Help with OrderProfit()

 
void ExitConditions()
  {
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS))
        {
         int ticket=OrderTicket();
         if(OrderMagicNumber()==MagicNumber && OrderSymbol()==Symbol())
           {
            if(OrderType()==OP_BUY)
              {
               // Exit Condition 1 - in profit and close > 5ma

               if(Close[1]>OrderOpenPrice() && OrderProfit()>0 && Close[1]>iMA(Symbol(),Period(),MAPeriod,0,0,PRICE_CLOSE,1))
                 {
                  OrderClose(ticket,Lots,Bid,50,clrRed);
                 }

              }

           }
        }
     }
}
  • This is only supposed to close position if it is in profit and price is > 5ma, for some reason it wont do that and keeps on closing position and seems to just ignore " close[1] > OrderOpenPrice() and OrderProfit() >0
Please can someone let me know what it is im doing wrong? Thanks
sam.
 
samuelgo:
Print your values to check what happens.