Preventing Repeated Expert Advisor Triggers with Bar Timing
Summary
This article addresses trading robots that repeatedly open and close positions during a volatile candle, increasing spread costs. Using a MetaTrader MACD sample Expert Advisor as an illustration, it proposes limiting entry triggers by recording the elapsed time from the current candle’s start when an order is opened. The stored interval is then used to prevent another entry condition from passing during that same candle, without maintaining a trigger counter or relying on price amplitude.
For exits, it describes fixing closure to a candle boundary, then aligning entry and exit logic through indicator shifts so the exit condition can be evaluated on the completed prior bar. The example reports a reduction from repeated entries to one on the illustrated candle, but it is a demonstration, not a general performance test. Only buy logic is modified, sell logic remains unchanged for comparison, and the author explicitly says the sample Expert Advisors are not intended for live trading. Timing rules must also fit the chart timeframe and the robot’s actual order execution flow.
Key ideas
- Repeated entries within a candle can increase spread costs when entry and exit rules chatter.
- Recording elapsed time from candle open can block subsequent entries on that candle.
- A candle-boundary exit rule can be coordinated with entry logic using completed-bar indicator values.
- The example demonstrates behavior on one scenario rather than establishing general trading performance.
- The sample modifies only buy logic and is presented for demonstration, not live trading.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.