Auto-Detects Flags and Poles, Then Marks the Breakout Bar
Price rips higher, then drifts down in a tight, orderly pullback. That is the classic flag. The sharp leg is the pole, the shallow pullback is the flag, and the textbook play is to catch the continuation when price breaks out of the top of the flag.
Flag & Pole Pattern Tp-sl hunts for these flags on your TradingView chart, draws dashed lines along the top and bottom of the flag, and prints BUY or SELL on the bar that closes through a line. It handles both bull flags and their mirror image, bear flags.
I ran it on Bitcoin across seven timeframes, from the 1-minute to the weekly. All it puts on the chart is two dashed lines and a few labels, and the candles almost never got buried. If you are used to connecting highs and lows by hand to spot flags, handing that whole search over to the indicator is the real win here.

The name says Tp-sl (take profit / stop loss), but in the version I tested there were no take-profit or stop-loss zones on the chart, and no risk-to-reward input in the settings either. What you get is the flag lines, the labels, and the BUY/SELL signals. Plan on bringing your own exit as you read on. I cover a pairing for that later in the article.
Two Dashed Lines and Three Kinds of Labels
There is not much on screen. The bullish and bearish sides simply swap colors and placement, so it is worth getting familiar with what each element means first.
| Element | Bull flag | Bear flag | When it appears |
|---|---|---|---|
| Upper dashed line | Lime green | Orange | Bar where the flag is detected |
| Lower dashed line | Light blue | Red | Bar where the flag is detected |
| Flag label | Green “Bullish Flag” (below the bar) | Red “Bearish Flag” (above the bar) | Bar where the flag is detected |
| Breakout triangle | Lime ▲ with “BUY” (below the bar) | Red ▼ with “SELL” (above the bar) | Bar that closes through the line |
| Breakout label | Green “FLAG BREAKOUT BUY” | Red “FLAG BREAKDOWN SELL” | Bar that closes through the line |
The figure below walks through a full bull flag sequence. A line connecting three lower highs is drawn on top and a line connecting three lower lows on the bottom Figure 1, then “Bullish Flag” fires on the bar where upside momentum kicks in Figure 2. After that, “BUY” prints on the bar that closes above the extension of the upper line Figure 3.
The basic Flag & Pole Pattern Tp-sl sequence (bull flag)
Once three lower highs and three lower lows line up and the latest push higher has momentum, Bullish Flag fires. BUY prints on the bar that closes above the upper dashed line.
Vowars DE ver.3.23.1
The BUY triangle and the “FLAG BREAKOUT BUY” label both sit under the low of the same bar, so on a live chart they read as one cluster. If the text feels crowded, turn off Show Breakout Labels and you are left with just the triangle, which keeps things clean.
At the right edge of the figure, “Bullish Flag” shows up again after the BUY. A BUY ends the monitoring for that flag, but if all three conditions are still true at that point, the indicator starts counting the same structure as a new flag from the next bar. I saw the same “Bullish Flag → BUY → Bullish Flag → BUY” sequence on the 5-minute chart. It is easiest to read the second and later labels as “momentum is still there.”
Bear Flags Flip the Colors and the Direction
For a bear flag, “Bearish Flag” fires above the bar once a strong drop follows a series of higher highs and higher lows Figure 1. When a bar closes below the extension of the red lower line, SELL prints on that bar Figure 2.
Bear flag, SELL, and where the lines stop
A strong drop after higher highs and higher lows fires Bearish Flag, and a close below the lower dashed line prints SELL.
Vowars DE ver.3.23.1
The other thing worth knowing is when the lines stop. Once BUY or SELL fires, or more than 40 bars pass after the label, the dashed lines stop extending to the right and only the segment between the three swing points remains Figure 3. That is why the lines look cut off partway through the flag when you scroll back through history. Nothing is missing from the display.

