error message in journals. array out of range in (214,36)?

Back to topics list To post a new topic, please log in or register
avatar
273
sheriffonline 2015.09.30 17:37
 

What could be the issue?

    ZEROAM= FromHours-4;
    THREEAM= FromHours-1;
    threeAM=0; while( TimeHour(Time[threeAM]) != THREEAM ) threeAM++;
    EJHigh7To10 = iHigh(NULL,PERIOD_H1,iHighest(NULL,PERIOD_H1,MODE_HIGH, THREEAM-ZEROAM+1,threeAM));
    EJLow7To10 = iLow(NULL,PERIOD_H1,iLowest(NULL,PERIOD_H1,MODE_LOW, THREEAM-ZEROAM+1,threeAM));
    EJ_Diff=EJHigh7To10-EJLow7To10;
    EJ_Hval=EJHigh7To10;
    EJ_Lval=EJLow7To10;

avatar
736
honest_knave 2015.09.30 17:52 #
 

Possibly either

FromHours is set to 0, meaning you are trying to access Time[-1]

FromHours is set to a very large number, which means you are trying to access an index > Bars

Without seeing your use of FromHours it is hard to tell. 

 

 

avatar
273
sheriffonline 2015.09.30 18:17 #
 
honest_knave:

Possibly either

FromHours is set to 0, meaning you are trying to access Time[-1]

FromHours is set to a very large number, which means you are trying to access an index > Bars

Without seeing your use of FromHours it is hard to tell. 

 

 

From Hours is 10:00
avatar
736
honest_knave 2015.09.30 18:28 #
 

How have you declared it (show the code)

 

avatar
273
sheriffonline 2015.09.30 18:53 #
 
honest_knave:

How have you declared it (show the code)

 

extern int FromHours = 10;
extern int ToHours = 20;
int ZEROAM=0;
int THREEAM=0;
int threeAM=0;
double EJHigh7To10=0;
double EJLow7To10=0;
double EJ_Diff=0;
ZEROAM= FromHours-4;
THREEAM= FromHours-1;
threeAM=0; while( TimeHour(Time[threeAM]) != THREEAM ) threeAM++;
EJHigh7To10 = iHigh(NULL,PERIOD_H1,iHighest(NULL,PERIOD_H1,MODE_HIGH, THREEAM-ZEROAM+1,threeAM));
EJLow7To10 = iLow(NULL,PERIOD_H1,iLowest(NULL,PERIOD_H1,MODE_LOW, THREEAM-ZEROAM+1,threeAM));
EJ_Diff=EJHigh7To10-EJLow7To10;
EJ_Hval=EJHigh7To10;
EJ_Lval=EJLow7To10;
Comment("High: ",EJ_Hval," Low: ",EJ_Lval," Range: ",EJ_Diff);

avatar
736
honest_knave 2015.09.30 19:17 #
 

Given that threeAM is set to 0:

threeAM=0; while( TimeHour(Time[threeAM]) != THREEAM ) threeAM++;

 

And the increment is positive

threeAM=0; while( TimeHour(Time[threeAM]) != THREEAM ) threeAM++;


I would surmize that your while loop is continuing until it exceeds Bars... are you running this on a backtest? 

 

avatar
273
sheriffonline 2015.09.30 19:20 #
 
honest_knave:

Given that threeAM is set to 0:

 

And the increment is positive


I would surmize that your while loop is continuing until it exceeds Bars... are you running this on a backtest? 

 

Forgot to mention that the code works fine, but when i use the code with 4H time frame i get the error as i mentioned on subject.

yes, i get the error while backtesting.

avatar
736
honest_knave 2015.09.30 19:31 #
 

You set THREEAM as 10-1 = 9 

Unless you have a very strange broker, your H4 bars never start at 09:00.

So your loop will continue indefinitely 

threeAM keeps increasing until it exceeds Bars

Then you get an array out of range error. 

avatar
273
sheriffonline 2015.09.30 19:41 #
 
honest_knave:

You set THREEAM as 10-1 = 9 

Unless you have a very strange broker, your H4 bars never start at 09:00.

So your loop will evaluate as false indefinitely. 

threeAM keeps increasing until it exceeds Bars

Then you get an array out of range error. 

Thank you honest_knave. got my logic error.

i fixed it. Thanks honest_knave

avatar
13001
WHRoeder 2015.09.30 21:19 #
 
If you had printed your values (threeAM, Time[threeAM], TimeHour(Time[threeAM]), THREEAM) inside your loop, you would have found the problem.
avatar
273
sheriffonline 2015.09.30 22:13 #
 
WHRoeder:
If you had printed your values (threeAM, Time[threeAM], TimeHour(Time[threeAM]), THREEAM) inside your loop, you would have found the problem.

Thanks WHRoeder. yes. same i did as you mentioned here. the issue is tf issue as honest_knave mentioned.

fixed it by filtering tf.


Back to topics list  

To add comments, please log in or register