Patterns & Conditions
The heart of every strategy: candle patterns, the three-section model, and the full condition syntax.
The three-section model
| Section | Purpose | Candle Period | Patterns allowed |
|---|---|---|---|
| Pre Entry optional | Setup conditions that must occur before an entry is even considered (e.g. "a swing high then a swing low formed in the last hour"). | You set it — scans the last N candles. Auto-updates to match the number of pre-entry patterns you add. | Any number of candle patterns, matched in order. |
| Entry required | The trigger. When the entry pattern matches and the entry condition is true, the trade is placed. | Always 1 (locked). Entry is decided on a single candle. | Exactly one candle pattern (validated at save). |
| Exit optional | Pattern/condition-based exits, evaluated while the trade is open (in addition to SL and target). | You set it — auto-updates with the number of exit patterns. | Any number of candle patterns. |
entry variables for stoploss and exits. Multi-candle setups belong in the Pre-Entry section.
Candle pattern indicators
Each pattern you add in a section is a named Candle indicator with three settings:
| Setting | Options | What it does |
|---|---|---|
| Candle Color | Green / Red / (blank = any) | The matched candle must close up (Green), down (Red), or either (blank). |
| Candle Gap | integer (e.g. 0, 4, 60) | Maximum number of candles allowed between this pattern's match and the next event in the sequence. 0 = must be immediately adjacent. See Candle Gap explained. |
| Candle Position | most_recent / last_closed_candle / higher_high / lower_low |
How the candle is located: the most recent matching candle, the last fully closed candle, the candle making the highest High in the window, or the lowest Low. |
- Entry section:
last_closed_candleis not offered (entry always works on the current candle). - Pre-entry section: when position is
last_closed_candle, the engine evaluates it against full history rather than the limited window.
The pattern's name becomes a variable in conditions, exposing the matched candle's values: name['Open'], name['High'], name['Low'], name['Close'], name['Volume'], name['Time'].
Candle Gap (max_gap) explained
When a section has multiple patterns, they must match sequentially. The gap on each pattern limits how far apart consecutive matches may be:
Pre-entry: candle_high (gap 60) → candle_low (gap 4) → ENTRY
candles: [H]· · · · · · · · · ·[L]· · ·[E]
≤ 60 candles ≤ 4 candles
candle_highmust be found, thencandle_lowwithin 60 candles after it.- After
candle_lowmatches, the entry candle must appear within 4 candles — otherwise the setup expires and pre-entry must re-match. - The last pre-entry pattern's gap controls how long the entry signal stays valid.
0 forces strictly adjacent candles.
Conditions
Each section has one condition string built with the Condition Builder popup — either by dragging tokens (parentheses, indicators, operators, numbers, time, AND/OR) or by typing the expression directly and clicking Build Condition.
Available variables by section
| Writing a condition in… | You can reference… |
|---|---|
| Pre Entry | Common indicators + pre-entry pattern names |
| Entry | Common indicators + pre-entry + entry pattern names |
| Exit | Common indicators + pre-entry + entry + exit pattern names |
This scoping is what lets an exit condition compare against the entry candle: exitC['Close'] < entry['Low'].
entry['rsi14'], candle_high['bb_middleband'] — never as a bare rsi14. A bare indicator name is undefined and the condition will fail.
Syntax reference
| Construct | Syntax | Example |
|---|---|---|
| Candle attribute | name['Field'] | entry['Close'], candle_high['High'] |
| Indicator (single output) | candle['name'] | entry['rsi14'], entry['vwap1'] |
| Indicator (multi output) | candle['name_suffix'] | entry['bb_upperband'], entry['macd1_Signal'] |
| Comparison | > < >= <= == != | entry['rsi14'] > 60 |
| Logical AND | && | A && B |
| Logical OR | || | A || B |
| Arithmetic | + - * / % | entry['High'] - entry['Low'] |
| Grouping | ( ) | (A && B) || C |
| Numbers | plain numerals | 0.5, 100 |
| Percent of a value | multiply | candle_high['High'] * 0.01 (1%) |
| Time of day | HH:MM compared to name['Time'] | entry['Time'] > 09:30 |
Running candle options
| Toggle | Effect |
|---|---|
| Use Running Candle (Entry) | Entry pattern/condition is evaluated on the live forming candle instead of waiting for it to close. Faster entries, but the candle's final values may differ from what triggered. |
| Use Running Candle (Exit) | Same idea for exit patterns — exits can trigger mid-candle. |
Worked examples
Example 1 — Bollinger Band reclaim (simple entry)
Setup: common indicator bb (Bollinger Bands 20/2); entry pattern entry = Green candle, gap 0.
# Entry condition
(entry['Low'] < entry['bb_middleband']) && (entry['Close'] > entry['bb_middleband'])
A green candle that wicks below the middle band but closes back above it.
Example 2 — Swing range then breakout (pre-entry + entry)
Pre-entry patterns: candle_high (position higher_high, gap 60) and candle_low (position lower_low, gap 4). Candle period 60.
# Pre-entry condition: at least a 1% high→low range, high formed first
(candle_high['High'] - candle_low['Low']) >= (candle_high['High'] * 0.01)
&& (candle_high['Time'] < candle_low['Time'])
# Entry condition: green candle reclaiming the BB midline
(entry['Low'] < entry['bb_middleband']) && (entry['Close'] > entry['bb_middleband'])
Because candle_low has gap 4, the entry must fire within 4 candles of the swing low — otherwise the whole setup re-arms.
Example 3 — Time-filtered momentum entry
# Only after the opening 15 minutes, with trend strength
entry['Time'] > 09:30 && entry['adx1'] > 25 && entry['Close'] > entry['vwap1']
Example 4 — Pattern-based exit
Exit pattern: exitC = Red candle, gap 0.
# Exit when a red candle closes below the entry candle's low
exitC['Close'] < entry['Low']
This works because exit conditions can see the entry pattern variable.
Checklist before saving
- Exactly one entry candle pattern exists.
- Every pattern/indicator referenced in a condition actually exists (names match exactly — case-sensitive).
- Parentheses are balanced; each comparison has both sides.
- Pre-entry/exit candle periods cover enough candles for your patterns (the builder auto-syncs them when you add patterns).
- Gaps reflect how quickly your setup should expire.