Download MetaTrader 5

iHighest/iLowest question

To add comments, please log in or register
corresandberg
33
corresandberg  

Hi!

I want to understand both of those functions and will layout my explanation on how I use them. Any experienced programmer feel free to correct my thoughts.

 

code....

 

// i is the current bar 

double highest = iHighest(NULL,0,MODE_HIGH,8,i - 16/ 2);

Symbol, timeframe and type is easy to understand but the count and start is what I am wondering about.  The last parameter "i - 15 / 2" means start at 7.5 bars from the current bar, then parameter "15" means scroll towards the last bar until 15th bar from the start. Is this correct? 

For example lets say current Bar is 500 

So I ask via iHighest() above to go back 8 bars to 492 and then iHighest looks at 493,494,495,496,497,498,499,500. And then I get highest value from any of this bars? 

 Maybe this is obvious but better to know correctly then don't know.

 Thx in advance! 

Alain Verleyen
Moderator
32814
Alain Verleyen  

"current bar" is always 0.

bars are counted up from the most recent to the past.

Did you read the documentation ?

iHighest - Timeseries and Indicators Access - MQL4 Reference
iHighest - Timeseries and Indicators Access - MQL4 Reference
  • docs.mql4.com
iHighest - Timeseries and Indicators Access - MQL4 Reference
corresandberg
33
corresandberg  

Thx Alain for your answer. I forgot to mention the obvious that I have read the documentation. Still little confused.

 Most mql-documentation could have more code examples.  And Php's documentation is a good example how it could be done.

 

"i" illustrates my variable in the for-loop.

But Alain how would you describe iHighest(NULL,0,MODE_HIGH,8,0) with your words not the documentations. What is the scoope?

Alain Verleyen
Moderator
32814
Alain Verleyen  
corresandberg:

Thx Alain for your answer. I forgot to mention the obvious that I have read the documentation. Still little confused.

 Most mql-documentation could have more code examples.  And Php's documentation is a good example how it could be done.

I agree but we have to deal with what is available.

 

"i" illustrates my variable in the for-loop.

But Alain how would you describe iHighest(NULL,0,MODE_HIGH,8,0) with your words not the documentations. What is the scoope?

It searches the highest (high or low, open...depending of the mode parameter),

starting at candle 0 (the current and most recent),

looking back 8 candles, including candle 0, so 0,1,2...up to 7,

on the current symbol (NULL) and current timeframe (0).

Stuart Browne
6186
Stuart Browne  

Also keep in mind, iHighest/Lowest doesn't return the actual price value, it returns the bar number (shift) of the highest/lowest.

In your example, you used a double so I'm assuming you thought it would be the actual price. It's actually an int (bar number). You then need to retrieve the actual price using the bar number returned.

corresandberg
33
corresandberg  

Alain and Stuart, thx alot and agreed.

 

I will do some adjustments now knowing more.

 

Cheers!

CS 

To add comments, please log in or register