You can write a function that loops over the closed orders and analyze the order comment if it contains [sl] then the order was closed by a stoploss, then you analyze the ordertype (if needed) and if it is the same as the previous sl closed order then you increment the consecutive sl counter until either the ordertype changes, or the order was closed manually, or by take profit so when there is no [sl] in the order comment.
When you exit the loop you will have the number of consecutive orders that were closed by sl.
- www.mql5.com
hello I'm tring this function, but it generates a continue counter
int RicercaSL()
{
int TotaleStorico = OrdersHistoryTotal();
if(TotaleStorico > 0)
{
for(int i = 0; i < TotaleStorico ; i++)
{
if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))
{
if(OrderMagicNumber() == MagicNumber && OrderProfit()<0) //
{
if(OrderType()==OP_BUY)
stl=stl+1;
if(OrderType()==OP_SELL)
stl=stl+1;
Print("Closed price:",OrderClosePrice()," Price StopLoss",OrderStopLoss(), " Closed in SL");
}
}
}
}
Print("Orders total", TotaleStorico, " Orders in SL:",stl);
return(stl);
}
someone cal help me?
Please edit your post and
use the code button (Alt+S) when pasting code
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
someone can help me