- How to use magic number in order to manage several EA
- Need Help with programming my EA
- Help in coding.
1. check opened time inside orderstotal
2. check current candle time
3. ibarshft <= 1 . don't trade
My solution for determining first and only the first tick of a new candle ...
datetime new_candle = 0; //in global space or in OnInit() if (new_candle != iTime(Symbol(), Period(), 0)) { ... ... new_candle = iTime(Symbol(), Period(), 0); }
Detecting the start of a new bar or candle
Fernando Carreiro, 2022.04.24 00:46
Detecting the start of a new bar or candle, in the OnTick() event handler of an expert advisor.Please don't post randomly in any section. MT4/mql4 has it's own section on the forum.I have moved your topic to the correct section.
Please don't post randomly in any section. MT4/mql4 has it's own section on the forum.I have moved your topic to the correct section.
This worked so perfectly!! Thanks so very much for the code.
void OnTick() { // Check for New Bar (Compatible with both MQL4 and MQL5) static datetime dtBarCurrent=WRONG_VALUE; datetime dtBarPrevious=dtBarCurrent; dtBarCurrent=(datetime) SeriesInfoInteger(_Symbol,_Period,SERIES_LASTBAR_DATE); bool NewBarFlag=(dtBarCurrent!=dtBarPrevious); if(NewBarFlag) { }
That is not the same code that I directed you to from the CodeBase. It seems to be from an older version.
Also, I have edited your post, but in the future please use the CODE button (Alt-S) when inserting code.
That is not the same code that I directed you to from the CodeBase. It seems to be from an older version.
Also, I have edited your post, but in the future please use the CODE button (Alt-S) when inserting code.
Yes, not exactly the same code but very similar to the one you directed me to. Both codes working perfectly!
Thanks so much! I did not know about the code button. I'm learning so many new things here
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use