How to recalculate indicator in back testing?

 

Hi all:

I am currently writing an EA based  the Zigzag indicator. As you know that, the Zigzag swing high or swing low may change as the market is going. 

 

In my EA, I wrote something like:

 

zArr[1000]; 

zHighArr[1000];

zLowArr[1000]; 

for (int i=0; i< 1000; i++){ 

        zArr =  iCustom(NULL, 0, "Zigzag", 25, 5, 25, 0, i); 




        zHighArr =  iCustom(NULL, 0, "Zigzag", 25, 5, 25, 1, i);

        zLowArr =  iCustom(NULL, 0, "Zigzag", 25, 5, 25, 2, i); 

} 

 As you can see from the last image, the arrow shows that at the time that I want to open a long order in the back testing, 

the Zigzag swing high should be at the arrow several bars ago. However, as I use the iCustom method to fetch the Zigzag values from the indicator buffer.

I got no  Zigzag swing high at where I suppose it should be.  In fact, I can only get the Zigzag swing high when the Zigzag line is drawn completely. 

 

Is there any way to re-calculate the indicator during the back testing so that I can see the correct action of  my EA please?

 

Thanks

 
asuralm:

 

Is there any way to re-calculate the indicator during the back testing so that I can see the correct action of  my EA please?

Not all Indicators work correctly when run on a chart produced by the Strategy Tester,  it's something you need to be wary of.
 
RaptorUK:
Not all Indicators work correctly when run on a chart produced by the Strategy Tester,  it's something you need to be wary of.


Thanks for your quick reply. Do you mean that for a self-updating indicator, like Zigzag, there is no way to simulate its behavior in the real market? Pessimistically, there is no way to prove my EA logic in that case?????
 
Is there any solution to this problem?????? Can anyone please help me!!!
 
You can run tester in Visual mode with ZigZag attached to the chart to see how ZigZag is being drawn and when it gets re-calculated in real time. There are many variations of ZigZag indicator out there so if you're not happy how the default MT4 ZigZag behaves, you can download and try a different one.
 
asuralm:

Thanks for your quick reply. Do you mean that for a self-updating indicator, like Zigzag, there is no way to simulate its behavior in the real market? Pessimistically, there is no way to prove my EA logic in that case?????
Create a simple Indicator that print's Bid price to screen using Comment(),  attach it to a Strategy tester chart and see what value you get  . . .  I can tell you now that you will get the last Bid price before the markets closed on Friday . . .  as I said,  not all Indicators function correctly on a strategy tester chart . . . .  the Strategy Tester is designed to test Strategies,  EAs.  If you call your Indicator from your EA using iCustom() it will return the correct values,  assuming your iCustom() call is correct.
Reason: