verification that trade was opend doesn't work

 

Hi,

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(UseVisibleSLandTP)
     {
      tp=Bid-takeprofitpointscalculated*Point;sl=Bid+(zoneheightpointscalculated+takeprofitpointscalculated)*Point;
      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(sellticket>0)
     {
      if(opentradehandling==1) Print("Opend a sell Trade, sellticket nrº ",sellticket);
     }
   else
     {
      if(opentradehandling) Print("Order Send failed, error # ",GetLastError());
      Sleep(wait);
      if(!DontUseForceOpenWhenTesting)
         OpenASellTrade();
     }

  };

 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 

 

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.

Reason: