Before news release, the EA places two pending orders at a preset distance from the current price – BUYSTOP and SELLSTOP.
If the published news does not immediately cause a strong price movement, and the price starts to slowly move in a certain direction, the EA moves one of the order away, and the other one is moved closer following the price, until the price starts moving fast or the orders expire. This makes it possible to place orders as close as possible to the price (20-30 points for the five-digit quotes) with a low probability that the price may hit the order and go in the wrong direction in case of weak news.
When a pending order triggers, the EA immediately tries to move the position to breakeven and sets a take profit, while still continuing to drag the other order in the event of a sharp price reversal.
Parameters of the EA:
- ID = 10092015 - magic number. If ID=0, the EA places pending orders with the 0 ID and manages all the orders with the same ID. Manually opened orders also have 0. With an other ID>0, the EA places orders with the specified magic and manages only its own orders.
- Type Lot = Fixed Lot. It has two possible values: "Fixed Lot" - the lot value is equal to the "Lot" parameter, "Percent of balance" - it uses percent of account balance specified in the "Lot" parameter.
- Lot = 1.0 - lot size of pending orders if "Type Lot"="Fixed Lot" or percent of the account balance if "Type Lot"="Percent of balance".
- The time of the news = 2015.10.05 19:57 - time of news release according to the terminal time. To be set manually. The EA will not do anything before this time. If you want to place and modify orders irrespective of time settings, set time_news to some past time.
- Start (sec) = 10 - number of seconds before the scheduled news release time, when the EA starts working: places pending orders or modifies existing ones.
- SLEEP (msec) = 500 - time in milliseconds (1 second = 1000 milliseconds). A delay before order modification. For example, if the is at a distance of stepmin from a pending order, then the order will not be modified, if less than the specified time has passed since the previous modification.
- Order delete (sec) = 60 - the time in seconds after which pending orders are deleted. The EA will continue to manage open orders.
- StopLoss distance (pip) = 50 - the stop loss in points for a position that has not been moved to breakeven. It is set together with a pending order and for the previously opened positions. If the stop loss of an open positions is smaller that the given one, stop loss will not increased.
- TakeProfit (pip) = 1000. It is set only for the orders that have no take profit and have been moved to breakeven. Already set TPs are not modified.
- Minimum distance = 20 - the minimum distance in points, where the EA will move a pending order away from the price.
- Maximum distance = 50 - the maximum distance in points, where the EA will move a pending order closer to the price. Initially pending orders are placed at a distance of (stepmin+ stepmax)/2 from the price. If the price moves away from a pending order by a distance greater stepmax, the order moves up closer by the distance of (stepmin + stepmax) / 2. If the price moves close to a pending order closer than stepmin, the order moves away by the distance of (stepmin + stepmax) / 2. For BUYSTOP it moves from the Ask price, for SELLSTOP it moves from Bid.
- Use trailing = true - trails stop towards breakeven.
- Only to trail the profit = true - Move stop loss towards breakeven only when the prices enters the profit area.
- TrailingStop = 500. The distance to trails stop loss of a profitable position.
- TrailingStep = 10 - minimum trailing step.