I just can't figure this one out. I need to open to orders, buystop and sellstop simultanously. And when one triggers to market close the other.
- need help with codes
- Please, how to open buystop and sellstop orders at the same time
- Help Deleting Pending Order!!!
RB
Enter the Pending orders for your breakout strategy.
Keep counting the BuyStops & the SellStops
When a count of BuyStops comes up as zero, close the pending SellStop.
Use the functions below as a basis
Good Luck
-BB-
int CountOrdersByTypeAndMagicNumber(int iType, int MN) { int icnt, itotal, retval; retval=0; itotal=OrdersTotal(); for(icnt=0;icnt<itotal;icnt++) { OrderSelect(icnt, SELECT_BY_POS, MODE_TRADES); // check for position, symbol & MagicNumber if((OrderType() == iType) && (OrderSymbol() == Symbol()) && (OrderMagicNumber() == MN)) retval++; } return(retval); } void ClosePendingBuyOrders(int MN) { int i, iTotalOrders; iTotalOrders=OrdersTotal()-1; // Rosh line for (i=iTotalOrders; i>=0; i--) // Rosh line { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderMagicNumber()==MN) { if (OrderType()==OP_BUYSTOP) OrderDelete(OrderTicket()); if (OrderType()==OP_BUYLIMIT) OrderDelete(OrderTicket()); } } } } void ClosePendingSellOrders(int MN) { int i, iTotalOrders; iTotalOrders=OrdersTotal()-1; // Rosh line for (i=iTotalOrders; i>=0; i--) // Rosh line { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderMagicNumber()==MN) { if (OrderType()==OP_SELLSTOP) OrderDelete(OrderTicket()); if (OrderType()==OP_SELLLIMIT) OrderDelete(OrderTicket()); } } } }
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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