when you write iMAOnArray on the editor ,just type "F1" an help box below will appear
Hey Blue,
how did you like the tutorial posted by CodersGuru on this forum?
ps. any chance for updating the st2w diary ?
Strange behaviour using iMAOnArray
I have modified an indicator which has 2 existing buffers to include iMAOnArray on 1 of the buffers. I have coded the first 2 buffers to DRAW_NONE and the 3 iMAOnArray buffers to DRAW_LINE.
If I add the indicator to a chart it does not plot the iMAOnArray buffers and instead returns a strange value for them as in the image.
If I then compile the indicator with it already attached to the chart it will plot as intended as in this image.
If I then try to alter the indicator inputs, it will fail to plot again.
This is the code:
int start()
{
// UPBuffer[0] = Trend_UP;
// DOWNBuffer[0] = Trend_DOWN;
//---- Result of the trend
int limit;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
// limit=Bars-counted_bars;
if(counted_bars>0) limit=Bars-counted_bars;
limit--;
int maxvalue;
if (firstrun) {maxvalue=lookback;firstrun=false;} else {maxvalue=2;}
{
for(int i=maxvalue; i>=0; i--)
// for(int i=0; i<=maxvalue; i++)
{
calcola(i);
RANGEBuffer = StrToDouble(Trend_UP) ;
RANGEBuffer1 = StrToDouble(Trend_DOWN) ;
RANGEBufferfast = iMAOnArray(RANGEBuffer,0,Fast_ema,0,MODE_EMA,i);
RANGEBuffermedium = iMAOnArray(RANGEBuffer,0,Medium_ema,0,MODE_EMA,i);
RANGEBufferslow = iMAOnArray(RANGEBuffer,0,Slow_sma,0,MODE_SMA,i);
} // for
}
return(0);
}
Could somebody please explain what I'm doing wrong?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use