Timeframe to timeframe comparison

To add comments, please log in or register
Duke Bushong
152
Duke Bushong  

I am obtaining certain values on one time frame. As an example, I may want to know when a fast ma crossed a slower ma. Then I may want to go one time frame higher and get the value of a stochastic  or a ma.  Since I am using a variable 'i' to reference a bar on the lower time frame, I cannot use the same 'i' to reference the equivalent bar on the upper time frame.  In other words if I am referencing bar #56 on the 5 min time frame then want to get the equivalent ma position on the 15 min time frame I cannot use the same 'i' that I used on the 5min time frame. Is there a way to use a timestamp (or whatever) to get to an equivalent position on an upper time frame?

Thank you... 

Simon Gniadkowski
17644
Simon Gniadkowski  
dukeb:

I am obtaining certain values on one time frame. As an example, I may want to know when a fast ma crossed a slower ma. Then I may want to go one time frame higher and get the value of a stochastic  or a ma.  Since I am using a variable 'i' to reference a bar on the lower time frame, I cannot use the same 'i' to reference the equivalent bar on the upper time frame.  In other words if I am referencing bar #56 on the 5 min time frame then want to get the equivalent ma position on the 15 min time frame I cannot use the same 'i' that I used on the 5min time frame. Is there a way to use a timestamp (or whatever) to get to an equivalent position on an upper time frame?

Get the time of  bar  i  on the higher timeframe using Time[] or iTime()  then use this datetime with iBarShift() to get the bar number for the higher timeframe.
Duke Bushong
152
Duke Bushong  

RaptorUK:
Get the time of  bar  i  on the higher timeframe using Time[] or iTime()  then use this datetime with iBarShift() to get the bar number for the higher timeframe.

                                                                                                                                                                                                                                             

                                                                                                                                                                                                                                             

Thank you, Raptor.. I will give it a try... 

whroeder1
17952
whroeder1  
dukeb: referencing bar #56 on the 5 min time frame then want to get the equivalent ma position on the 15 min time frame 
int iM5 = 56;
datetime dtM5 = Time[iM5];                   // on M5 chart
datetime dtM5 = iTime(NULL, PERIOD_M5, iM5); // On any TF
int iM15 = iBarShift(NULL, PERIOD_M15, dtM5);
Duke Bushong
152
Duke Bushong  
WHRoeder:


Thank you ... I really appreciate the help...
To add comments, please log in or register