Any Idea why this line of code does not work?

 

Hi People,


I have taken this code from the MQL4 reference manual and I always assumed it was working. I have found out today, it does not work on a different chart than the period specified.


on the 15 minute chart is prints the value of the last days close rather than the highest high for the last 10 days..


double HighTrendVal= High[iHighest(NULL,PERIOD_D1,MODE_HIGH,10,1)];

Print ("High Trend Value is",(HighTrendVal));

 
asgard2:

Hi People,


I have taken this code from the MQL4 reference manual and I always assumed it was working. I have found out today, it does not work on a different chart than the period specified.


on the 15 minute chart is prints the value of the last days close rather than the highest high for the last 10 days..


double HighTrendVal= High[iHighest(NULL,PERIOD_D1,MODE_HIGH,10,1)];

Print ("High Trend Value is",(HighTrendVal));

As far as I can see, this chooses Highest day index, lets say 3, and puts it into the High array. So, what would be printed with High[3] on a 15 minute chart ? What you have to do is use iHigh instead with (NULL,PERIOD_D1,...iHighest.....)

 
asgard2:

Hi People,


I have taken this code from the MQL4 reference manual and I always assumed it was working. I have found out today, it does not work on a different chart than the period specified.


on the 15 minute chart is prints the value of the last days close rather than the highest high for the last 10 days..


double HighTrendVal= High[iHighest(NULL,PERIOD_D1,MODE_HIGH,10,1)];

Print ("High Trend Value is",(HighTrendVal));

Hi,

Just try that before going further and come back if it doesn't fit your expectations:

double HighTrendVal= iHigh[NULL,PERIOD_D1,iHighest(NULL,PERIOD_D1,MODE_HIGH,10,1)];

 
Jacques366:

Hi,

Just try that before going further and come back if it doesn't fit your expectations:

double HighTrendVal= iHigh[NULL,PERIOD_D1,iHighest(NULL,PERIOD_D1,MODE_HIGH,10,1)];


You good Man, it works perfectly


Thanks so much

Reason: