Flag

The bull and bear flag as one node: a pole, a tight pause, a close through it. Sensitivity sets how strict the shape is. How AlgoLift finds it.

IndicatorBy AlgoLiftUpdated 5 min read
On this page 11What it measuresFormulaInputs in AlgoLiftOutputs in AlgoLiftHow to read itBest in, worst inThree setups1. Flag with a trend filter2. Measured-move exits3. Trend strength confirmationCommon mistakes

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

SettingDefaultRangeNotes
Sensitivity51 to 10How 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 flag203 to 200 barsThe most bars the pause may last.
Target (% of height)10010 to 500The target's distance past the breakout, in percent of the pole. 100 is the classic measured move.
SettingsFrom SensitivityFrom Sensitivity, CustomCustom unlocks the six settings below and reads them as you set them.
Pole at least1.8 ATR0.1 to 20The pole's least height. Step 1: 3.0, step 10: 1.0.
Pole within8 bars1 to 200The most bars the pole may take. Step 1: 5, step 10: 14.
Gives back at most50%1 to 100The deepest the flag may retrace. Step 1: 30%, step 10: 68%.
Flag at most1.6 ATR wide0.1 to 20The flag's widest range. Step 1: 1.0, step 10: 2.6.
Flag at least4 bars1 to 200The fewest flag bars before a break counts. Step 1: 6, step 10: 2.
Breaks by0.05 ATR0 to 5How far past the flag a close must be. Step 1: 0.15, steps 7 to 10: 0.

Outputs in AlgoLift

HandleTypePlottedNotes
BreakoutNumericAlways+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 breakoutNumericOn select1 on that side's breakout bar, else 0.
StageNumericOn selectThe 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 levelNumericAlwaysThe armed flag's high (or low, for a bear flag).
Pattern high, Pattern lowNumericOn selectThe forming flag's range.
Target, StopNumericOn selectThe last breakout's measured move and its flag's far side, held until the next breakout.
Bars formingNumericOn selectBars 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.
Common Misconception
Myth
A looser Sensitivity is just more trades of the same quality.
Reality
Each step admits flags with smaller poles and deeper, wider pauses. Those are different setups, and their follow-through is usually weaker. Test the step you trade on months it was not chosen on.

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).
Key Takeaway

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.