-
Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
Messages Editor -
if(OrderType()==OP_BUY){ ⋮ status= OrderClose(OrderTicket(),Partialslots,Bid,UseSlippage);
You don't have to test the type and use Bid/Ask. You can use OrderClosePrice() instead of Bid/Ask and be direction independent — no need to check order type for close price. -
You can't just use OrderLots()/2 because that is not a multiple of LotStep, and you can't close or have remaining less than MinLot.
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
void Takepartials()
{
bool status;
int cnt;
RefreshRates();
if(OrdersTotal()>0)
{
for(cnt=OrdersTotal()-1; cnt>=0; cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if(OrderMagicNumber()==Magicnumber)
{
if(OrderType()==OP_BUY)
{
if(Bid-OrderOpenPrice()>=Takepartialspips1*Usepoint)
{
if(OrderLots()==Lotsize)
{
status= OrderClose(OrderTicket(),Partialslots,Bid,UseSlippage);
if(status==true)
{
Print("Partials Taken");
}
else
{
int err=GetLastError();
Print("Error is : ",err);
}
return;
}
}
}
if(OrderType()==OP_SELL)
{
if(OrderOpenPrice()-Ask>=Takepartialspips1*Usepoint)
{
if(OrderLots()==Lotsize)
{
status= OrderClose(OrderTicket(),Partialslots,Ask,UseSlippage);
if(status==true)
{
Print("Partials Taken");
}
else
{
int err=GetLastError();
Print("Error is : ",err);
}
return;
}
}
}
}
}
}
}