I use the ADX Wilder buffer in my EA and realize that value in the array for the current bar  is different from the value I see in the data window of Strategy Tester, for the same bar. Values  and  are correct. For example the Data Window shows :
- ADX Wilder(14) = 46.70 (for bar EURUSD, M1, 2013.08.01 00:45:00) and array ADXWilderMain returns 51.42
- ADX Wilder(14) = 48.96 (for bar EURUSD, M1, 2013.08.01 00:44:00) and array ADXWilderMain returns 48.96
- ADX Wilder(14) = 46.30 (for bar EURUSD, M1, 2013.08.01 00:43:00) and array ADXWilderMain returns 46.30
DI+ and DI- are also wrong and DI+ and DI- are correct...
This is a problem for detecting buy or sell signal at the right bar. Please find bellow the code I use to handle the indicator and copy buffer. I use the GetIndicatorBuffer header. It is not clear for me what is going wrong. Clue from you guys would be appreciate a 0.1 lot :)
double ADXWilderMain; // array for MAIN_LINE of iADXWilder
double ADXWilderPlusDI; // array for PLUSDI_LINE of iADXWilder
double ADXWilderMinusDI; // array for MINUSDI_LINE of iADXWilder
int ADXWilder_handle; // handle of the indicator iADXWilder
//--- creation of the indicators
//--- report if there was an error in objects creation
Print("The creation of iADXWilder has failed: Runtime error =",GetLastError());
//--- forced program termination
ArraySetAsSeries(ADXWilderMain,true); // Same problem if I remove these 3 lines (dupplicate with GetADXWilderBuffers)
This is a problem for detecting buy or sell signal at the right bar. Please find bellow the code I use to handle the indicator and copy buffer. I use the GetIndicatorBuffer header. It is not clear for me what is going wrong. Clue from experimented people would be appreciate a 0.1 lot :)
Bar with index 0 is current bar, so ADX Wilder for this bar is always changing (on each tick). How do you know 46.70 and 51.42 are values produced at the same tick ?
Bar 1, 2, etc...are closed bars so the values doesn't change anymore.
Thank you it is more clear for me now. I understand that value in Data Window correspond to value of the bar after it is close, unlike value  that returns value of one tick of the current bar.
I suppose that signal detection based on indicator value must be performed on the previous bar with value  as the most recent data, m'I right ? I think like this because value 0 returns only one value for one tick, and in my case it does not fill the condition for signal detection. Some variable are then reseted and I lost the trend information.