How to send a order at MQL5

 

hi

at MQL4 the send order was very simple

         orderticket=OrderSend(_Symbol,OP_SELL,orderlot,Bid,10,stoploss,takeprofit,_Symbol,magicNM);           

i wirte this and i get the order ticket and i set the magic number


now i try to move for MQL5 and i dont understand how i send a order and get the ticket number and set the magin number 


i tried to do this but nothing happend

         MqlTradeRequest request={0};
         MqlTradeResult  result={0};
      
//--- parameters of request

         request.action   =TRADE_ACTION_DEAL;                     
         request.symbol   =_symbol;                                  
         request.volume   =0.1;
         request.sl       =stoplosslong;
         request.tp       =takeprofitlong;                  
         request.type     =ORDER_TYPE_BUY;                        
         request.price    =Ask(SYM);
         request.deviation=10;                                     
         request.magic    =magicNMlong;
         result.order     =orderlongticket; 
 
How to start with MQL5
How to start with MQL5
  • 2020.12.19
  • www.mql5.com
This thread discusses MQL5 code examples. There will be examples of how to get data from indicators, how to program advisors...
 

whats worng at my code ? 

i have 2 strategy and i want differenf magic num and ticket num for each 


void OnTick()
  {
//---
   
//------SEND OREDER BY RSI -------------
   
   int rsival=iRSI(_Symbol,_Period,14,PRICE_HIGH);
   double rsiarry[];
   ArraySetAsSeries(rsiarry,true);
   CopyBuffer(rsival,0,0,4,rsiarry)
   if(rsiarry[0]>70)
   {
         MqlTradeRequest request={0};
         MqlTradeResult  result={0};
      //--- parameters of request
         request.action   =TRADE_ACTION_DEAL;                     
         request.symbol   =_Symbol;                                  
         request.volume   =0.1;
         request.sl       =SL;
         request.tp       =TP;                  
         request.type     =ORDER_TYPE_BUY;                        
         request.price    =Ask(SYM); 
         request.deviation=10;                                    
         request.magic    =2222;
         result.order     =orderRSIticket;
   }

//------SEND OREDER BY CCI -------------
   
   int CCIval=iCCI(_Symbol,_Period,14,PRICE_HIGH);
   double CCIarry[];
   ArraySetAsSeries(CCIarry,true);
   CopyBuffer(CCIval,0,0,4,CCIarry)
   if(CCIarry[0]>70)
   {
       MqlTradeRequest request={0};
         MqlTradeResult  result={0};
      //--- parameters of request
         request.action   =TRADE_ACTION_DEAL;                     
         request.symbol   =_Symbol;                                  
         request.volume   =0.1;
         request.sl       =SL;
         request.tp       =TP;                  
         request.type     =ORDER_TYPE_BUY;                        
         request.price    =Ask(SYM); 
         request.deviation=10;                                    
         request.magic    =4444;
         result.order     =orderCCIticket;
   }  
   
   
  }
//+------------------------------------------------------------------+
 
Netanel Tanami:

hi

at MQL4 the send order was very simple

i wirte this and i get the order ticket and i set the magic number


now i try to move for MQL5 and i dont understand how i send a order and get the ticket number and set the magin number 


i tried to do this but nothing happend

You forget main part. 

OrderSend(request,result);
Reason: