Comments that do not relate to the "Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes", have been moved into this topic.
- Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes
- EA programming
- Errors, bugs, questions
Hi all, I'm a newbie with MT5.
I need an help in recall BUY and SELL STOP ORDERS, could you fix the following code?
I don't know how to select SELL STOP ORDERS. Thank you!
#include <Trade\Trade.mqh> CTrade trade ; void OnTick() { for(int cnt=0; cnt<PositionsTotal(); cnt++) { if(PositionGetSymbol(cnt)==Symbol()) { if (OrderGetInteger(ORDER_TYPE,ORDER_TYPE_SELL_STOP)) { trade.OrderDelete(OrderGetTicket(cnt)); Print("Error deleting SELL Stop order: ",GetLastError()); } } } }
I wrote this code
for(cnt=0; cnt<OrdersTotal(); cnt++) { ResetLastError(); string OrderSymbol = OrderGetString(ORDER_SYMBOL); if(OrderSelect(OrderGetTicket(cnt))==true) { if(OrderSymbol == Symbol()) { ENUM_ORDER_TYPE type=(ENUM_ORDER_TYPE)OrderGetInteger(ORDER_TYPE); if(type==ORDER_TYPE_BUY_STOP) { trade.OrderDelete(cnt); Print("Error deleting BUY Stop order: ",GetLastError()); } if(type==ORDER_TYPE_SELL_STOP) { trade.OrderDelete(cnt); Print("Error deleting SELL Stop order: ",GetLastError()); } } // Symbol } // ticket } // FOR
but I stil have this error in testing
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