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?
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...
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);
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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...