Multiple Data Streams in Strategies

trading strategies and money management discussion, code, results

Moderator: moderators

msrussllc
rank: <50 posts
rank: <50 posts
Posts: 1
Joined: Fri Jun 09, 2006 6:00 pm
Reputation: 0
Location: Mount Shasta, CA
Real name: Russ Allen
Gender: Male

Multiple Data Streams in Strategies

Postby msrussllc » 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]
Russ Allen

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.

User avatar
TheRumpledOne
rank: 10000+ posts
rank: 10000+ posts
Posts: 15558
Joined: Sun May 14, 2006 9:31 pm
Reputation: 3035
Location: Oregon
Real name: Avery T. Horton, Jr.
Gender: None specified
Contact:

Postby TheRumpledOne » Sun Jul 02, 2006 11:30 pm

try this:


Variables: // to check EMA alignment
ShortEMA(0),
MidEMA(0),
LongEMA(0),
Alignup(False),
AlignDn(False);
IT'S NOT WHAT YOU TRADE, IT'S HOW YOU TRADE IT!

Please do NOT PM me with trading or coding questions, post them in a thread.

User avatar
TheRumpledOne
rank: 10000+ posts
rank: 10000+ posts
Posts: 15558
Joined: Sun May 14, 2006 9:31 pm
Reputation: 3035
Location: Oregon
Real name: Avery T. Horton, Jr.
Gender: None specified
Contact:

Postby TheRumpledOne » Sun Jul 02, 2006 11:31 pm

And you may also need:

ShortEMA = XAverage( Close of Data2, ShortLength ) ;
MidEMA = XAverage( Close of Data2, MidLength ) ;
LongEMA = XAverage( Closeof Data2 , LongLength ) ;
IT'S NOT WHAT YOU TRADE, IT'S HOW YOU TRADE IT!



Please do NOT PM me with trading or coding questions, post them in a thread.

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.


Return to “strategy trading & money management”