forex software

Create and Test Forex Strategies

forex software

Skip to forum content

Forex Forum

Forex Software, Forex Strategies, Expert Advisors Generator

You are not logged in. Please login or register.


Forex Forum → Third Party Robots, Expert Advisors, Tools → Is it possible to choose the last losing position? IN MQL4

Pages 1

You must login or register to post a reply

RSS topic feed

Posts: 1

Topic: Is it possible to choose the last losing position? IN MQL4

Hello to all friends

I have this cood

//---------------------------------------------------------------------
void close3(int number)
{

 for(int i=OrdersTotal()-1;i>=0;i--)

 {
 int OrderSelect = OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
 
  if(OrderMagicNumber()==number)
  {
   if( OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderProfit() + OrderCommission()>0 && OrderMagicNumber()==Magic7)
   if(Bid>OrderOpenPrice())
   if(OrderType()==OP_BUY)

   bool result=OrderClose(OrderTicket(),OrderLots(),Bid,slippage,Green);
   
  
  if( OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderProfit() + OrderCommission()>0 && OrderMagicNumber()==Magic8)
  if(Ask<OrderOpenPrice())
   if(OrderType()==OP_SELL) 
    
   bool result=OrderClose(OrderTicket(),OrderLots(),Ask,slippage,Yellow);
   }   
 }
}

//--------------------------------------------------------------

My EA is closing the bunch of profitable order at once , how can I add the last order which is on loss , on this group

So I want the close the orders on the loss one by one

Sample
Buy 0.05: - $ 30
Buy 0.06: - $ 40
Buy 0.08: - $ 10
Buy 0.12: $ 15
Buy 0.15: $ 30
Buy 0.18: $ 50
$ 50 + $ 30 + $ 15 + - $ 10 = + $ 85


Please help the professors
Thank you all

Posts: 1

Pages 1

You must login or register to post a reply

Forex Forum → Third Party Robots, Expert Advisors, Tools → Is it possible to choose the last losing position? IN MQL4

Similar topics in this forum