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 !
- Help me with a simple code that doesn't work, please !
- Questions from Beginners MQL4 MT4 MetaTrader 4
- Modify an order
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 !!
-
Play videoPlease edit your post.
For large amounts of code, attach it.
- "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.
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

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register