iHighest/iLowest question

To add comments, please log in or register
corresandberg
35
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
37187
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
35
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
37187
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
7617
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
35
corresandberg  

Alain and Stuart, thx alot and agreed.

 

I will do some adjustments now knowing more.

 

Cheers!

CS 

Daniel Cardoso
259
Daniel Cardoso  

Hello coders,


I'm still in doubt on this subject.


I know we get the bar's number with the iHighest or iLowest for lower price, but I'm still confused about getting the actual value. I mean, I want to use it to set SL for example. I just can't find a way.

If someone out there is hearing, please give us some help!

TKs in advance!

peterpies
18
peterpies  
Daniel Cardoso:

Hello coders,


I'm still in doubt on this subject.


I know we get the bar's number with the iHighest or iLowest for lower price, but I'm still confused about getting the actual value. I mean, I want to use it to set SL for example. I just can't find a way.

If someone out there is hearing, please give us some help!

TKs in advance!



int highbar=iHighest(NULL,0,MODE_HIGH,8,0); // find the highest bar of the current symbol and timeframe 'change the first 0 to any ENUM_TIMEFRAMES'

double highprice=iHigh(NULL,0,highbar); // find the price of highest bar found

datetime hightime=iTime(Symbol(),0,highbar); // find the time of highest bar found

// now draw a line with the above
To add comments, please log in or register