Download MetaTrader 5

Help Please on iHighest

To add comments, please log in or register
Deepak
20
Deepak  

i am new to MQL scripting and looking for some help. 

 Can someone please help me here to understand this piece of code? Is MaxH/MinL looking into the future by period bar to find the highest High and Lowest Low in "period"? 

 The i as Start parameter in iHighest means High is calculated from the future data in this for loop?

   for(int i=0; i<Bars; i++)

    {

      MaxH = High[iHighest(NULL,0,MODE_HIGH,period,i)];

      MinL = Low[iLowest(NULL,0,MODE_LOW,period,i)]; 

 

Thanks for your help!

 

DK 

Keith Watford
Moderator
10617
Keith Watford  
The i as Start parameter in iHighest means High is calculated from the future data in this for loop?
The highest is calculated for index i and previous bars, not future bars
Vasyl Nosal
19285
Vasyl Nosal  

looking into the future

yes(in history). Most repainting indicators writes like this. 

Deepak
20
Deepak  
eevviill:

looking into the future

yes(in history). Most repainting indicators writes like this. 

Then how would it calculate the value for the most recent bar because the future bars are not available yet
Deepak
20
Deepak  
eevviill's response seems contradicting GumRai. Strange!!
Vasyl Nosal
19285
Vasyl Nosal  
dkpmba:
Then how would it calculate the value for the most recent bar because the future bars are not available yet
I mean history bars.
Deepak
20
Deepak  
eevviill:
I mean history bars.

So is it correct to say that MaxH above is the highest high value of previous "Periods" from current bar (i)

 

This is confusing me when Start parameter in iHighest has i which increases with every increase in for loop

 Say period = 8 and current i = 9 below

Would High[iHighest(NULL,0,MODE_HIGH,period,i)]; calculates highest high value from bar 2-9?

i =>> 1 2 3 4 5 6 7 8 9

^ - current i at 9  

Keith Watford
Moderator
10617
Keith Watford  
dkpmba:
eevviill's response seems contradicting GumRai. Strange!!

That is because he seems to be on a campaign to contradict me as much as possible. I have no idea why.

I assure you that iHighest cannot work on future bars. It can only check the start index bar (last parameter) and bars previous to that

Keith Watford
Moderator
10617
Keith Watford  
dkpmba:

So is it correct to say that MaxH above is the highest high value of previous "Periods" from current bar (i)

 

This is confusing me when Start parameter in iHighest has i which increases with every increase in for loop

 Say period = 8 and current i = 9 below

Would High[iHighest(NULL,0,MODE_HIGH,period,i)]; calculates highest high value from bar 2-9?

i =>> 1 2 3 4 5 6 7 8 9

^ - current i at 9  

No, the start index bar is 9 and it will check 8 bars

so

9 10 11 12 13 14 15 16

Vasyl Nosal
19285
Vasyl Nosal  
dkpmba:

So is it correct to say that MaxH above is the highest high value of previous "Periods" from current bar (i)

 

This is confusing me when Start parameter in iHighest has i which increases with every increase in for loop

 Say period = 8 and current i = 9 below

Would High[iHighest(NULL,0,MODE_HIGH,period,i)]; calculates highest high value from bar 2-9?

i =>> 1 2 3 4 5 6 7 8 9

^ - current i at 9  

from 9 to 16 

Deepak
20
Deepak  

Damn man! so it works backward and I was thinking forward. So when we say

 for(int i=0; i<Bars; i++)

 

i = 0 is the most recent bar and i = 1 is the bar previous to the most recent one. And I was thinking that i = 0 is the first (historical) bar in the current chart. Thanks guys you rock! 

12
To add comments, please log in or register