Hi,
I'm having a problem with using a function to return the lowest value of the current 5 min bar using an EA attached to a H1 chart.
The problem seems to be with the timeframe enumeration. I tried finding an answer on the forum but couldn't.
Here's my code:
Print("val= ",Low[iLowest(NULL,5,MODE_LOW,1,0)]); OR
Print("val= ",Low[iLowest(NULL,PERIOD_M5,MODE_LOW,1,0)]);
When I attach the EA to a H1 chart I just get the low of the current Hourly bar printed to the screen, but I want the low of the current 5 minute bar, hence why I use "PERIOD_M5" as my second input parameter as documented by timeframe enumeration.
Is this not what I should expect??
No. What does Low return ? " . . . the lowest prices of each bar of the current chart. " did you see where it said current chart ? why should it return the Low for the M5 bar when your current chart is H1 ?
Read the documentation for iLow()
When posting code please use the SRC button: How to use the SRC button.
on the H1 chart Low[x] is the H1's low, not the M5. Don't mix apples and oranges.
If you want the current M5 bar's low, ask for it
double lowM5 = iLow(NULL,PERIOD_M5,0); Print("val= ",lowM5);If you want to find which M5 bar is the current low of the H1 bar
datetime currentHour = Time[0]; // H1 chart assumed int iCurrentHourM5 = iBarShift(NULL, PERIOD_M5, currentHour); // M5 index int iCurrentHourM5Low = iLowest(MODE_LOW, iCurrentHourM5 + 1, 0); // Lowest M5 iCHM5..0 inclusive double CurrentHourM5Low = iLow(NULL, PERIOD_M5, iCurrentHourM5Low); Print( "val= CurrentHourM5Low );
No. What does Low return ? " . . . the lowest prices of each bar of the current chart. " did you see where it said current chart ? why should it return the Low for the M5 bar when your current chart is H1 ?
Read the documentation for iLow()
When posting code please use the SRC button: How to use the SRC button.
Thanks a lot Raptor. I used iLow, and this gave me what i want!! I was about to give up on this too!
best,
Ciaran.
Hi WHRoeder,
Thanks to you too. I'll have a play around with your suggested code as well for locating the desired bar, which might come in handy in the future.
best,
Ciaran.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I'm having a problem with using a function to return the lowest value of the current 5 min bar using an EA attached to a H1 chart.
The problem seems to be with the timeframe enumeration. I tried finding an answer on the forum but couldn't.
Here's my code:
Print("val= ",Low[iLowest(NULL,5,MODE_LOW,1,0)]); OR
Print("val= ",Low[iLowest(NULL,PERIOD_M5,MODE_LOW,1,0)]);
When I attach the EA to a H1 chart I just get the low of the current Hourly bar printed to the screen, but I want the low of the current 5 minute bar, hence why I use "PERIOD_M5" as my second input parameter as documented by timeframe enumeration.
Is this not what I should expect??
any help appreciated!
Ciaran.