My bad... i realise i should SELECT_BY_TICKET instead of SELECT_BY_POS
sigh.. took me so much time to see this.. ha!
I see you're doing this:
OrderSelect(bTicket[1])
It seems to me you're hard coding the array index/position. Shouldn't you do more or less this instead?
OrderSelect(bTicket[bCount]) OrderSelect(bTicket[(bCount + 1)])
Yes I am hardcoding this at the moment cos I only have 2 buy tickets and 2 sell tickets max..
It seems that the OrderModify can pick up the correct ticket but it is the s/l and t/p set to zero that I am concerned about.
orderS = OrderSelect( orderM = OrderModify(
-
Check your return codes, and report your errors (including market prices and your variables). Don't look at GLE/LE unless you have an error. Don't just silence the compiler (MT5 / MT4+strict), it is trying to help you.
return value of OrderSend should be checked - Expert Advisors and Automated Trading - MQL5 programming forum -
You select by ticket. Where do you check if the order has already closed?
-
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 / position 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 / Position select loop on the first tick, or persistent storage (GV+flush or files) of ticket numbers required.
- 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, I have the following code..
I have problems with the second and third OrderModify command..
in the 2nd OrderModify, I do have an existing s/l level in bTicket[1], however when this this command was executed, the s/l level was set to zero.
in the 3rd OrderModify, I do have an existing t/p level in sTicket[1], however when this command was executed, the t/p level was set to zero.
May I know why and how can I keep the existing s/l and t/p levels?