Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 183
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Thank you all for your help.
The question was this.
<There is a function called NewBar(sy, TF). It looks if a new bar has opened. I want to get a signal on hourly chart about the appearance of a new bar with a 5 min lag. That is, I want to get a signal at 0.05, 1.05, 2.05, ..........., 10.05, 11.05, etc. >
To clarify the question. The function should return true every hour, but with a delay of 5 min. I.e. when the formation of the bar 1.05 is over and the bar 2.05 appears, the function returns true when the latter appears. The function returns true when the bar appears at 1.10, 2.10, etc.
In the picture the yellow line shows that the next bar was true .
Following your tip I tried it this way but it does not work.
It immediately struck me that the types are not right:
And then comparing them and assigning values... int to datetime
I've just written it by hand. You can get the gist of it, and it's all right as far as it goes.
What's all the fuss about... Here every fifth minute of the hour returns TRUE and holds it for one minute:
int bt=((TimeCurrent()-5*60)/3600)*3600;
The bt value will change at 5 minutes of each hour. It is possible not to multiply by 3600 at the end, it will be the bar number from the beginning of the epoch, this is enough to define a new bar.
Missed. If multiplied by 3600 at the end, then also add back the 5*60 correction.
What's all the fuss about... Here every fifth minute of the hour returns TRUE and holds it for one minute:
I mean, really, and we're making a smart-ass of ourselves here...
Missed. If multiplied by 3600 at the end, then also add back the 5*60 correction.
It's a bit wrapped up and unreadable. I get the point though.
It immediately struck me that the types are wrong:
And then compare them and assign the values... int to datetime
What's all the fuss about... Here every fifth minute of the hour returns TRUE and holds it for one minute:
In that minute, the advisor will open up to forty orders for him.
This is the way to control...either the number of orders or just the first call to the function...
During this minute, the Expert Advisor will open up to forty orders.
And if the first one will not open? Wait for the next signal for an hour? It is ok:
There is a signal --> Check if there is an order/position set/open on this candlestick, there is no --> set/open, there is --> then there is no need for more.