Problem with ADX indicator and CopyBuffer function

 

Hello, I am new to this and I am trying to do an EA with the ADX indicator, for the signal system I try to use the CopyBuffer function but I cannot get the correct values, I want to use the main line and the level of the indicator to generate a signal when the market is lateralized, example L> 25, but I cannot bring the correct values ​​of the indicator could someone help me? 


   handle3=iADX(NULL,0,ADX_Periodo);

   if(handle3==INVALID_HANDLE){ return(INIT_FAILED); }


   CopyBuffer(handle3,MAIN_LINE,0,3,adxVal);

   CopyBuffer(handle3,PLUSDI_LINE,0,3,plsDI);

   CopyBuffer(handle3,MINUSDI_LINE,0,3,minDI);  ArraySetAsSeries(plsDI,true);

  ArraySetAsSeries(minDI,true);

  ArraySetAsSeries(adxVal,true);


   if(adxVal[0]>25)

     if(plsDI[0]>minDI[0])

  {            buytime1=iTime(Symbol(),TimeFrame,1);

if(Alertas)

               Alert(Symbol()+" Buy signal TimeFrame: "+myperiod);...


it gives me values ​​that have nothing to do with reality

 
wmpbass:

Hello, I am new to this and I am trying to do an EA with the ADX indicator, for the signal system I try to use the CopyBuffer function but I cannot get the correct values, I want to use the main line and the level of the indicator to generate a signal when the market is lateralized, example L> 25, but I cannot bring the correct values ​​of the indicator could someone help me? 

it gives me values ​​that have nothing to do with reality

These lines are fine, so the culprit is likely elsewhere.

 
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. Do you create the handle in OnInit and get the buffers in OnTick?
Reason: