MR.: I am creating my system to open two pending orders - BuyStop and SellStop
-
There is no need to create pending orders in code.
-
The pending has the slight advantage, A) you are closer to the top of the queue (filled quicker), B) there's no round trip network delay (filled quicker.)
Don't worry about it unless you're scalping M1 or trading news.
-
Humans can't watch the screen 24/7, so they use pending orders; EAs can, so no need for pending orders, have it wait until the market reaches the trigger price and just open an order.
-
-
Where is your attempt and what is your problem?
Not tested, not compiled, just typed.
bool isOpen=false; int pendingTicket=EMPTY; for(int iPos=OrdersTotal(); --iPos >= 0;) if( OrderSelect(iPos, SelectByPos) && OrderMagicNumber() == extMN && OrderSymbol() == _Symbol ){ if(OrderType <= OP_Sell) isOpen = true; else pendingTicket = OrderTicket(); } if(isOpen && pendingTicket != EMPTY) OrderDelete(pendingTicket);
Not tested, not compiled, just typed.
Your topic has been moved to the section: MQL4 e MetaTrader 4 — In the future, please consider which section is most appropriate for your query.
![MQL5 forum: Expert Advisors and Automated Trading MQL5 forum: Expert Advisors and Automated Trading](https://c.mql5.com/36/77/mql5-forum-expert-advisors-and__2.png)
MQL5 forum: Expert Advisors and Automated Trading
- www.mql5.com
How to create an Expert Advisor (a trading robot) for Forex trading
![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
Dear all,
I am creating my system to open two pending orders - BuyStop and SellStop
Next, I want it to Close or Delete one of the Stop order when Buy or Sell is executed.
Example:
Case 1: BuyStop and SellStop are Placed
BuyStop is executed - Buy. Then, SellStop should be closed.
Case 2: BuyStop and SellStop are placed
SellStop is executed - Sell. Then, BuyStop should be closed.
Anyone knows how to code this in MT4?
Thanks.