Exit Rules

The Exit Rules serve as triggers for closing a position. They are the fourth of the four indicator slots of the Strategy Editor.

The slot is optional and holds an ordered list of 0..n indicators. A rule never sets the closing price — it produces a long or a short signal that allows or denies a position exit. The closing price comes from the Exit Point.

Availability

Exit rules exist only behind an exit point that allows them. The rule lives in the indicator definition (isAllowExitRules), and only the two market exits — Bar Open and Bar Close — declare it. A price-level exit point (Moving Average, Bollinger Bands, Donchian Channel, Envelopes, Fractal) places a resting order the bar reaches, so a closing condition in front of it would be calculated and never read; No Indicator Exit never closes on an indicator signal at all.

  • The Add exit rule button is enabled only while the exit point allows rules. Its title (and the hint shown when it is disabled) names the condition.
  • Selecting an exit point that does not allow exit rules removes the strategy's exit rules. The change is one undo step: Undo restores the point and the rules together, and Cancel in the open indicator form restores them as well.
  • A strategy stored or exported by an older version can still carry rules behind such a point. They stay listed and the hint marks them as not applied; they never close a position, and switching to a point that allows rules keeps them. The Collection and the Expert Advisor import refuse such a strategy with the same explanation, so only a strategy already stored in the Editor can reach this state.

How the rules combine

  • None — with no exit rules added, the strategy exits each time the Exit Point is reached.
  • One exit rule — a single exit rule allows or denies a position exit.
  • Multiple exit rules — the strategy closes a position when one of the exit rules is satisfied. They act as OR logic.

The exit rules are ORed across the open position's direction: a position closes when the exit point allows the exit and any rule triggers for its direction.

Rule families

The exit rule catalog is the same as the entry rule catalog. Every rule indicator offers a fixed list of logic rules (the "Logic" selector in the indicator form). The rules fall into families with shared evaluation semantics:

FamilyIndicatorsWhat the rule compares
OscillatorRSI, Stochastic, MACD, Momentum, CCI, Money Flow Index, and the other oscillatorsThe indicator value against a level line, its direction, or a level crossing
BandBollinger Bands, Donchian Channel, EnvelopesThe bar open or the bar close against the upper and lower band, with return variants
Price vs. lineMoving AverageThe bar open or the bar close against the indicator line, with return variants
Two-lineMACD Signal, RVI Signal, Stochastic Signal, Moving Averages Crossover, Directional Indicators, AlligatorTwo indicator lines against each other (crosses and comparisons)
No-directionVolumes, ADX, Average True Range, Standard DeviationThe rule output is written to both signals, so it fires for both directions
PatternCandle Color, Pin BarCandlestick patterns (consecutive bullish/bearish candles, pin bars)

The full list of exit rule indicators, their logic rules, and the threshold tables are in the Indicators index; every indicator's own guide page documents its rules.

Signal timing

  • The exit point decides which bar the exit rules read. Behind Bar Open they are evaluated on the previous (closed) bar (prev = 1); behind Bar Close they are evaluated on the bar being closed (prev = 0), because that bar is complete at the Bar Close moment. The exported EA mirrors this: CalcSignals computes the previous-bar reading and the Bar Close event re-evaluates the rules on the near-final bar.
  • An indicator applied to the Open price reads the current bar even behind a Bar Open exit, because an open-price line is known at the bar opening. That relaxation never applies to a The bar closes rule: its subject is the read bar's close, which is not known when the bar opens.
  • Signals are valid only from the indicator's firstBar — the bars needed to compute the first value plus two warm-up bars.
  • Every comparison uses a small dead zone (SIGMA = 0.000001): a value must differ by more than that epsilon to count.

Bar open and bar close rules

The price (main-chart) indicators — Moving Average, Bollinger Bands, Envelopes, Donchian Channel — offer two rule families:

FamilyWordingJudged bar
Bar openThe bar opens above …the bar open at the execution moment, compared with the line of the read bar
Bar close (exit only)The bar closes above …the close of the read bar, compared with the line of that same bar

The wording names the reference bar, so a rule means one thing in every slot. Behind a Bar Close exit the two families differ: an open rule judges the bar's open against a line that already includes that bar, a close rule judges its close. The Generator prefers the family that matches the exit point — a Bar Close exit draws The bar closes lines.

Managing the slot

The strategy layout shows the Exit Rules in the Exit point and rules section, below the Exit Point. Add a rule with the Add exit rule button while the exit point allows rules; the catalog lists every indicator that supports the slot. Click a listed rule to open its form; the replace button swaps the indicator in place.