The Three Conditions Behind a Bullish Flag
Once you know what the indicator checks behind each label, it becomes much clearer why a flag fired where it did, or why it did not fire at all. Bullish Flag prints when all three of these line up on the same bar.
- Three consecutive pivot highs, each lower than the last
- Three consecutive pivot lows, each lower than the last
- The current close is at least 3x ATR(14) above the close from 20 bars ago
A pivot here means a bar whose high (or low) is above (or below) the six bars on either side of it. On top of that, the gap between the second and third pivot highs has to be at least Minimum Trendline Slope (%) (0.02% by default). Bearish Flag is the exact mirror: higher highs and higher lows, plus a close at least 3x ATR below the close from 20 bars ago.
From Bullish Flag to BUY: the decision flow
All three conditions on the same bar fire Bullish Flag. A close above the upper line within the next 40 bars prints BUY.
Vowars DE ver.3.23.1
Two points in the flow matter most: momentum is measured from the current bar Figure 1, and every check waits for the bar to close Figure 2. Whether a BUY fires or 40 bars go by, that is where monitoring ends Figure 3.
Pole Strength Is Measured 20 Bars Back From the Current Bar
This is where the character of the indicator really shows. It does not go looking for the rally before the flag to measure the pole. Instead, it compares the close of the bar it is about to label Figure 2 with the close 20 bars earlier Figure 1, and if the difference is at least 3x ATR, the pole counts as valid Figure 3.
The pole check: current close vs. the close 20 bars ago
On the Bullish Flag bar, the close is at least 3x ATR(14) above the close from 20 bars earlier.
Vowars DE ver.3.23.1
With the defaults, a pivot needs six bars to confirm, so the bar 20 bars back usually lands inside the flag itself. In other words, out of the box Flag & Pole Pattern Tp-sl catches the moment price swings sharply higher over the last 20 bars while the lower-highs structure is still intact. That is why the label tends to fire when price snaps back from the bottom of the flag to the top, right before or right after the breakout.
If you would rather catch the textbook “sharp rally, then slow pullback” shape and measure it from the start of the rally, lengthen Pole Lookback. I show concrete values, with a figure, in the settings section.
The Label Shows Up at Least Six Bars After the Third Pivot
A pivot only confirms once six bars (the Pivot Length value) have printed to its right. So from the third swing low Figure 1 until those six bars have passed Figure 2, Bullish Flag will not fire no matter how hard price rallies. It finally prints on the bar where the pivot is confirmed and the momentum condition is also met Figure 3.
The label comes 6+ bars after the third swing low
A pivot only confirms once six bars have printed to its right, so Bullish Flag always appears on a later bar than the third swing low.
Vowars DE ver.3.23.1
The dashed lines are drawn on that signal bar, reaching back to the earlier pivots. Looking at it later, it seems as if the lines were there before the flag finished forming, but they actually appear on the bar where the label prints.
Both the labels and the BUY/SELL signals are evaluated on bar close. They do not flicker on and off on the live bar, and once printed they never disappear later. The dashed lines, however, are drawn back in time to pivots several to dozens of bars earlier at the moment the flag is detected. When you compare lines and labels on historical bars, treat the label’s position, not the line, as the bar where that information became available.
When BUY/SELL Prints, and When You Only Get the Label
BUY prints on the bar that closes above the extension of the upper line, from below, within 40 bars of the label. The check is a cross: the previous close is at or below the line and the current close is above it. You get one BUY per flag. Going through all seven timeframes, the signals fell into three broad patterns.
1 Label first, BUY a few bars later
This is the standard pattern. When the label fires, price is still inside the flag, and a later bar breaks through the upper line. In this test, the bull flags on the 30-minute, 1-hour, 4-hour, and daily charts all played out this way. You get some lead time after the label to get ready, which makes this the easiest pattern to trade.
2 Label and BUY on the same bar
When a big momentum candle punches straight through the line, the label and the BUY land on the same bar. On the 4-hour chart, during the March selloff, the Bearish Flag and SELL labels printed almost on top of each other. It is a bit harder to read because of the overlap, but the meaning is simple: the flag broke on the same bar it was detected.
3 Label only, no BUY
If the close is already above the line on the bar where the label fires, there is no cross from below, so BUY will not print unless price dips back under the line and breaks out again. In this test, I saw this on a 1-minute bull flag and on the daily and weekly bear flags. It is the flip side of measuring momentum over the last 20 bars: the faster the move, the more likely the label shows up after the breakout has already happened.

