Entry Rules
The Entry Rules serve as entry conditions, or filters, for opening a position. They are the second 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 order price — it produces a long or a short signal that allows or denies a position opening. The order price comes from the Entry Point.
How the rules combine
- None — with no entry rules added, the strategy raises an entry signal each time the Entry Point is reached, for both directions.
- One entry rule — a single entry rule allows or denies a position opening.
- Multiple entry rules — the strategy opens a position only when all the entry rules are satisfied. They act as AND logic.
The entry rules are ANDed with the entry point's direction signal: an entry opens when the entry point allows the direction and every rule allows it for that bar.
Rule families
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:
| Family | Indicators | What the rule compares |
|---|---|---|
| Oscillator | RSI, Stochastic, MACD, Momentum, CCI, Money Flow Index, and the other oscillators | The indicator value against a level line, its direction, or a level crossing |
| Band | Bollinger Bands, Donchian Channel, Envelopes | The bar open against the upper and lower band, with return variants; entry-only rules also compare the proposed entry price with the bands |
| Price vs. line | Moving Average | The bar open against the indicator line, with return variants; entry-only rules also compare the proposed entry price with the MA |
| Two-line | MACD Signal, RVI Signal, Stochastic Signal, Moving Averages Crossover, Directional Indicators, Alligator | Two indicator lines against each other (crosses and comparisons); Alligator and MA Crossover also offer entry-only price comparisons |
| Fractal | Fractal | The proposed entry price against the available Up or Down Fractal level |
| No-direction | Volumes, ADX, Average True Range, Standard Deviation | The rule output is written to both signals, so it fires for both directions |
| Pattern | Candle Color, Pin Bar | Candlestick patterns (consecutive bullish/bearish candles, pin bars) |
The full list of entry 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
- Rules are evaluated on the previous (closed) bar (
prev = 1in the engine). - 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.
Signal kinds
Every logic rule is also classified by how long its signal stays true, which is what decides whether a rule can make an entry land on one bar:
- Event — the rule signals on the single bar a change happens: a level crossing, a direction change, a
… after opening …transition, or a completed pin bar. - State — the rule signals on every bar its condition holds: a level comparison,
rises/falls,The bar opens …, or a candle colour. A state can stay true for a run of bars, so on its own it lets the strategy enter again on the next bar after a close. - Level — an order resting at a price. Only the entry and exit points have this kind (
Enter at Moving Averageand the band and fractal points): the level itself is always there, but the order fills on the touch, which is one concrete bar.
The Logic selector groups the rules by these kinds and shows the kind of the selected line. The Editor uses the kinds only as information — a hand-authored strategy with no event, or with several, still backtests. The Generator aims at exactly one single-bar trigger (an event or a level touch) in its entry chain and repairs a chain that misses, but that is its own preference, not a rule the user has to satisfy: a chain without a trigger still runs, and the preference has no control on any page.
The entry-only The position opens above/below … rules compare the Entry Point's proposed long or short order price with a raw indicator line. The rule text describes the long comparison; short entries reverse the inequality, and band/Fractal rules use the opposite line for shorts. These are state filters, not bar-open tests or conditions on the eventual fill. Comparisons require a strict difference greater than half an instrument point; each indicator guide documents its line mapping and read timing.
The proposed entry price
The candidate those rules compare is the Entry Point's order price for the direction, exactly the price at which the entry order is placed:
- a market entry (Bar Open) — the bar open, the same price for both directions;
- a price-level entry (bands, MA, Fractal) — the pending level, including its gap-to-open adjustment, so a level the bar gapped across counts as the bar open.
Spread, slippage and commission are applied later when the fill is booked, and they never change the relation. The reference line is the raw indicator value and is never gap-adjusted.
Two consequences:
- Equality fails. The comparison is strict by half an instrument point, so an order proposed exactly on the line does not satisfy the rule. Only the Entry Point's gap adjustment can move a pending level off the line it rests on, which is why the price rules are meaningful together with a different line or entry point.
- The same line as the Entry Point rarely passes. With “Enter long at Upper Band” the long candidate is the upper band (or the bar open after a gap), so “The position opens above Upper Band” blocks long entries and only a gap can let one through; the short side compares its own level with the opposite band and passes normally. The Generator may draw such a pair, and it is a legal but heavily restrictive combination rather than an error.
With a Bar Open entry the two families are nearly the same test: “The position opens above Upper Band” checks open > upper + point/2 (and open < lower - point/2 for the short side), while the older “The bar opens above Upper Band” checks open > upper + SIGMA (SIGMA = 0.000001) and mirrors to the lower band the same way. They differ only in that margin — the position rule scales with the instrument's point, the bar-open rule does not — so on a wide-point instrument an exactly-on-the-line open can satisfy one and not the other.
Ambiguity
The rules are evaluated before the order is created, so they decide the direction whenever the Entry Point cannot:
- If exactly one direction passes, that direction opens — even for a single-line entry point (Moving Average) or a shared level (Bar Open), where both directions share one price and would otherwise be ambiguous.
- If both directions still pass at one price, the bar is ambiguous: no order is placed and the bar is counted as ambiguous in the report.
- If the Entry Point's two levels differ (bands, Fractal), both directions can pass and both pending orders are armed; the first level the price reaches fills.
The same combined signal drives every consumer: fresh entries, opposite-signal close/reduce/reverse, adds on the same signal and the margin-rejection diagnostics. Grid adds keep their own grid gates and are not filtered by entry rules.
Entry Rule slot only
An exit point that closes on a price level leaves no room for exit rules, so these entry rules exist only in the Entry Rule slot: the Logic selector of an Exit Rule never lists them, and a stored Exit Rule record that carries one is rejected on load.
In the exported EA
The MQL5 export compares the same candidates: Open(0) for a market entry, the point's gap-adjusted long/short price otherwise, and the raw indicator line read at the same offset as the backtester (_Point / 2.0 as the margin). When the optional trace is enabled, the EA and the backtester both write entryRule<slot>_refLong / entryRule<slot>_refShort columns holding the reference values each decision used, so a divergence points at the line, not only at the trade.
Managing the slot
The strategy layout shows the Entry Rules in the Entry point and rules section, below the Entry Point. Add a rule with the Add entry rule button; 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.