MQL5 - Placing two orders (instead of one)

 

Hello,


I have this code but it is sending two orders of 100 (lots) instead of one. Any idea on what might be happening is appreciated.

Please see below the code:


               double Ask = NormalizeDouble(SymbolInfoDouble(SymbolArray[posicao_array],SYMBOL_ASK)+(2*_Point),_Digits);
               double stopLossPrice = NormalizeDouble((Ask/Multiplicador_Aditivo_TakeLoss),_Digits);
               double takeProfitPrice = NormalizeDouble(Ask +((Ask-(Ask 
               *Gap_Tradable[contador_de_trade]))*Gap_Percent_Closure),_Digits);
               double lotSize = 100; //OptimalLotSize(riskPerTrade,Ask,stopLossPrice);
               ZeroMemory(request);
               ZeroMemory (result);
               ResetLastError();
               MqlTradeRequest request={0};
               MqlTradeResult  result={0};
               request.action=TRADE_ACTION_PENDING;
               request.magic= EXPERT_MAGIC; 
               request.order = OpenTradeOrderTicket[posicao_array];
               request.symbol = SymbolArray[posicao_array]; 
               request.volume = lotSize;         
               request.type=ORDER_TYPE_BUY_STOP;
               request.price = Ask;
               request.stoplimit = Ask-3*_Point;
               request.tp = takeProfitPrice;
               request.sl = stopLossPrice;
               request.deviation= TradeDeviation;
               request.type_filling=ORDER_FILLING_RETURN;
               request.type_time = ORDER_TIME_DAY;
               OrderSend(request,result); 
               request.expiration = TimeCurrent()+180; // 3 minutos (3*60=180)
               request.position = OpenTradeOrderTicket[posicao_array];
               request.position_by = (OpenTradeOrderTicket[posicao_array]/10);           


Please see a typical outcome journal received after running the code:

 
52170755 :


You have an error in the code above: you enter the code block that generates a trade order twice. Show the complete code.

 

Thnaks for the return  Vladimir,


I found the error and now it is working good : took out this line of code 

   OrderSend(request,result); 

I came form MT4 and now I understand(?) that on MT5 there is two alternative methods to place an order and i was using both.