TL;DR. A flag is a sharp move, the pole, followed by a short pause that gives back only part of it, then a close through the pause in the pole's direction. The Flag node finds bull flags and bear flags, fires once on the breakout bar, and hands you the breakout level, a measured-move target and a stop. One Sensitivity setting decides how strict the shape must be.
What it measures
- A continuation. After a strong push, price pauses in a tight range instead of reversing. A close through the pause says the push is resuming.
- Both directions in one node. A bull flag breaks up; a bear flag is the same shape upside down and breaks down. The node's breakout reads +1 for a bull flag and -1 for a bear flag.
- Once per flag. The breakout fires on one bar and the pattern ends. Another breakout needs a new pole, so a strategy never re-enters the same flag.
Formula
Inputs in AlgoLift
| Setting | Default | Range | Notes |
|---|---|---|---|
| Sensitivity | 5 | 1 to 10 | How strict the shape is. 1 finds only the cleanest flags, 10 the loosest; 5 is the textbook shape. Every setting below moves with it. |
| Longest flag | 20 | 3 to 200 bars | The most bars the pause may last. |
| Target (% of height) | 100 | 10 to 500 | The target's distance past the breakout, in percent of the pole. 100 is the classic measured move. |
| Settings | From Sensitivity | From Sensitivity, Custom | Custom unlocks the six settings below and reads them as you set them. |
| Pole at least | 1.8 ATR | 0.1 to 20 | The pole's least height. Step 1: 3.0, step 10: 1.0. |
| Pole within | 8 bars | 1 to 200 | The most bars the pole may take. Step 1: 5, step 10: 14. |
| Gives back at most | 50% | 1 to 100 | The deepest the flag may retrace. Step 1: 30%, step 10: 68%. |
| Flag at most | 1.6 ATR wide | 0.1 to 20 | The flag's widest range. Step 1: 1.0, step 10: 2.6. |
| Flag at least | 4 bars | 1 to 200 | The fewest flag bars before a break counts. Step 1: 6, step 10: 2. |
| Breaks by | 0.05 ATR | 0 to 5 | How far past the flag a close must be. Step 1: 0.15, steps 7 to 10: 0. |
Outputs in AlgoLift
| Handle | Type | Plotted | Notes |
|---|---|---|---|
| Breakout | Numeric | Always | +1 on a bull flag's breakout bar, -1 on a bear flag's, 0 elsewhere. Wire it into a Comparison (greater than 0 for longs, less than 0 for shorts). |
| Bull flag breakout, Bear flag breakout | Numeric | On select | 1 on that side's breakout bar, else 0. |
| Stage | Numeric | On select | The flag forming now: 0 none, 1 forming, 2 armed (a close beyond the level would break out). Positive for a bull flag, negative for a bear flag. |
| Breakout level | Numeric | Always | The armed flag's high (or low, for a bear flag). |
| Pattern high, Pattern low | Numeric | On select | The forming flag's range. |
| Target, Stop | Numeric | On select | The last breakout's measured move and its flag's far side, held until the next breakout. |
| Bars forming | Numeric | On select | Bars since the pole's top. |
How to read it
- Stage 2: a flag is armed and its level is drawn. A close beyond it is the signal.
- Stage 1: a pole has formed and the pause has started, but it is not long enough yet.
- A level that disappears without a marker: the flag gave back too much, grew too wide, ran too long, or a new pole replaced it.
- Few signals: raise Sensitivity one step at a time and watch the count. Each step loosens every rule together, so the shape stays coherent.
Best in, worst in
Best in trending sessions with impulsive legs, where pauses resolve in the direction of the move.
Worst in slow, ranging markets: the pole rule finds few real impulses, and a loose Sensitivity starts calling ordinary wiggles flags. Pair it with a trend filter.
Three setups
1. Flag with a trend filter
Wire Breakout into a Comparison (greater than 0) and AND it with an EMA trend filter (EMA 20 above EMA 50) into a long Entry. Mirror it with less than 0 and EMA 20 below EMA 50 for shorts.
2. Measured-move exits
Set a Bracket Order with its target at the node's Target and its stop at the node's Stop, so every trade's exits come from its own flag.
3. Trend strength confirmation
Require the ADX/DMI above 20 at the breakout, so flags in a directionless market are skipped.
Common mistakes
- Building the flag by hand. A flag needs memory (a pole, then a pause, then a break). The node holds that memory and has been tested against an independent implementation; a hand-built version rarely matches what you meant.
- Loosening several rules at once. Move Sensitivity one step, not five separate settings. If you need one rule different, switch Settings to Custom and change only that one.
- Choosing Sensitivity on the backtest you report. Pick it on one window and check it on another (overfitting in trading).
The Flag node finds a pole, a tight pause and the close through it, in both directions, once per flag. Sensitivity sets how strict the whole shape is with one number.