Download MetaTrader 5

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

To add comments, please log in or register
giomazz
12
giomazz  
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 ! 

Carl Schreiber
7679
Carl Schreiber  
Don't double post: http://forum.mql4.com/70922  Even here use the SRC button for your code!
Help me with a simple code that doesn't work, please ! - MQL4 forum
  • www.mql5.com
Help me with a simple code that doesn't work, please ! - MQL4 forum
Alain Verleyen
Moderator
33811
Alain Verleyen  
calli:
Don't double post: http://forum.mql4.com/70922  Even here use the SRC button for your code!
It's not a double post, it's an other forum.
To add comments, please log in or register