Bullish Flag is the heads-up that structure and momentum are in place. BUY is the trigger that confirms a close above the upper line. When the label fires, check where the upper line sits and how far price is from the most recent high, then make the actual decision on the BUY bar. With that two-step approach, a Case 3 setup with no BUY will not catch you off guard.
How It Behaved Across Different Timeframes
I checked the indicator on seven timeframes: 1-minute, 5-minute, 30-minute, 1-hour, 4-hour, daily, and weekly. This is only what I saw on my own charts, but the feel was clearly different from one timeframe to the next.
On the 1-minute chart, small flags kept popping up one after another, and there were spots where Bearish Flag and SELL labels stacked on top of each other and got hard to read. That is because it picks up even tiny wiggles as three pivots. I found it easier to work with after adjusting the settings covered later than running it as is.
From the 30-minute to the 4-hour chart, the sequence of a pullback boxed in by downward-sloping dashed lines, then Bullish Flag, then BUY was easy to follow. This is the range where the indicator’s strengths came through most clearly. On the 1-hour chart there were also cases where the label fired on the bounce after a sharp drop, with BUY following a few bars later.
On the daily chart, after the lines boxed in the decline from May through July, Bullish Flag fired in mid-July and BUY followed in mid-August, right before a strong rally. With fewer bars, signals are rare, but the structure is very clear when they do show up.
On the weekly chart the flags stretch out much longer, and the lines kept extending to the right because the 40-bar monitoring window (about nine months) had not run out yet. On the weekly, it works better as a way to confirm the shape of the bigger trend than as something to wait on for signals.

Flags tend to form in markets that trend in one direction, so beyond Bitcoin, it should pair well with instruments whose trends tend to persist, such as gold (XAUUSD) and stock indices. In a choppy market that just chops back and forth, clean lower-highs or higher-lows sequences are hard to come by, so the label itself fires less often.
Settings and How to Tune Them for Your Setup
The settings are split into three groups: “Pole Detection,” “Flag Detection,” and “Display Settings.” The suggested values are starting points based on the behavior covered above and how the indicator looked on each timeframe.
| Setting | Default | Suggested | Effect |
|---|---|---|---|
| Pole Lookback | 20 | 20 (standard) / 40–50 (to measure from the start of the pole) | How many bars back the momentum comparison looks. Higher values compare against the start of the pole; lower values react only to recent sharp snap-backs |
| Minimum Pole Size (ATR) | 3.0 | 2.5–3.0 | Momentum threshold as a multiple of ATR. Lower values give more labels; higher values give fewer, but the label is more likely to land after the breakout |
| ATR Length | 14 | 14 | ATR period used to measure momentum. Shorter tracks recent volatility; longer tracks average volatility |
| Pivot Length | 6 | 4–5 (15m and below) / 6–8 (1H and above) | Bars on each side that define a pivot. Lower values pick up smaller flags and confirm faster; higher values keep only larger structures and delay the label |
| Touch Tolerance (%) | 0.30 | Leave as is | In the tested version, changing this value does not change the display |
| Maximum Flag Length (Bars) | 40 | 20–30 (short-term) / 40–60 (daily and above) | How many bars after the label the indicator waits for BUY/SELL. After that, monitoring ends and the lines stop extending |
| Minimum Trendline Slope (%) | 0.02 | 0.02–0.1 | Minimum gap (%) between the second and third pivot highs. Raising it filters out nearly flat structures |
| Show Pole Labels | On | On | Shows the Bullish Flag / Bearish Flag labels |
| Show Flag Trendlines | On | Leave as is | In the tested version, the dashed lines still show even when this is off |
| Show BUY / SELL Signals | On | On | Shows the triangles with BUY/SELL text |
| Show Breakout Labels | On | Personal preference | Shows the FLAG BREAKOUT / FLAG BREAKDOWN labels |
You might want to raise Minimum Pole Size (ATR) when there are simply too many labels. Keep in mind, though, that the stricter the threshold, the longer the indicator waits for momentum to build up, so you get more Case 3 setups where the label fires after the breakout. If you just want fewer signals, raising Pivot Length first to filter on structure tends to keep the label-then-BUY sequence intact.
The 0.02% default for Minimum Trendline Slope (%) works out to about $16 when price is at $80,000. On Bitcoin at 1-hour and above, almost every structure clears that bar. If you feel it is picking up patterns where the highs are basically flat, more consolidation than flag, raise it to 0.05–0.1% and only flags with a clear slope will remain.
A Longer Pole Lookback Catches Textbook Flag-and-Pole Setups
As mentioned above, with the default Pole Lookback of 20, the comparison point falls inside the flag. The cleaner the flag, with a slow pullback after the pole, the smaller the difference between now and 20 bars ago, so the label shifts to after the breakout and no BUY prints Figure 1. On the same price action, setting Pole Lookback to 50 pushes the comparison point back into the middle of the pole’s rally. The label then fired right after the third swing low confirmed Figure 2, and BUY printed on the very next bar Figure 3.
A longer Pole Lookback catches textbook flag-and-pole setups
On the same price action, a Pole Lookback of 20 puts the label after the breakout, while 50 fires it right after the third swing low confirms.
Vowars DE ver.3.23.1
The rule of thumb is to set it longer than the flag portion itself. With Pivot Length at 6, three pivots plus the confirmation wait already take 20+ bars, so 40–50 is a good starting point. The trade-off is that a more distant comparison point also counts older rallies as momentum, so in choppy markets the label can fire because of a rally from quite a while back. I recommend choosing based on which shape you want to trade.
Example Setups by Goal
| Goal | Suggested timeframe | Pivot Length | Pole Lookback | Maximum Flag Length (Bars) |
|---|---|---|---|---|
| Catch smaller flags too | 5m–15m | 4–5 | 20 | 20–30 |
| Run the defaults | 30m–4H | 6 | 20 | 40 |
| Focus on the pole-to-flag shape | 1H–Daily | 6–8 | 40–50 | 40–60 |
Lowering Pivot Length on lower timeframes shortens the pivot confirmation wait so the label fires as early as possible. Since that also produces more flags, Maximum Flag Length (Bars) is shortened too, so old lines do not hang around forever. On the daily, the opposite applies: the flag’s pullback itself tends to run longer, so the monitoring window is given more room.
Touch Tolerance (%) and Show Flag Trendlines are listed in the settings, but in the version I tested they are not used in the detection logic or for toggling anything on the chart. Even if you switch Show Flag Trendlines off to hide the dashed lines, the dashed lines stay on the chart. They may be wired up in a future update, so it is worth checking them again whenever the script is updated.
Two-Stage Alerts: Detection and Breakout
Flag & Pole Pattern Tp-sl comes with four alert conditions. The figure shows how they map to what you see on the chart: you can get alerted on the label bar Figure 1 and on the BUY/SELL bar Figure 2, separately for the bullish and bearish sides.
How the four alerts map to the chart
You can be alerted at two stages, on the label bar and on the BUY/SELL bar, separately for the bullish and bearish sides.
Vowars DE ver.3.23.1
| Alert condition | When it fires | What the message includes |
|---|---|---|
| Bullish Flag Detected [JPT] | When the bar with Bullish Flag closes | Symbol |
| Bullish Flag Breakout [JPT] | When the bar with BUY closes | Symbol and close price |
| Bearish Flag Detected [JPT] | When the bar with Bearish Flag closes | Symbol |
| Bearish Flag Breakdown [JPT] | When the bar with SELL closes | Symbol and close price |
An efficient workflow is to use “Detected” on a higher timeframe to know a flag has formed, open the chart to check where the lines are, and then act on “Breakout” or “Breakdown.”
1 Add the indicator to your chart
Add Flag & Pole Pattern Tp-sl to a chart of the symbol and timeframe you want to watch. On the chart it shows up under its short name, “F & P JPT.”
2 Pick the condition in the Create Alert dialog
Open the Create Alert dialog, select this indicator in the Condition field, then choose which of the four conditions you want.
3 Create as many alerts as you need
Each alert can only use one condition, so if you want all four, you need four separate alerts. The number of alerts you can create depends on your TradingView plan, so narrowing it down to the two you use most is also a solid option.
Adding an Exit After the BUY
As noted earlier, Flag & Pole Pattern Tp-sl stops at flagging the breakout bar and does not draw a stop level for an open position. Where to get out after the BUY is up to you. A good fit for that job is Chande Kroll Stop, one of TradingView’s built-in indicators.
Chande Kroll Stop plots two stop lines based on recent highs, lows, and ATR. TradingView’s help center describes the blue line as the stop level for long positions and the other line as the stop level for short positions. In the figure, after the BUY Figure 1, the blue line (Stop Long) ratchets higher as price rises Figure 2, and the first bar that closes below it is used as the exit cue Figure 3.
Adding an exit after BUY with Chande Kroll Stop
Flag & Pole Pattern Tp-sl stops at flagging the breakout bar, so the blue Chande Kroll Stop line (Stop Long) can serve as the exit guide while you are in the trade.
Vowars DE ver.3.23.1
There are two reasons I like this pairing. First, both use ATR to size the move, so how volatile the flag bar was and how wide the stop sits feel consistent. Second, while the uptrend continues, the blue line steps up like a staircase, so compared with keeping your stop at the low of the BUY bar or the lower flag line, it moves to a level that locks in more of the gain.
There are other good pairings depending on what you need. If you want to confirm there was real buying behind the breakout bar, Elder’s Force Index (EFI), which combines price change with volume, is a candidate. If EFI spikes well above zero on the BUY bar, you can read it as a breakout backed by volume. And if you want to know whether the market is even in flag-friendly conditions, check the Choppiness Index (CHOP) first to see whether price is trending or chopping sideways. That should save you time waiting for labels that are unlikely to come.
Display Quirks Worth Knowing Before You Use It
Only the Latest Set of Lines Stays for Each Direction
When a new Bullish Flag fires, the bullish lines that were on the chart are removed and replaced with the new ones (the bearish side works the same way). Past labels and BUY signals stay, so when you scroll back you will see a row of flags with labels but no lines. If you want to see the old lines, rewind to that point with TradingView’s Bar Replay and you can check the lines as they were calculated up to that bar. How far back you can go depends on your plan and the timeframe.
BUY Signals When a New Pivot Forms During Monitoring
If a new pivot high confirms after the label while you are waiting for the BUY, the BUY check switches to a line through the latest three pivots at that point. The dashed lines on the chart are not redrawn, so BUY can print a little away from the dashed line, or not print even though price closed through it. If the dashed line and the BUY look out of sync, check whether a new high formed after the label. SELL on bear flags works the same way, with the check line shifting on a new pivot low.
Lines When a Flag in the Opposite Direction Appears
When a Bullish Flag fires, any Bearish Flag that was being monitored at that time is dropped (and vice versa). In that case, the bearish lines may not stop extending and can keep stretching to the right. They look the same as an active flag, but SELL will not print even if price closes below them. Use the most recent label to tell which direction is actually live.
Flag breakouts that get pushed right back into the flag, classic fakeouts, are not unusual. Because Flag & Pole Pattern Tp-sl waits for the bar to close, it keeps you from chasing a move on the live bar, but a confirmed breakout is still no guarantee of follow-through. The basics still apply: set your stop before you take the BUY, and check that the higher-timeframe trend points the same way. Also, since this is an indicator, you cannot get backtest results from the Strategy Tester as is. For a quick check, step through bars one at a time in Bar Replay and watch how the labels and BUY signals play out.
What it handles for you
- Connects three highs and three lows for you and scans for both bull flags and bear flags
- Shows only dashed lines and labels, so the chart stays readable even with other indicators on it
- Labels and BUY/SELL are evaluated on bar close, so printed signals never disappear later
- Detection and breakout can be sent as separate alerts
- Changing just Pole Lookback switches between catching momentum snap-backs and measuring from the start of the pole
What you will want to add yourself
- No take-profit or stop-loss levels are drawn, so exits have to come from another indicator or your own rules
- On fast moves the label can fire after the breakout, and no BUY prints
- Only the latest set of lines per direction is kept, so older flags show up without lines
- On very low timeframes like the 1-minute, labels tend to pile up with the default settings
Let It Find the Flags So You Can Focus on the Decision
ImageFlag & Pole Pattern Tp-sl flags the spot where three lower (or higher) highs and lows line up and strong momentum shows up over the last 20 bars, then prints BUY or SELL on the bar that closes through the line. Every check runs on bar close, so you can rely on signals that do not flicker or vanish.
The key to getting the most out of it is understanding that momentum is measured against the close 20 bars before the current bar. On the defaults it catches the momentum snap-back right before a breakout, and stretching Pole Lookback to 40–50 makes it easier to catch the textbook pole-to-flag shape. Decide which one you are after, then tune the settings to match.
Since it does not draw exits, pairing it with a trailing stop like Chande Kroll Stop is the practical way to go. On the 30-minute through daily charts, keeping it on as your dedicated flag scanner for day trading or swing trading should free up more of your screen time for actual decisions.








