Using Two Time Frames Within One Script  [SOLVED]

Questions about MultiCharts and user contributed studies.
tony
Posts: 420
Joined: 14 Jun 2013
Has thanked: 30 times
Been thanked: 81 times
Contact:

Using Two Time Frames Within One Script

Postby tony » 23 Jun 2013

I'm currently writing a script that trades a 15 min. bar but uses a 5 min. bar as part of the conditional state to go long, short, exit, etc. I have the instrument on a chart with the 5 min bar as "sub chart #1" and a 15 min. as "sub chart #2." Within my script I reference the 5 min. bar as "Data1" and the 15 min as "Data2."

I have these data series referenced in my variables but I suspect I am missing a reference in the following statement

"Buy ( "LE2" ) 2 Contracts Next Bar at Market;"

The reason I say that is the 5 min bar chart (Data1, sub chart #1) is actually populating with my trade signals. But I am desiring it to be on the 15 min bar chart (Data2, sub chart #2).

I also have one more question in regards to the above. Each data series uses Bollinger Bands within the conditional statements.

In the inputs I define the SD up and SD down for the bands but am not sure if I am properly specifying what data series to use in calculating one standard deviation for both Data1 and Data2.

What I currently have written for variables are

var1( 0, data2),
var14( 0, data1),

And then I assign these variables as follows

var1 = StandardDev( BollingerPrice, Length, 1 );
var14 = StandardDev( BollingerPrice, Length, 1);

Thanks for any help anyone can provide.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Using Two Time Frames Within One Script

Postby TJ » 24 Jun 2013

I'm currently writing a script that trades a 15 min. bar but uses a 5 min. bar as part of the conditional state to go long, short, exit, etc. I have the instrument on a chart with the 5 min bar as "sub chart #1" and a 15 min. as "sub chart #2." Within my script I reference the 5 min. bar as "Data1" and the 15 min as "Data2."

I have these data series referenced in my variables but I suspect I am missing a reference in the following statement

"Buy ( "LE2" ) 2 Contracts Next Bar at Market;"

The reason I say that is the 5 min bar chart (Data1, sub chart #1) is actually populating with my trade signals. But I am desiring it to be on the 15 min bar chart (Data2, sub chart #2).

I also have one more question in regards to the above. Each data series uses Bollinger Bands within the conditional statements.

In the inputs I define the SD up and SD down for the bands but am not sure if I am properly specifying what data series to use in calculating one standard deviation for both Data1 and Data2.

What I currently have written for variables are

var1( 0, data2),
var14( 0, data1),

And then I assign these variables as follows

var1 = StandardDev( BollingerPrice, Length, 1 );
var14 = StandardDev( BollingerPrice, Length, 1);

Thanks for any help anyone can provide.
Please see post #4 and post #5
viewtopic.php?f=16&t=6929

tony
Posts: 420
Joined: 14 Jun 2013
Has thanked: 30 times
Been thanked: 81 times
Contact:

Re: Using Two Time Frames Within One Script

Postby tony » 24 Jun 2013

Once again thank you TJ! I may have one more question but so far what you advised worked. I appreciate the help!

tony
Posts: 420
Joined: 14 Jun 2013
Has thanked: 30 times
Been thanked: 81 times
Contact:

Re: Using Two Time Frames Within One Script

Postby tony » 24 Jun 2013

My script is still applying signals to Data1, the slower of the two timeframes and NOT Data2 as I want it to. Data1 and Data2 are clearly referenced throughout the script including the additional reference in the function as TJ kindly pointed out.

In reading about EL I understand the default Data1 is based on the instrument that "created" the chart. So in this case I have Sub Chart #1 as the faster timeframe and designate it Data1 in my script (Data2 and Sub Chart #2 is the slower timeframe).

Should I have the slower timeframe (the one I want to signal off) as Data1 and Sub Chart #1 and then the faster as Data2 and Sub Chart #2? I read in this forum that the shorter timeframe should be Data1 though.

Thank You!

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Using Two Time Frames Within One Script

Postby TJ » 24 Jun 2013

My script is still applying signals to Data1, the slower of the two timeframes and NOT Data2 as I want it to. Data1 and Data2 are clearly referenced throughout the script including the additional reference in the function as TJ kindly pointed out.

In reading about EL I understand the default Data1 is based on the instrument that "created" the chart. So in this case I have Sub Chart #1 as the faster timeframe and designate it Data1 in my script (Data2 and Sub Chart #2 is the slower timeframe).

Should I have the slower timeframe (the one I want to signal off) as Data1 and Sub Chart #1 and then the faster as Data2 and Sub Chart #2? I read in this forum that the shorter timeframe should be Data1 though.

Thank You!
Please post your codes.
Please post a screenshot and write notes on it to point out to the problem you are having.


[FAQ] How to Post Codes
viewtopic.php?f=16&t=11713

tony
Posts: 420
Joined: 14 Jun 2013
Has thanked: 30 times
Been thanked: 81 times
Contact:

Re: Using Two Time Frames Within One Script

Postby tony » 24 Jun 2013

I can't share the conditional statements. Is there a specific section I can share within the script?

tony
Posts: 420
Joined: 14 Jun 2013
Has thanked: 30 times
Been thanked: 81 times
Contact:

Re: Using Two Time Frames Within One Script

Postby tony » 24 Jun 2013

It appears I can only apply this signal which I wrote to Sub Chart #1 and NOT Sub Chart #2. So that would tell me I need to reference Sub Chart #1 as my slower timeframe and thus Data1 and the faster timeframe as Sub Chart #2 and Data2.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Using Two Time Frames Within One Script

Postby TJ » 24 Jun 2013

It appears I can only apply this signal which I wrote to Sub Chart #1 and NOT Sub Chart #2. So that would tell me I need to reference Sub Chart #1 as my slower timeframe and thus Data1 and the faster timeframe as Sub Chart #2 and Data2.
Please read

Multi-data strategy... pg. 34

tony
Posts: 420
Joined: 14 Jun 2013
Has thanked: 30 times
Been thanked: 81 times
Contact:

Re: Using Two Time Frames Within One Script  [SOLVED]

Postby tony » 25 Jun 2013

As a follow up to anyone asking similar questions, you need to make "Data1" the data series you are applying the study to and not necessarily the shorter time series. So in my case I assigned Data1 (sub chart 1) as the longer time series which I am signaling off and therefore by default Data2 (sub chart 2) as the shorter time series. I am now signaling on the proper timeframe. But I do need to confirm that each data series is referenced properly.

Thank you TJ for the assistance and for the most recent info regarding using multiple time frames. It's on my reading for today. I appreciate the help!

User avatar
Analyst
Posts: 19
Joined: 09 Jul 2013
Has thanked: 3 times
Been thanked: 2 times

Re: Using Two Time Frames Within One Script

Postby Analyst » 31 Jul 2013

Multi-data strategy... pg. 34? In the MC.NET User Manual? I can't find it.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Using Two Time Frames Within One Script

Postby TJ » 31 Jul 2013

Multi-data strategy... pg. 34? In the MC.NET User Manual? I can't find it.
the "pg.34" refers to the link in the discussion of previous post.


Please see post #4
Multi-data strategy... pg. 34
viewtopic.php?f=16&t=6929


Return to “MultiCharts”