ATTENTION: this indicator is WRONG!
You cannot call iMA on different timeframes using the same barshift of the current timeframe.... what you get is a senseless series of numbers.
The correct way to address data from different timeframes is to get, in the current timeframe, the time of opening of the bar you want to process (i) and using iBarshift find out to which bar of another timeframe that opening time belongs.
Visually you should expect to see MA of bigger timeframes moving by steps, ie you need 5 M1 bars to make an M5 bar... and if the current timeframe is M1 the displayed MA for M5 shall remain constant for 5 bars... and so on :)
Here a sample code which will fix your indicator:
I used same MA periods and methods for different timeframes. Also added the option to change applied prices from external.
//-------------------------------------------------------------------- Counted_bars=IndicatorCounted(); i=Bars-Counted_bars-1; while(i>=0) { time=iTime(Symbol(),0,i); iM1=iBarShift(Symbol(),ma1_TF,time,false); iM2=iBarShift(Symbol(),ma2_TF,time,false); iM3=iBarShift(Symbol(),ma3_TF,time,false); Buf_0[i]=iMA(Symbol(),ma1_TF,MA_Period,0,MA_Method,MA_AppliedPrice,iM1); Buf_1[i]=iMA(Symbol(),ma2_TF,MA_Period,0,MA_Method,MA_AppliedPrice,iM2); Buf_2[i]=iMA(Symbol(),ma3_TF,MA_Period,0,MA_Method,MA_AppliedPrice,iM3); i--; } //--------------------------------------------------------------------

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
MultiMA:
Author: r.v.