Wrong value in ADX Wilder array[0]

 

Hello,


I use the ADX Wilder buffer in my EA and realize that value in the array for the current bar [0] is different from the value I see in the data window of Strategy Tester, for the same bar. Values [1] and [2] 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[0] returns 51.42

- ADX Wilder(14) = 48.96 (for bar EURUSD, M1, 2013.08.01 00:44:00) and array ADXWilderMain[1] returns 48.96

- ADX Wilder(14) = 46.30 (for bar EURUSD, M1, 2013.08.01 00:43:00) and array ADXWilderMain[2] returns 46.30


DI+[0] and DI-[0] are also wrong and DI+[1] and DI-[1] 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 :)

Thank you

Vivaldi

#include <GetIndicatorBuffers.mqh>

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

...

int OnInit()
  {
  
   //--- creation of the indicators
   ADXWilder_handle=iADXWilder(NULL,0,ADXWilderPeriod);
     
   //--- report if there was an error in objects creation
   
   if(ADXWilder_handle<0)
     {
      Print("The creation of iADXWilder has failed: Runtime error =",GetLastError());
      //--- forced program termination
      return(-1);
     }
   return(0); 
   ...

  }

void OnTick()
  
  {
   ...
   
      ArraySetAsSeries(ADXWilderMain,true); // Same problem if I remove these 3 lines (dupplicate with GetADXWilderBuffers)
      ArraySetAsSeries(ADXWilderPlusDI,true);
      ArraySetAsSeries(ADXWilderMinusDI,true);

      if(!GetADXWilderBuffers(ADXWilder_handle,0,100,ADXWilderMain,ADXWilderPlusDI,ADXWilderMinusDI,true)) return;

  ...
  }





 
Vivaldi:

Hello,


I use the ADX Wilder buffer in my EA and realize that value in the array for the current bar [0] is different from the value I see in the data window of Strategy Tester, for the same bar. Values [1] and [2] 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[0] returns 51.42

- ADX Wilder(14) = 48.96 (for bar EURUSD, M1, 2013.08.01 00:44:00) and array ADXWilderMain[1] returns 48.96

- ADX Wilder(14) = 46.30 (for bar EURUSD, M1, 2013.08.01 00:43:00) and array ADXWilderMain[2] returns 46.30


DI+[0] and DI-[0] are also wrong and DI+[1] and DI-[1] 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 experimented people would be appreciate a 0.1 lot :)

Thank you

Vivaldi

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.

 

Hi,

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 [0] 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 [1] 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.

Vivaldie

 
Vivaldi:

Hi,

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 [0] 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 [1] 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.

Vivaldie

Yes, signal on closed candle is better, as signal on current can be false signal. Although there are traders who trade on open candle, probably with some filters.
Reason: