A new bar requires a new tick, so just use OnTick() and check for a new bar
A new bar requires a new tick, so just use OnTick() and check for a new bar
Aren't there multiple ticks on each bar? Like when the price changes at all, doesn't that generate a new tick? Not very familiar with MQL, sorry if this is obvious to everybody else.
Yes, usually. However, each bar can only have 1 first tick
The open time of a bar is stored in a static/globalscope variable.
At each tick the open time of the current bar is compared to the value. If it is not the same, then it must be the first tick of a new bar (received by the Expert)
The variable is reassigned the value of the current bar's open time in order to check for the next new bar.
Yes, usually. However, each bar can only have 1 first tick
The open time of a bar is stored in a static/globalscope variable.
At each tick the open time of the current bar is compared to the value. If it is not the same, then it must be the first tick of a new bar (received by the Expert)
The variable is reassigned the value of the current bar's open time in order to check for the next new bar.
JD4: Aren't there multiple ticks on each bar?
|
|
Yes, usually. However, each bar can only have 1 first tick
The open time of a bar is stored in a static/globalscope variable.
At each tick the open time of the current bar is compared to the value. If it is not the same, then it must be the first tick of a new bar (received by the Expert)
The variable is reassigned the value of the current bar's open time in order to check for the next new bar.
Just thought of something again on this. When using OnTick(), which will work because of the bar needing that first tick anyway, how is it to differentiate between that (infamous) first tick, and any following ticks related to that same bar?
Strange that you quote my post which has already answered your question
Yes, usually. However, each bar can only have 1 first tick
The open time of a bar is stored in a static/globalscope variable.
At each tick the open time of the current bar is compared to the value. If it is not the same, then it must be the first tick of a new bar (received by the Expert)
The variable is reassigned the value of the current bar's open time in order to check for the next new bar.
If it is not the same, then it must be the first tick of a new bar (received by the Expert)
It follows that if it IS the same, it must be a subsequent tick
Strange that you quote my post which has already answered your question
If it is not the same, then it must be the first tick of a new bar (received by the Expert)
It follows that if it IS the same, it must be a subsequent tick
- 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 folks,
I'm building an EA that must place a trade at the beginning of a new bar. Regarding to less time delay from the opening time of the new bar, which one is more recommended to use: OnTick() or OnTimer()?