if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_HISTORY) == true) { //if (!OrderProfit() == 0) ticket = 0; Print("ticket set to zero"); }
- Mode is irrelevant when you select by ticket.
- What do when you select it? You zero it! What do you do when it is zero? You open another.
-
EAs must be coded to recover. If the power
fails, OS crashes, terminal or chart is accidentally closed, on the next tick,
any static/global ticket variables will have been lost. You will have an open
order but don't know it, so the EA will never try to close it, trail SL, etc. How are you going to recover? Use a OrderSelect loop to recover, or persistent storage
(GV+flush or
files) of ticket numbers
required.
whroeder1:
The select by history there is intended to check if the last order has been closed by take profit, trail stop, etc. Otherwise I don't know it's closed. The intent is to only have one open order at a time per pair. I'm sure whatever I'm doing wrong is something silly, i just cant find it.
- Mode is irrelevant when you select by ticket.
- What do when you select it? You zero it! What do you do when it is zero? You open another.
LancerSykera: The select by history there is intended to check if the last order has been closed by take profit, trail stop, etc. Otherwise I don't know it's closed.
Selecting by ticket doesn't mean any of those things. The ticket could be pending, open, closed, or deleted. You must test to see if it is closed.
LancerSykera: My understanding was that its only in the history if its been closed,
That is true (closed, deleted, balance/adjustment entries,) but you are not selecting a position out of history.
You are selecting a ticket. What part of "Mode is irrelevant when you select by ticket" was unclear?
The pool parameter is ignored if the order is selected by the ticket number. The ticket number is a unique order identifier.
OrderSelect - Trade Functions - MQL4 Reference
OrderSelect - Trade Functions - MQL4 Reference
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
.