Try it
//-------------------------------------------------------------------+
// Close at profit Function |
//-------------------------------------------------------------------+
void CloseatProfit( string Symb )
{
total = OrdersTotal();
int ticket = 0;
if(OrdersTotal() <= 10) return;
for( int cnt = total-1; cnt >= 9; cnt-- )
{
if ( OrderSelect( cnt, SELECT_BY_POS, MODE_TRADES ))
{
if ( OrderSymbol() == Symb && OrderProfit() > 1 )
{
if ( OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), 10, clrNONE ) ) Print("Close order success");
else Print( "Close order failed");
}
}
}
}
tuoitrecuoi:
//-------------------------------------------------------------------+
// Close at profit Function |
//-------------------------------------------------------------------+
void CloseatProfit( string Symb )
{
total = OrdersTotal();
int ticket = 0;
while ( OrdersTotal() > 10 )
{
for( int cnt = total-1; cnt >= 9; cnt-- )
{
if ( OrderSelect( cnt, SELECT_BY_POS, MODE_TRADES ))
{
if ( OrderSymbol() == Symb && OrderProfit() > 1 )
{
if ( OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), 10, clrNONE ) ) Print("Close order success");
else Print( "Close order failed");
}
}
}
}
}
Try it
//-------------------------------------------------------------------+
// Close at profit Function |
//-------------------------------------------------------------------+
void CloseatProfit( string Symb )
{
total = OrdersTotal();
int ticket = 0;
while ( OrdersTotal() > 10 )
{
for( int cnt = total-1; cnt >= 9; cnt-- )
{
if ( OrderSelect( cnt, SELECT_BY_POS, MODE_TRADES ))
{
if ( OrderSymbol() == Symb && OrderProfit() > 1 )
{
if ( OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), 10, clrNONE ) ) Print("Close order success");
else Print( "Close order failed");
}
}
}
}
}
Wow! Thank you.
May I ask, no -break- - IsStopped()- ?
If I have 10 or 100 open positions, the function will only close,per ticket,per symbol of only OrderProfit() > 1?

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
Hi. I have a function that keeps my platform unresponsive and 100% CPU usage each time it executes,
I hope someone could help...
Please note, I have a loop of continuous buying and selling and means that there are always
positions left open at negative or positive result...