Download MetaTrader 5
To add comments, please log in or register
Carry on your private correspondence in your profile. It is secure!
Peter Williams
344
Peter Williams 2013.11.14 14:45 

I have used ADX in the past with no problem. I have just tried to access values for DI+ & DI- and they appear so different than on the chart. I use the Comment statement to display the values on the top part of the screen. The lower half displays the value as shown by the indicator.

ADX Values

I use the following code to retrieve the values:-

   string My_OrderSymbol = Symbol();
   int My_ADX_Period = 14;
   double My_ADX_Limit = 25;
   double My_ADX ;
   double My_ADX_DMI_Minus;
   double My_ADX_DMI_Plus;
   int digits ;
   double My_ADX_Last_value;
   digits            =  MarketInfo(My_OrderSymbol,MODE_DIGITS);
   My_ADX            = iADX(My_OrderSymbol,1,My_ADX_Period,PRICE_OPEN   ,0,0); //My_ADX_Limit = 25;
   My_ADX_Last_value = iADX(My_OrderSymbol,1,My_ADX_Period,PRICE_OPEN   ,0,1); //My_ADX_Limit = 25;
   My_ADX_DMI_Minus  = iADX(My_OrderSymbol,1,My_ADX_Period,MODE_MINUSDI ,0,0); //My_ADX_Limit = 25; 
   My_ADX_DMI_Plus   = iADX(My_OrderSymbol,1,My_ADX_Period,MODE_PLUSDI  ,0,0); //My_ADX_Limit = 25;
   string st_30201 = My_OrderSymbol+"\nMy_ADX("+My_ADX_Period+"/"+DoubleToStr(My_ADX_Limit,0)+") = "+DoubleToStr(My_ADX,digits)+
      "\nMy_ADX_Last_value = "+DoubleToStr(My_ADX_Last_value,digits)+
      "\nMy_ADX_DMI_Minus = "+DoubleToStr(My_ADX_DMI_Minus,digits)+
      "\nMy_ADX_DMI_Plus = "+DoubleToStr(My_ADX_DMI_Plus,digits);
   Comment(st_30201);

I suspect the answer is staring me in the face - but just can't relate to the numbers or what else to use

whroeder1
14457
whroeder1 2013.11.14 14:54  
peterhw1:
   My_ADX_DMI_Minus  = iADX(My_OrderSymbol,1,My_ADX_Period,MODE_MINUSDI ,0,0); //My_ADX_Limit = 25; 

I suspect the answer is staring me in the face - but just can't relate to the numbers or what else to use

Yep.When in doubt, RTFM
double iADX(    string symbol, int timeframe, int period, int applied_price, int mode, int shift)
     = iADX(My_OrderSymbol,1,My_ADX_Period,MODE_MINUSDI ,0,0);
               ^symbol     ^TF ^period          ^ not an applied_price MINUSDI=2=PRICE_HIGH
                                                         ^mode=0=MODE_MAIN
Peter Williams
344
Peter Williams 2013.11.15 14:38  

Got it - many thanks.

Yes I now see the constants were being used.

Thanks again

/
To add comments, please log in or register