void open (double stp,double tp) { if(jahat==true) { int cick =OrderSend(Symbol(),OP_BUY,lot(),Ask,0,0,0,NULL,1111,0,clrGreen); jahat=false } if(jahat==false) { int tick =OrderSend(Symbol(),OP_SELL,lot(),Bid,0,0,0,NULL,2222,0,clrRed); jahat=true; } if(OrderSelect(OrdersTotal()-1,SELECT_BY_POS,MODE_TRADES)) { bool mod=OrderModify(OrderTicket(),OrderOpenPrice(),stp,tp,0,clrWhite); if(mod==false) { Comment(GetLastError()); } } }
1. You should check the returned value of OrderSend() for errors. OrderSend() returns a Ticket or -1.
2. You have 0 Slippage Tolerance; any differences in price between the request and the current market will cancel your transaction. Use 30 as a baseline. Slippage is in Points.
3. OrderSend returns a Ticket; why use OrderSelect with OrdersTotal - 1, its dangerous to do so because other trades can be open or closed meanwhile.
Just use OrderSelect with the Ticket Number gathered above.
4. For the issue about the EA not Triggering Orders the way you expected; its really hard to tell by the code you shared. I would Print() my Trigger Logic (your first block of code) and ensure it really trade as I expect before including Trade Functions.

- docs.mql4.com
1. You should check the returned value of OrderSend() for errors. OrderSend() returns a Ticket or -1.
2. You have 0 Slippage Tolerance; any differences in price between the request and the current market will cancel your transaction. Use 30 as a baseline. Slippage is in Points.
3. OrderSend returns a Ticket; why use OrderSelect with OrdersTotal - 1, its dangerous to do so because other trades can be open or closed meanwhile.
Just use OrderSelect with the Ticket Number gathered above.
4. For the issue about the EA not Triggering Orders the way you expected; its really hard to tell by the code you shared. I would Print() my Trigger Logic (your first block of code) and ensure it really trade as I expect before including Trade Functions.
thank u bro, i solve it. i didnt notice to the spread and thank u for your addition explains

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hi guys , do u know how this could happen? i tested my strategy in strategy tester then i expected only one sell there but it open some sells and some buys, price didnt reach to the buy
position even