You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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