I cannot find best way to close all buy/sell trade by group (string comment or magic).
I use this code to open trades...someone could suggest the solution please?
Many thanks!
//+==================================================================================================+//| FILTER BUY//+==================================================================================================+if (CheckForBuy())
{
if(PositionSelect(_Symbol))
{
switch((int)PositionGetInteger(POSITION_TYPE))
{
casePOSITION_TYPE_BUY:
if(PositionGetDouble(POSITION_PROFIT)<=0)
return;
break;
casePOSITION_TYPE_SELL:
Trade.PositionClose(_Symbol);
break;
}
}
if(!Trade.Buy(Lot,_Symbol,ask,0,0,"Group_1"))
Print("Error of open BUY ORDER Group_1"+Trade.ResultComment());
}
//+==================================================================================================+//| FILTER SELL//+==================================================================================================+ if (CheckForSell())//(CheckForSell())
{
if(PositionSelect(_Symbol))
{
switch((int)PositionGetInteger(POSITION_TYPE))
{
casePOSITION_TYPE_SELL:
if(PositionGetDouble(POSITION_PROFIT)<=0)
return;
break;
casePOSITION_TYPE_BUY:
Trade.PositionClose(_Symbol);
break;
}
}
if(!Trade.Sell(Lot,_Symbol,bid,0,0,"Group_1"))
Print("Error of open SELL ORDER Group_1 "+Trade.ResultComment());
}
return;
//+==================================================================================================+//| CLOSE ALL BUY/SELL GROUP 1//+==================================================================================================+if (closebuy_1)
{
// CODE TO CLOSE ALL BUY GROUP 1
}
if (closesell_1)
{
// CODE TO CLOSE ALL SELL GROUP 1
}
} // END
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hello,
I cannot find best way to close all buy/sell trade by group (string comment or magic).
I use this code to open trades...someone could suggest the solution please?
Many thanks!