“Open a trade when the indicator changes” is a common and perfectly natural request. A human looking at a chart may feel that the meaning is obvious. To an Expert Advisor, however, the sentence is incomplete.
The change might happen inside the current candle, after the candle closes, when a line crosses a level, when one buffer replaces another, when a colour changes, or only after the new state remains valid for several updates. Each interpretation can produce a different trade history.
What must be clear before coding
Before an indicator change can become an EA rule, the data, event, confirmation time, and reset condition must all be defined.
- 01Data stateCurrent candle or closed candle?
- 02EventCross, value change, colour, arrow, object, or buffer state?
- 03ConfirmationImmediate, after close, or after several valid updates?
- 04ResetOnce, once per bar, or only after an explicit reset condition?
Current or closed bar?
An indicator can change many times while a candle is open. If the EA reacts immediately, it may enter on a state that disappears before close. If it waits, the signal is slower but more stable. Neither choice is automatically correct; the strategy must choose.
The same question applies to higher-timeframe indicators. A daily value read during the day is not the same as the final daily value visible later on the chart.
What counts as a change?
A cross above zero, a move from negative to positive, a colour switch, a new arrow, and a numeric increase are different events. Some indicators expose several buffers, and the visible object may not be the value the EA should read.
The rule should name the exact source, previous state, new state, direction, and any tolerance around the threshold.
Can the signal repaint?
Some indicators recalculate recent history or move a signal after new data arrives. A screenshot can then show an excellent past entry that was not available in that form at the decision time.
Before automation, the indicator should be observed tick by tick and after restart. The EA also needs a rule for missing values, history updates, and duplicate signals.
A useful specification
A short definition prevents long debugging sessions. The following points are usually enough to turn “indicator changed” into a testable event.
- Indicator name, version, symbol, timeframe, input settings, and exact buffer or object.
- Current candle or closed candle, including the bar index used for confirmation.
- Previous state, new state, cross direction, threshold, and numeric tolerance.
- Whether one signal may trigger once, once per bar, or again after a reset condition.
- What cancels the setup, blocks a trade, or closes an existing position.
- Expected behaviour after terminal restart, timeframe change, or incomplete history.
Why this matters
When the rule is precise, disagreements become testable. The trader can compare the intended event with logs and chart marks, and the developer can reproduce the same result. Clarity does not make a strategy profitable, but it makes honest evaluation possible.
Questions you may have
Should every indicator signal wait for a closed candle?
No. Intrabar signals can be valid, but their changing nature and execution rules must be intentional and tested.
Is repainting always a defect?
Not always. Some tools are designed to recalculate. The problem is using a historical appearance as if it had been available in real time.