Multiple Data Streams in Strategies
Posted: Sun Jul 02, 2006 9:49 pm
[font=Arial]I'm trying to reference daily EMA's in a strategy on an intraday chart, which also has the daily data stream for the same symbol as Data2.
I find that if I define any variables based on Data2, the strategy stops generating any trades. This is true even though I don't use those variables for anything or make any other changes in the code.
Can someone point me to what I'm doing wrong?
Here's the relevant code:
// Data1 is a 15-minute chart of a stock, over 2 years.
// Data2 is the daily data stream for the same symbol.
Inputs: // for 3 EMA's
UseEMAFilter(False)
ShortLength( 5),
MidLength(10),
LongLength(17);
// No problem with including these inputs.
Variables: // to check EMA alignment
ShortEMA(0, Data2),
MidEMA(0, Data2),
LongEMA(0, Data2),
Alignup(False),
AlignDn(False);
{If I include the above variable declarations, no trades are generated. If I comment out this Variables section, all the trades (40 or so) reappear.}
{What I want to do is the following. I can't get there because just defining the variables disables the strategy. Any help would be appreciated.
If Date>Date[1] THEN
BEGIN
// UseEMAFilter
IF UseEMAFilter THEN
Begin
// Calculations
ShortEMA = XAverage( Close , ShortLength ) of Data2;
MidEMA = XAverage( Close , MidLength ) of Data2;
LongEMA = XAverage( Close , LongLength ) of Data2;
// Check for alignment; don't comsider it aligned if all 3 are equal.
AlignUp = ShortEMA >= MidEMA AND MidEMA >= LongEMA // Each MA is >= the next slower one
AND (ShortEMA > MidEMA OR MidEMA > LongEMA OR ShortEMA > LongEMA); // Exclude the possibility that all 3 are equal.
AlignDn = ShortEMA <= MidEMA AND MidEMA <= LongEMA // Each MA is <= the next slower one
AND (ShortEMA < MidEMA OR MidEMA < LongEMA OR ShortEMA < LongEMA); // Exclude the possibility that all 3 are equal.
End
I then want to use the variables AlignUp and AlignDn as trade filters.[/font]
I find that if I define any variables based on Data2, the strategy stops generating any trades. This is true even though I don't use those variables for anything or make any other changes in the code.
Can someone point me to what I'm doing wrong?
Here's the relevant code:
// Data1 is a 15-minute chart of a stock, over 2 years.
// Data2 is the daily data stream for the same symbol.
Inputs: // for 3 EMA's
UseEMAFilter(False)
ShortLength( 5),
MidLength(10),
LongLength(17);
// No problem with including these inputs.
Variables: // to check EMA alignment
ShortEMA(0, Data2),
MidEMA(0, Data2),
LongEMA(0, Data2),
Alignup(False),
AlignDn(False);
{If I include the above variable declarations, no trades are generated. If I comment out this Variables section, all the trades (40 or so) reappear.}
{What I want to do is the following. I can't get there because just defining the variables disables the strategy. Any help would be appreciated.
If Date>Date[1] THEN
BEGIN
// UseEMAFilter
IF UseEMAFilter THEN
Begin
// Calculations
ShortEMA = XAverage( Close , ShortLength ) of Data2;
MidEMA = XAverage( Close , MidLength ) of Data2;
LongEMA = XAverage( Close , LongLength ) of Data2;
// Check for alignment; don't comsider it aligned if all 3 are equal.
AlignUp = ShortEMA >= MidEMA AND MidEMA >= LongEMA // Each MA is >= the next slower one
AND (ShortEMA > MidEMA OR MidEMA > LongEMA OR ShortEMA > LongEMA); // Exclude the possibility that all 3 are equal.
AlignDn = ShortEMA <= MidEMA AND MidEMA <= LongEMA // Each MA is <= the next slower one
AND (ShortEMA < MidEMA OR MidEMA < LongEMA OR ShortEMA < LongEMA); // Exclude the possibility that all 3 are equal.
End
I then want to use the variables AlignUp and AlignDn as trade filters.[/font]