You already have it. Your problem is else where. Probably exceeding array size.
fEndMA=iMA(NULL,0,MAPeriod,0,MAMode,Price,i+EndMAShift); fStartMA=iMA(NULL,0,MAPeriod,0,MAMode,Price,i+StartMAShift);
Your max look back is StartMaShift (you test End >= Start) so do your loop correctly.Your code Look back handled nCountedBars = IndicatorCounted(); //---- check for possible errors if(nCountedBars<0) return(-1); //---- last counted bar will be recounted if(nCountedBars>0) nCountedBars--; nLimit = Bars-nCountedBars; ShiftDif = StartMAShift-EndMAShift; mFactor = 100*840/Period()/ShiftDif; Sym = StringSubstr(Symbol(),3,3); //---- main loop for(i=0; i<nLimit; i++)
Decrement is unnecessary Contradictory information on IndicatorCounted() - MQL4 forumnCountedBars = IndicatorCounted(); //---- check for possible errors if(nCountedBars<0) return(-1); //---- last counted bar will be recounted // if(nCountedBars>0) // nCountedBars--; // nLimit = Bars-nCountedBars; ShiftDif = StartMAShift-EndMAShift; mFactor = 100*840/Period()/ShiftDif; Sym = StringSubstr(Symbol(),3,3); //---- main loop for(i= Bars - 1 - MathMax(nCountedBars, StartMAShift); i>=0; i--)
Get in the habit of counting down. (can't use future values to compute past ones.)
Thank you very much it works !
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello,
How do you make an indicator autoscroll? I use this indicator that calculates a moving average angle but I need to refresh it al the time.
What do I need to change/add so that it will automatically update on new tics/bars ?
Thanks