if (OrderType() == OP_BUY && OrderCloseTime()!=0)should be
if (OrderType() == OP_BUY && OrderCloseTime()==0)
Please edit your post and use the code button (Alt+S) when pasting code.
EDIT your original post, please do not just post the code correctly in a new post.
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.
-
if (OrderType() == OP_BUY && OrderCloseTime()==0)
You are reading the open orders pool. There will never be an entry with OCT non-zero. Unnecessary test.
-
You can use OrderClosePrice() instead of Bid/Ask and be direction independent — no need to check order type to get the close price.
if (OrderType() == OP_BUY && OrderCloseTime()!=0)
should be
if (OrderType() == OP_BUY && OrderCloseTime()==0)
Please edit your post and use the code button (Alt+S) when pasting code.
EDIT your original post, please do not just post the code correctly in a new post.
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.
OrderCloseTime() == 0
you test that for an opened trade? of course is 0... it is still open...
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi Gents, I ran out of ideas to debug this as I couldn't close the last order (always closed most of them except the last active trade). This isn't happening often. It only happens very late at night. When I was monitoring it, it wouldn't happen. so strange. Would you please help me double check? I feel I missed some knowledge.
The error code is: