Download MetaTrader 5

Custom Indicator, accessing indicator values.

To add comments, please log in or register
Do you keep a blog? Place a link to MQL5.community there and make money!
mcai4sh3
37
mcai4sh3 2010.11.25 14:20 

Hi,

 

I am trying to create a custom coloured indicator X. X uses a number of "base" indicators to calculate its own indicator value. One of the base indicators is ATR. Please see extract of my code to see how I access this ATR indicator values:

 

int atrHandle;

double atrVal[];

 

int OnInit( ) {

//ATR INIT

         atrHandle=iATR(NULL,PERIOD_H1,ATRPERIOD);              

         ArraySetAsSeries(atrVal,true);

 }

int OnCalculate(const int rates_total,

                const int prev_calculated,

                const datetime &time[],

                const double &open[],

                const double &high[],

                const double &low[],

                const double &close[],

                const long &tick_volume[],

                const long &volume[],

                const int &spread[])

 {

  CopyBuffer(atrHandle,0,0,rates_total,atrVal) \\ get me all ATR values for the entire chart

 

QUESTION 1

When I try to copy all the values (rates_total) from atrVAL I get the following output. Note rates_total-1 is the first bar on the chart. 

atrVal[rates_total-1]=1.797693134862316e+308

atrVal[0]=0.001854666666666693


I don't understand why I am getting a strange number for the first bar (rates_total-1).  It seems like there is a threshold to the number of indicator values you can recieve, i.e. if I only get the last 100 bars ATR values then they all seem corrent. Its just when I overload the CopyBuffer with a task to get me all the indicator values for the entire chart do I start getting strange number like atrVal[rates_total-1]=1.797693134862316e+308.

Is it something to do with the fact that the atrVal is of type double []?


any help would be appreciated.

 

mcai4sh3 

Documentation on MQL5: Standard Constants, Enumerations and Structures / Chart Constants / Types of Chart Events
  • www.mql5.com
Standard Constants, Enumerations and Structures / Chart Constants / Types of Chart Events - Documentation on MQL5
Rashid Umarov
Admin
11814
Rashid Umarov 2010.11.26 15:33  
To add comments, please log in or register