Problem with Closed[] - help please

 

I am working on a script that reads back x bars. for bars 0-9 I get information, but from 10 to 15 and back all I get is 0.0 for closed, open, high, and low. I have also tried this with the iOpen, IClosed functions with the same results.

Is there something I need to do to load candle history past this point in my script.


for(int counter=1;counter>=15;counter++)
{
candle_array_open[counter] = Open[counter];
candle_array_closed[counter] = Close[counter];

candle_array_low[counter] = Low[counter]

candle_array_high[counter] = High[counter];

}


Thanks for any help in advance

 

F2 (history center) check if you have the data in those timeframes.

See Ickyrus' reply below.

 

I read your for loop as set counter equal to 1, while counter is greater than or equal to 15 then loop by adding one when code block end is reached.

In other words the for loop is not done.

 

That was just a quick loop i wrote for example, here is corrected. But the issue is not with the loop but that Open[10] to Open[nn] returns 0.0. Any [nn] over 9 returns 0.0000 This is the same for Closed, High, and Low, and also tried iClosed ..... versions.


If I do

double var = Closed[12] I get 0.0000

but for Closed[9] I do get the closed price.



for(int counter=1;counter<=15;counter++)

{
candle_array_open[counter] = Open[counter];
candle_array_closed[counter] = Close[counter];

candle_array_low[counter] = Low[counter]

candle_array_high[counter] = High[counter];

}

 

Having had a similar problem I must assume that the mistake lies in the array definition with you writing something like

double Candle_array_open[10] ;

instead of

double Candle_array_open[16] ; //the 15+1 is deliberate because your counter starts at 1 instead of zero and in order to have candle_array_open[15] you will need 16 memory slots.

 

Good catch that was it. Need to adjust the holding array size ...


Thanks

 
Always use one constant not multiple
#define LOOKBACK 16
double Candle_array_open[LOOKBACK];
for (int idx=0; idx < LookBack; idx++){
  candle_array_open[idx] = Open[idx+1];...
Reason: