static datetime currentbar = 0;
It is good but there can be an issue when you switch the timeframe on the chart manually.
If you want ultimate control over that you can use a global variable instead. (https://www.mql5.com/en/docs/globals/globalvariableset)
- www.mql5.com
It is good but there can be an issue when you switch the timeframe on the chart manually.
If you want ultimate control over that you can use a global variable instead. (https://www.mql5.com/en/docs/globals/globalvariableset)
It is good but there can be an issue when you switch the timeframe on the chart manually.
If you want ultimate control over that you can use a global variable instead. (https://www.mql5.com/en/docs/globals/globalvariableset)
When you switch timeframe the bar time changes so it will trigger your code.
If you dont want that you'd have to use a fixed candle like PERIOD_H1 in stead of PERIOD_CURRENT, or use a global var.
Also if you set the static datetime currentbar = 0; to zero it will be set to zero each time the program is reinitialized which can be undesirable as well.- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I'm trying to make sure I have the right coding to check and execute a possible close of position After a new bar from opening a position.
Can anyone confirm if this code is good. It seems as if each time it checks for close, it would set the "currentbar" again to datetime?