Array out of range while a function works perfect

 

Hellow folk(s)

i have this function 

double high_price() {
   int highSto_price;
   highSto_price = iHighest(Symbol(), PERIOD_H1, MODE_HIGH, x_hours, 0);
   return (High[highSto_price]);
}

that return the high stock price for a certain period of hours ...It works well but i get an error while passing the EA to the market Array out of range on its return array 167,25 ...What might be the problem..Also if the method is wrong i need help on getting the high price value after certain hours

The checks a trading robot must pass before publication in the Market
The checks a trading robot must pass before publication in the Market
  • www.mql5.com
Before any product is published in the Market, it must undergo compulsory preliminary checks, as a small error in the expert or indicator logic can cause losses on the trading account. That is why we have developed a series of basic checks to ensure the required quality level of the Market products. If any errors are identified by the Market...
 
Omega J Msigwa:

Hellow folk(s)

i have this function 

that return the high stock price for a certain period of hours ...It works well but i get an error while passing the EA to the market Array out of range on its return array 167,25 ...What might be the problem..Also if the method is wrong i need help on getting the high price value after certain hours

What is x_hours and what code is on line 167?


I know that it is not obvious, but topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I will move your topic to the MQL4 and Metatrader 4 section.

 
  1. Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum?
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2.    highSto_price = iHighest(Symbol(), PERIOD_H1, MODE_HIGH, x_hours, 0);
       return (High[highSto_price]);
    Unless you are running on the H1 chart, You are mixing apples and oranges.
  3. On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
              Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26.4 2019.05.20

 
Keith Watford:

What is x_hours and what code is on line 167?


I know that it is not obvious, but topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I will move your topic to the MQL4 and Metatrader 4 section.

x_hours is 172 

line 167 is 
return (High[highSto_price]);
 
Omega J Msigwa:

x_hours is 172 

line 167 is 

Then it is probably as William has pointed out.