When I I reach if(currentProfit >= (profitTarget +tradeCosts))
First I want to remove all losses trades -its working with this code:
double LossToClose = -0.5;
for (int i = OrdersTotal() - 1; i >= 0; i--) //loop all the orders
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES); //select one after another//----if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) // check if it's the one u looking for
{
if (OrderProfit() <= LossToClose) // check if it's losing more or equal to what u decided
{
OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), Slippage, Red); // close it
}
}
After that I want Modify TP for 10 pips for each positive trades and use Trailing Stop for each positive trades for 30 points.
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.
hi,
When I I reach if(currentProfit >= (profitTarget +tradeCosts))
First I want to remove all losses trades -its working with this code:
After that I want Modify TP for 10 pips for each positive trades and use Trailing Stop for each positive trades for 30 points.
This is my function for calling when reach profit:
In strategy tester not returns correct results for Trailing and TP.
How can I resolved this?