OrderSelect(BuyTicket,SELECT_BY_TICKET); if(OrderCloseTime() == 0 && BuyTicket > 0)
Always test return codes. If the orderSelect fails such as when the order hit a stop, then OrderTicket() OrderCloseTime() etc are meaning less. Otherwise OrderCloseTime() will ALWAYS be zero.SellTicket = OrderSend(Symbol(),OP_SELL,LotSize,OpenPrice
Always test return codes so you can find out WHY.SellTicket = OrderSend(Symbol(),OP_SELL,LotSize,OpenPrice... if (SellTicket < 0) Alert("OrderSend(sell) failed: ", GetLastError());
-
Always test return codes. If the orderSelect fails such as when the order hit a stop, then OrderTicket() OrderCloseTime() etc are meaning less. Otherwise OrderCloseTime() will ALWAYS be zero.
-
Always test return codes so you can find out WHY.
Thank you for that advice. I have been using Andrew Young's book to learn programming so my view of the MQL4 world is very restricted!
In a related thread I think I may have seen your comments that with ECN brokers you can not set TP and SL at the order send, but need to do it through an order modification.This seems to replicate the manual order method through the terminal.
I did notice and realized belatedly that when in "manual confirmation" mode, the EA did not place the SL and TP's - so perhaps that is the problem? I will make these changes also and wait for my broker to re-open Monday midnight (GMT + 3).
cheers
Don't need to wait, run it in the tester/visual mode
That won't work!
The problem is that it works fine in the tester (when back testing) but when I forward test using the demo account, it does not open the trades.
That won't work!
The problem is that it works fine in the tester (when back testing) but when I forward test using the demo account, it does not open the trades.
Just in follow-up.
As I later suspected, my broker really works as an ECN and therefore, all that was needed was to send the order first and than modify it by adding SL and TP.
The bloody annoying thing was that the broker seemed unaware that this was a requirement!!!!
thanks for all the input

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Good evening expert traders and programmers:
This seems a common enough problem, yet I've not managed to find a solution in any of the threads.
After writing and back testing a few EA's I have been trying to demo test and can not get the EA to trade. I have checked and rechecked the enabling dialogue boxes and even played with the Vista permissions, before uploading to an XP VPS. Print statements in log file confirm that trading signals are being received and when I tick the "ask manual confirmation" it opens the terminal's trading dialogue box and the resulting manually confirmed trade has a magic number corresponding to the EA.
Believing that the problem must be in my code I downloaded a very simple EA by Andrew Young and changed the trade conditions to be once every bar, just to test the automatic trading - same result as before.
I increased the allowable slippage to 50 (from 5) - still no change.
With my limited knowledge, I have exhausted the potential solutions - if anyone has further ideas I would be very appreciative.
thanks in advance
I have posted the code