Partial close in MQL5...?

To add comments, please log in or register
Bhuvanesh Sahadhevan
198
Bhuvanesh Sahadhevan  
Hi, How to achieve partial close in MQL5...?
honest_knave
Moderator
2302
honest_knave  
BHUVANESH S:
Hi, How to achieve partial close in MQL5...?
Using code or manually?
Bhuvanesh Sahadhevan
198
Bhuvanesh Sahadhevan  
honest_knave:
Using code or manually?
Using code...!
honest_knave
Moderator
2302
honest_knave  
BHUVANESH S:
Using code...!

Never done it in MT5, but I surmise you just change the volume in the MqlTradeRequest structure:

MqlTradeRequest request;

... 

...
request.volume =

...

...


Perhaps someone who knows will be along soon to help. 

Alain Verleyen
36101
Alain Verleyen  
BHUVANESH S:
Using code...!
Please show your attempt.
Bhuvanesh Sahadhevan
198
Bhuvanesh Sahadhevan  
honest_knave:

Never done it in MT5, but I surmise you just change the volume in the MqlTradeRequest structure:

MqlTradeRequest request;

... 

...
request.volume =

...

...


Perhaps someone who knows will be along soon to help. 

Thankyou... It helps...!
Bhuvanesh Sahadhevan
198
Bhuvanesh Sahadhevan  
Alain Verleyen:
Please show your attempt.

Try this one...! 

void ClosePartial(string symbol,int type,double lots,int ticket)
  {
      MqlTradeRequest request={0};
      MqlTradeResult  result={0};
      request.action   =TRADE_ACTION_DEAL;        
      request.position =ticket;          
      request.symbol   =symbol;          
      request.volume   =lots;                  
      request.deviation=5;
      double price=0;
      if(type==0)
      {
         request.type=ORDER_TYPE_SELL;
         request.price=SymbolInfoDouble(symbol,SYMBOL_BID);
      }
      else if(type==1)
      {                  
         request.type=ORDER_TYPE_BUY;
         request.price=SymbolInfoDouble(symbol,SYMBOL_ASK);
      }
      //request.magic    =111222;             // MagicNumber of the position      
      if(!OrderSend(request,result))
         Alert("OrderSend error "+GetLastError());
      else
         Alert("Success");
  }

 

Alain Verleyen
36101
Alain Verleyen  
BHUVANESH S:

Try this one...! 

void ClosePartial(string symbol,int type,double lots,int ticket)
  {
      MqlTradeRequest request={0};
      MqlTradeResult  result={0};
      request.action   =TRADE_ACTION_DEAL;        
      request.position =ticket;          
      request.symbol   =symbol;          
      request.volume   =lots;                  
      request.deviation=5;
      double price=0;
      if(type==0)
      {
         request.type=ORDER_TYPE_SELL;
         request.price=SymbolInfoDouble(symbol,SYMBOL_BID);
      }
      else if(type==1)
      {                  
         request.type=ORDER_TYPE_BUY;
         request.price=SymbolInfoDouble(symbol,SYMBOL_ASK);
      }
      //request.magic    =111222;             // MagicNumber of the position      
      if(!OrderSend(request,result))
         Alert("OrderSend error "+GetLastError());
      else
         Alert("Success");
  }

 

So ? What is the question/problem ?
To add comments, please log in or register