Hi, How to achieve partial close in MQL5...?
BHUVANESH S:
Hi, How to achieve partial close in MQL5...?
Using code or manually?
Hi, How to achieve partial close in MQL5...?
honest_knave:
Using code or manually?
Using code...!
Using code or manually?
BHUVANESH S:
Using code...!
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.
BHUVANESH S:
Using code...!
Please show your attempt.
Using code...!
honest_knave:
Thankyou... It helps...!
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:
Please show your attempt.
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");
}
{
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");
}
BHUVANESH S:
So ? What is the question/problem ?
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");
}
{
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");
}
Look at your pc: ...\MQL5\Include\Trade\Trade.mqh
search for partial close to see how it works.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register