Hello,
I am trying to write a code so that i can work off the highs and lows of a specific bar per day.... The specific bar will be defined by time....
E.G. Just say i want to use the range of the 4 hour bar that starts at 4:00 and finishes at 8:00 every day.... obviously i wont be able to trade off it until after 8 as this is when the bar is closed...but i can work all that out myself later.
I think i have the code pretty much right below.... the purpose of this function is just to return either the high or low of the specified bar.....i just need help with how to specify the time.
Calculate it as a datetime type variable and make good use of % to give you the remainder of a division. All you need to do is calculate midnight and add on 4 * PERIOD_H1 * 60 (4hrs as seconds).
Midnight: Look here
Worked like a charm!
Thanks Raptor!
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I am trying to write a code so that i can work off the highs and lows of a specific bar per day.... The specific bar will be defined by time....
E.G. Just say i want to use the range of the 4 hour bar that starts at 4:00 and finishes at 8:00 every day.... obviously i wont be able to trade off it until after 8 as this is when the bar is closed...but i can work all that out myself later.
I think i have the code pretty much right below.... the purpose of this function is just to return either the high or low of the specified bar.....i just need help with how to specify the time.
I wish i could just write "some_time= 12:00" but in reading mt4 help files it seems i need to find a date aswell...... but it always need to be the current days date.....
Can anyone help please? Thanks in advance.... I cant find anything on the forum that makes sense to me.