EA Failed in Live Trading although Worked in Backtesting

 

Hi,

I have an EA that worked in back testing. However, a part of it failed in live trading.

When a level is breached, it supposed to close a short and open a long. Although, it's doing so in the back tester, it failed to open the long in live trading today. I added the print function today, to see where it stops if it happens again. But since it worked perfectly in the back tester, I am very surprised. Also, the same EA worked alright on AUDUSD although it broke in USDJPY.

Help is much appreciated.

Thanks,

while(IsTradeContextBusy()) Sleep(10);
 Closed=OrderClose(SellTicket,LotSize,Ask,UseSlippage,Green);
 Print("Close Short " + Symbol() + " " + LotSize + " " + Ask);
 while(IsTradeContextBusy()) Sleep(10);
 BuyTicket=OrderSend(Symbol(),OP_BUY,LotSize,Ask,UseSlippage,0,0,"Stop Short & Open Long",MagicNumber,0,Green);
 Print("Open Long " + Symbol() + " " + LotSize + " " + Ask);
 Position="Long";
 TradeCount++; 
 

How do you know errorcodes returned from broker ??

 

nope, no error returns

it closes the trade but doesn't flip

really weird given that the logic seems to work in backtesting

 
nonhuman:

nope, no error returns

it closes the trade but doesn't flip

really weird given that the logic seems to work in backtesting

You need to check the return values from your trading functions and report any errors and associated variables . . . read this: What are Function return values ? How do I use them ?
 
  1. Use SRC
  2. No RefreshRates() after sleep
  3. What are Function return values ? How do I use them ? - MQL4 forum
  4. Adjusting slippage for 4/5 digit brokers?
Reason: