Trabalho concluído
![](https://c.mql5.com/i/avatar/avatar_na2.png)
Termos de Referência
Concept:
The EA will remove pending orders (Limit and Stop) when spread is too high to avoid the orders being hit at a bad price. (ie during high overnight spreads or news events). They will either be placed back once spread is low again or will be transformed into market orders if they are still to be executed when spread is normalised.
It is also possible to set a fixed time period where pending orders will be deleted and placed back. (for example for overnight spreads)
When loaded on a chart (ie EURUSD) it checks the spread of that chart and when spread is higher then the set parameter, it removes either all pending orders or pending orders from certain Magic numbers (depending on settings). It places back the pending orders when spread is back to normal or executes them as market orders if the pending order would still be triggered.
The EA can be attached to different charts (i.e. EURUSD, GBPCAD, XAUUSD, EURJPY) working independantly from each other for different pairs.
Parameters:
Max Spread allowed (points): default = 30
Remove Stop orders: Yes/No (default = Yes)
Remove Limit orders: Yes/No (default = Yes)
Use fixed time removal: Yes/No (default = No)
Time to remove pending orders: (default = 23:30)
Time to place back pending orders: (default = 01:30)
Check magic number: Yes/No (default = No) => If no, it applies to ALL orders with/without MN
Magic Numbers: example: 0, 1550, 9999... (Magic Nrs seperated by comma. 0 = manual orders)
Max price difference to execute Market order: (default = 1000)
Examples:
EURUSD current price is 1.10650 and there is a STOP buy order at 1.10700.
Max Spread is set to 30 points and the spread goes to 31 points. The STOP buy order is now removed from the chart. 30 min. later, the spread drops to 25 points. The EA checks the price and if it is still below 1.10700 and it is possible to place the STOP order back, it places back te stop order. If price is now above 1.10700 and it is impossible to execute toe STOP order, it executes a Market buy order with the same lot size instead.
GBPCAD is at 1.68700 at 22:59 and the fixed time removal is set to YES 23:00 to 01:30.
Max spread allowed is set to 30. There is a LIMIT BUY order for 0.10 at 1.68600.
The LIMIT order gets removed at 23:00. At 01:30 the spread is still 40 points so the order does not get placed back yet. At 01:50 the spread gets to 20 points so the EA checks if it is possible to place the 0.10 LIMIT buy order back. Since the current price dropped to 1.68550 it is not possible to place the Limit order anymore so it executes a Market BUY order of 0.10 instead.
If price would have moved more then 100 pips from the limit order (1.68600 => 1.67600) the order would NOT be transferred into a market order and would be cancelled instead because of the Max price difference parameter.