Problems running an indicator

 

Hi everyone,

I'm experiencing an issue while calling the indicator StepMA_v7.1 (written by Igorad) from an EA. I don't get the same results as the ones I see on the chart. For instance, when the trend is clearly red (all drawn in red), I get many up trend signals.

Here is the code of my "EA" :

int start()

{

// Catches up signals

double stepU = NormalizeDouble(iCustom(NULL, 0, "StepMA_v7.1", 10, 0.3, 0, 0, 0, 0, true, 2, 0, 1, 0), Digits);

// Catches down signals

double stepD = NormalizeDouble(iCustom(NULL, 0, "StepMA_v7.1", 10, 0.3, 0, 0, 0, 0, true, 2, 0, 2, 0), Digits);

if (stepU != EMPTY_VALUE && stepD != EMPTY_VALUE)

Print("UP/DOWN => " + stepU + "/" + stepD);

else

if (stepU != EMPTY_VALUE)

Print("UP => " + stepU);

else

if (stepD != EMPTY_VALUE)

Print("DOWN => " + stepD);

return (0);

}

I've ran it with the open price only method. Well, I was thinking of what could produce differences between indicators shown on a chart and indicators ran from an EA. Well, I guess there's a difference in the moment where the indicator is called. Correct me if I'm wrong, but on a chart, an indicator is called at the CLOSE of each bar while from an EA, it's the opening of the bars that triggers the start() function. Now, to try to call my indicators under the same conditions, I've chosen the open price only method and used 1 as shift in order to get the last bar CLOSE. But it didn't work.

Do you have an idea of what's going on ?

I enclosed a picture with the post so you can see the problem.

Thanks in advance,

Mark

Files:
chart_1.jpg  664 kb
Reason: