DislikedInserted Codeint start () double emaCustomIndicator = iMA(NULL,0,emaPeriod,0,MODE_EMA,customIndicatorOutput,i); ...Ignored
Try this:
Inserted Code
static double emaBuffer[];
static int lastBars = 0;
if(Bars != lastBars) {
ArrayResize(emaBuffer, Bars);
ArraySetAsSeries(emaBuffer, true);
for(int j = Bars-1; j >= 0; j--) {
double customVal = iCustom(NULL,0,"CustomIndicator",param1,param2,param3,0,j);
if(j == Bars-1) {
emaBuffer[j] = customVal;
} else {
double alpha = 2.0 / (emaPeriod + 1.0);
emaBuffer[j] = alpha * customVal + (1.0 - alpha) * emaBuffer[j+1];
}
}
lastBars = Bars;
}
double emaCustomIndicator = emaBuffer[i]; 1