Timeframe to timeframe comparison

 

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... 

 
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.
 

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... 

 
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);
 
WHRoeder:


Thank you ... I really appreciate the help...
Reason: