stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Exit trade when on profit or loss
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=865
Page 1 of 1
Author:  Carioca [ Mon Oct 01, 2012 11:05 pm ]
Post subject:  Exit trade when on profit or loss

The EA exit a trade in the opposite sign, I wanted can choose to close only when in profit or loss

Code: Select all

bool LookForTradeClosure(int ticket)
{

...

   if (OrderType() == OP_BUY)
   {

...

       if (CloseTrade && trend == down) CloseThisTrade = true;

    }//if (OrderType() == OP_BUY)
    
    
   if (OrderType() == OP_SELL)
   {

...

      if (CloseTrade && trend == up) CloseThisTrade = true;

...
      
   }//if (OrderType() == OP_SELL)

...

}//End bool LookForTradeClosure()
It should be something easy someone can help me

thanks
Author:  Carioca [ Wed Oct 03, 2012 1:59 am ]
Post subject:  Re: Exit trade when on profit or loss

My error and I was using AccountProfit () instead of OrderProfit ().

This worked for me.

Code: Select all

if(OrderProfit() + OrderSwap() + OrderCommission() >= 0)
   {
      if (CloseTrade && trend == down) CloseThisTrade = true;
   }
All times are UTC Page 1 of 1