Help me with a simple code that doesn't work, please !

 
Hello everybody!
I'm a new user of this forum and I'm trying to learn MQL4 to build a my own EA, but now I have a little problem with my code.

The MT4 doesn't read this part :

"
int H = OrdersTotal();

//CORREZIONE BUY
  if (H>0)
   {
    OrderSelect(H-1,SELECT_BY_POS);
    if(OrderType()==0 && OrderMagicNumber()==MG_BUY && OrderLots()==LOT && OrderStopLoss()==(OrderOpenPrice()-SL*Point) && OrderOpenPrice()>=(Ask+40*Point))
    {
     OrderSelect(H-1,SELECT_BY_POS);
      OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss()+1*Point,OrderTakeProfit(),0,Green);
         OrderSend(Symbol(),1,LOT*10,Bid,5,Bid+SL2*Point,Bid-TP2*Point,"DIS+3",MG_SELL,0,Red);
    }
   }

   //CORREZIONE SELL
  else if (H>0)
   {
    OrderSelect(H-1,SELECT_BY_POS);
    if(OrderType()==1 && OrderMagicNumber()==MG_SELL && OrderLots()==LOT && OrderStopLoss()==(OrderOpenPrice()+SL*Point) && OrderOpenPrice()<=(Bid-40*Point))
      {
       OrderSelect(H-1,SELECT_BY_POS);
        OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss()+1*Point,OrderTakeProfit(),0,Red);
          OrderSend(Symbol(),0,LOT*10,Ask,5,Ask-SL2*Point,Ask+TP2*Point,"DIS+3",MG_BUY,0,Green);
      }
   }
"
I think the problem is this part of code : "OrderOpenPrice()>=(Ask+40*Point) / OrderOpenPrice()<=(Bid-40*Point)"

So I Tried also to change this part  
with: "OrderOpenPrice()-(Ask+40*Point)>=0 / OrderOpenPrice()-(Bid-40*Point)<=0" 
and with : " OrderOpenPrice()>=NormalizeDouble((Ask+40*Point),8) / OrderOpenPrice()<=NormalizeDouble((Bid-40*Point),8)" 
and with : " NormalizeDouble(OrderOpenPrice(),8)>=NormalizeDouble((Ask+40*Point),8) / NormalizeDouble(OrderOpenPrice(),8)<=NormalizeDouble((Bid-40*Point),8)
but It doesn't work !!

Can You Help Me , please ?

Thank You in Advance ! 
 
Please correct you post and and use the SRC-button for your code - it's a lot easier to read for others.!
 
giomazz: but It doesn't work !!
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
  3. OrderSelect(H-1,SELECT_BY_POS);
    OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss()+1*Point,OrderTakeProfit(),0,Red);
    OrderSend(Symbol(),0,LOT*10,Ask,5,Ask-SL2*Point,Ask+TP2*Point,"DIS+3",MG_BUY,0,Green);
    Check your return codes and find out why. What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
Reason: