Download MetaTrader 5

verification that trade was opend doesn't work

To add comments, please log in or register
Why to sell products in MetaTrader AppStore? Find that out from the article!
rme0108 2016.06.03 15:58 


sorry to post this but I can't seem to figure out what is wrong with my code.

I noticed that sometimes my ordersend isn't executed due to a timeout or "no connection" (amazon windows server) therefore i integrated this force open order function but it doesn't work.

Please have a look, I appreciate your help...

void OpenASellTrade()
   double tp,sl;
      if(errorHandling==1) Print("tp=",tp," sl=",sl);
   comment=coment+" Nº "+IntegerToString(totaltrades)+","+IntegerToString(numberofactivetrades);
   int sellticket=OrderSend(Symbol(),OP_SELL,TradeNumber[numberofactivetrades][RoundedLotsize],Bid,3,sl,tp,comment,MagicNumber,0,Red);
      if(opentradehandling==1) Print("Opend a sell Trade, sellticket nrº ",sellticket);
      if(opentradehandling) Print("Order Send failed, error # ",GetLastError());


 I've googled for cerification of open orders and edited what I found to suit my needs but it seems I'm missing out on something important.

When I set DontUseForceOpenWhenTesting to false the EA crashes MT4, oops :) 

Tks again for your help 

whroeder1 2016.06.03 20:18  

When you get no result, you don't know if an order was opened or not. Your code may try to open open another and another...

I simply log the error and return from OnTick. On the next tick, you have a connection, verify you don't already have an open order, and that conditions are still value and retry.

To add comments, please log in or register