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:
PHP 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[i] = StrToDouble(Trend_UP) ;
RANGEBuffer1[i] = StrToDouble(Trend_DOWN) ;
RANGEBufferfast[i] = iMAOnArray(RANGEBuffer,0,Fast_ema,0,MODE_EMA,i);
RANGEBuffermedium[i] = iMAOnArray(RANGEBuffer,0,Medium_ema,0,MODE_EMA,i);
RANGEBufferslow[i] = iMAOnArray(RANGEBuffer,0,Slow_sma,0,MODE_SMA,i);
} // for
}
return(0);
}
Could somebody please explain what I'm doing wrong?