CBc BullFlag Scalping — bull flag setups
Marks the latest bull flag — a sharp rise, then a calm pause — with its entry, stop and target lines.
About
CBc BullFlag Scalping looks for a bull flag. That is a sharp rise in price, then a short, calm pause. It draws the latest one, with an entry, a stop and a target.
To find it, click Indicators at the top of a KAGAMI chart. It is in the KAGAMI group, named CBc BullFlag Scalping. See Indicators.
It comes with KAGAMI Pro. Without KAGAMI Pro, its name ends in · Pro in the list. If you add it, nothing is drawn — a box says it comes with KAGAMI Pro.
What you see on the chart
A chart shows the price as candles. A candle (also called a bar) is one slice of time. The timeframe is how long each slice is, for example 15 minutes.
It draws only the latest bull flag it found. That one may be many candles back. On some charts, nothing is drawn. A bull flag has two parts:
- The pole — the price shoots up over a few candles, often on busy trading.
- The pullback — the price then rests or dips a little. It does not make a new high.
When it finds one, it draws four short flat lines. Each line has a price tag at its right end.
- ENTRY — a thick indigo (blue-purple) line. It sits just above the high of the latest resting candle. Its tag reads like ENTRY 105.01 · 3.0R.
- STOP — a red line at the lowest price of the pause. Its tag reads like STOP 104.00.
- TARGET — a green line, usually at the highest price of the day. Its tag reads like TARGET 108.00.
- 50% — a grey dotted line halfway down the pole. Its tag reads like 50% 103.00.
The number with an R compares two distances. Take the distance from the entry up to the target. Divide it by the distance from the entry down to the stop. 3.0R means the first distance is three times the second. See R in Words we use.
While the pause goes on, the lines move. They start at the newest resting candle. The ENTRY line can step down with each new candle.
When a candle reaches the ENTRY price, two things happen:
- A small indigo arrow pointing up marks that candle, at the entry price.
- The tag changes from ENTRY to BUY.
BUY only names what happened: the price reached the entry. It is not advice.
Sometimes the lines look faded, partly see-through. That means the setup broke one of its rules. The reason is on the ENTRY tag:
- < 2:1 — the target is too close. It is less than twice as far as the stop.
- heavy volume — the pause traded too busily. Volume is how much was traded.
If the price then reaches a faded entry, the tag reads SKIP instead of BUY. No arrow is drawn.
Only the latest setup stays on the chart. A new one replaces it.
You cannot move or edit these lines. They are not saved. To hide them, hide the indicator. To remove them, remove the indicator.
How traders often read it
- Many traders read the pole as a burst of strong buying.
- Many traders read a quiet pause on lighter volume as calm, not panic.
- Some traders watch the 50% line. A pause that falls below it is often read as weak.
- Some traders watch whether the price breaks above the pause, at the ENTRY line.
- Many traders compare the R number between setups. A higher R means more room to the target than to the stop.
- Some traders use the faded tags to see which rule a setup missed.
An indicator only describes past prices. It cannot tell you what the price will do next.
The settings
KAGAMI shows no settings for this indicator. You cannot change how it works. It always uses fixed values. The ones that matter most:
- The pole must rise at least 2.5 times the usual candle size. The usual size is the average size of the last 14 candles.
- The pole must have at least 3 green candles. A green candle closed higher than it opened.
- The pole is looked for within the last 10 candles.
- The pause must not fall below the halfway point of the pole.
- Volume is checked only when the chart has volume.
- The target is the highest price of the day so far.
- The target must be twice as far from the entry as the stop, or more. If not, the setup is faded.
- The lines are 10 candles long, or 20 candles on seconds charts.
- Only one setup, the latest, stays on the chart.
When it can mislead
- The newest candle. Nothing is judged until a candle closes. The price can reach the entry in mid-candle. The arrow and the BUY tag appear only when that candle closes.
- The moving target. After a BUY, the target line climbs with each new high. Afterwards, it can look like the target was always that high. It was not.
- Choppy markets. When prices jump up and down, many setups appear and then vanish.
- Too few candles. It needs more than 14 candles before it can find anything.
- Charts with no volume. Some markets show no volume. Then the volume rules are simply skipped.
- The market close. For stocks, a waiting setup is removed when the next day starts.
- Only the latest one. Older setups disappear when a new one appears. You cannot look back over them.
- The R number is a sketch. Real prices can jump past the entry or the stop. A gap overnight is one example.
- Daily charts. On daily charts and up, the target is the top of the pole.
Charts are for learning, not advice. Read our Risk Disclaimer.
An example
Open NASDAQ:AAPL and choose the 15-minute timeframe. Add CBc BullFlag Scalping. The prices below are made up.
- Say the price climbs from 100 to 106 over five candles, on busy trading. Most of those candles are green.
- Say the usual candle size is 2. The rise of 6 is more than 2.5 × 2 = 5. So it counts as a pole.
- The next candle does not make a new high. Its high is 105 and its low is 104.
- Halfway down the pole is 103. The low of 104 stays above it. So the setup is born.
- Four lines appear. ENTRY is at 105.01, one cent above the high of 105. STOP is at 104.00. The 50% line is at 103.00.
- Say the day's high was 108 earlier on. So TARGET is at 108.00.
- Up to the target is about 3. Down to the stop is about 1. The tag reads ENTRY 105.01 · 3.0R.
- The next candle has a high of 104.80 and a low of 103.50. It is still a pause.
- The lines move to this candle. ENTRY steps down to 104.81. STOP moves to 103.50. The tag now reads ENTRY 104.81 · 2.4R.
- The next candle rises to 106. When it closes, an arrow marks it. The tag reads BUY 104.81 · 2.4R.
Later candles above 108 would lift the TARGET line to their new high.
Technical details
This part is for readers who want the exact rules. KAGAMI's servers compute everything below on the chart's own symbol and timeframe. The page only draws the result.
The calculation
The rules run on every closed candle, oldest first, in this order. They follow the original Pine script.
- The day's high. The highest high of the trading day so far, this candle included.
- The trailing target. If a setup has fired (BUY), its target may move up. See The trailing target.
- The live setup. A setup that is still waiting is removed, fires, is skipped, or gains one more pullback candle. See The pullback.
- A new setup. If no setup was waiting at the start of this candle, the candle is tested as the first pullback candle after a pole. See The pole.
The building blocks:
- Tick — the symbol's smallest price step (see The tick). A candle "makes a new high" only when its high is more than half a tick above the high it is compared with.
- ATR (14) — the average true range, Wilder's method. True range = the largest of
high − low,|high − previous close|and|low − previous close|; on the first candle it ishigh − low. The first ATR is the simple average of the first 14 true ranges. After that,ATR = (true range + 13 × previous ATR) ÷ 14. - Average volume — the simple average volume of the last 20 candles.
- Green candle — a candle whose close is above its open.
Inputs
KAGAMI shows no inputs for this indicator. It always uses these fixed values, which are the original script's defaults:
| Original input | Value in KAGAMI | What it does |
|---|---|---|
| Pole move (× ATR) | 2.5 | The smallest pole move, in multiples of ATR (14) |
| Green candles in the pole | 3 | The fewest green candles in the pole |
| Pole within (bars) | 10 | How far back the pole low is looked for |
| Deepest pullback (% of the pole) | 50 | The level the pullback must hold |
| Volume rules | Auto | Volume checks only when the chart has volume |
| Pole volume (× average) | 1.5 | The pole's volume against the 20-candle average before it |
| Pullback volume (× pole) | 1.0 | The most the pullback may trade, against the pole |
| Target | High of day | The day's high, never below the pole high |
| Minimum reward to risk | 2.0 | Below it the setup is faded and marked SKIP |
| Line length on seconds charts (bars) | 20 | Line length on seconds charts |
| Line length on minute charts and up (bars) | 10 | Line length on 1 minute and up |
| Setups kept | 1 | Only the latest setup stays |
| Tag size | Small | The size of the tag text |
| Entry, Stop, Target, 50% colours | #6366F1, #EF4444, #10B981, #9CA3AF | Each line and its tag |
Not offered in KAGAMI:
- every input above (you cannot change them);
- the optional Scanner group: Price band (setups only between 2 and 20) and Show relative volume (a small panel, today's volume against the 50-day average). Both are off by default in the original script, and KAGAMI does not have them.
The pole
The candle being tested is called C. The candle just before it is the pole high candle.
- C must not make a new high:
high of C ≤ pole high + half a tick. - Walk back from the candle 2 places before C to the candle 10 places before C. Stop early, before any candle whose high is more than half a tick above the pole high, before the floor (below), or at the start of the data.
- The pole low is the lowest low among the pole high candle and the candles walked. If two candles share that low, the later one counts.
- The pole is every candle from the pole low candle to the pole high candle.
- The pole needs at least 3 green candles.
- The move is
pole high − pole low. It must be at least2.5 × ATR, with the ATR read on the pole high candle. If that ATR does not exist yet or is 0, no setup is made. - The pole volume check (when the volume rules are on): the pole's average volume must be at least
1.5 ×the average volume of the 20 candles that end just before the pole low candle. If that average does not exist yet, the check fails. - The 50% level is
pole high − 50% × move. The low of C must be at or above it.
When every check passes, the setup is born on C. C is its first pullback candle.
The floor. A pole never reaches back past the floor, and the pole high candle itself must be at or after it. The floor moves to:
- the pullback candle with the lowest low, in the last setup whose trigger traded (BUY or SKIP);
- the candle that removed the last setup by falling below its 50% level;
- the first candle after a market close.
So each new pole is measured from its own dip. Only one setup is live at a time.
The pullback
On each closed candle after the setup is born, KAGAMI checks, in this order:
- Removed — the candle is the first after a market close, or its low is below the 50% level. The setup is deleted from the chart at once. A candle that both breaks the 50% level and trades above the trigger is read the safe way: removed, no BUY.
- Triggered — the candle's high is more than half a tick above the trigger. The trigger is the high of the latest pullback candle before this one. If the setup meets every rule, it fires: the tag reads BUY and the arrow is drawn. If not, it is skipped: the tag reads SKIP, still faded. Either way the ENTRY, STOP and 50% lines freeze where they are.
- One more pullback candle — otherwise. If its low is below the stop, the stop moves down to it. Its high becomes the new trigger. Entry, target, reward to risk and the volume check are measured again. The lines move to start at this candle.
Volume rules
- The rules are on when the volume of the last 20 candles adds up to more than 0. Otherwise they are off. This is the original script's Auto mode, checked on every candle.
- When they are off, both volume checks pass.
- Pole volume: see step 7 in The pole.
- Pullback volume: the average volume of the pullback candles so far (the first one included) must be at most
1.0 ×the pole's average volume. - A heavy pullback does not remove the setup. It fades it and adds heavy volume to the ENTRY tag.
Entry, stop and target
- Entry =
trigger + 1 tick. - Stop = the lowest low of the pullback so far, from the first pullback candle to the latest.
- Target = the larger of the day's high so far and the pole high. On daily, weekly and monthly charts each candle is its own day, so the target is, in practice, the pole high.
- Reward to risk
R = (target − entry) ÷ (entry − stop). Ifentry − stopis 0 or less, R is 0. - Meets every rule =
R ≥ 2.0and the pullback volume check passes. - The tag shows R rounded to one decimal (halves round up), never below 0.0.
The trading day starts with:
- US stocks: the first candle of the New York calendar date;
- crypto: 00:00 UTC;
- FX and metals: 17:00 New York.
A market close is the first candle of a new trading day that starts more than four candle lengths after the candle before it. Stocks have one every night. FX has one at the weekend. Crypto trades through midnight, so it rarely has one. Daily, weekly and monthly charts never have one.
The trailing target
After a BUY, the target follows the price up:
- On the BUY candle and on every later closed candle, a high above the target lifts the target to that high. Its line then starts at that candle and runs the usual length.
- The target never moves down.
- It stops at the first candle whose low is at or below the stop, at a market close, or when a newer setup is born.
- When it stops, all lines stay where they were.
The lines and tags
| Line | Colour | Width and style | Tag text |
|---|---|---|---|
| ENTRY | indigo #6366F1 | 2 px, solid | ENTRY 105.01 · 3.0R, then BUY … or SKIP … |
| STOP | soft red #EF4444 | 1 px, solid | STOP 104.00 |
| TARGET | emerald #10B981 | 1 px, solid | TARGET 108.00 |
| 50% | muted grey #9CA3AF | 1 px, dotted | 50% 103.00 |
- Length. ENTRY, STOP and 50% start at the latest pullback candle (frozen at the last one once the setup fires or is skipped). TARGET starts there too, or at the candle that last lifted it. Each line is 10 candles long, the start candle included. On seconds charts it is 20 candles. A line can reach past the newest candle, into the empty space on the right.
- Tags. Each tag sits at its line's right end, in the line's colour, in a small bubble that points at the end of the line. The text is white (
#FFFFFF) or near-black (#111827), whichever stands out more on the tag's colour. So ENTRY has white text and the other three have near-black text. - Extra text on the ENTRY tag.
< 2:1when R is below 2.0.· heavy volumewhen the pullback volume check fails. Both can show. - Faded. A setup that does not meet every rule has its lines and tags 60% see-through. The tag text stays solid.
- The BUY arrow. An indigo (
#6366F1) arrow pointing up, its tip at the entry price, on the candle that fired. - Prices on the tags are rounded to the tick (halves round up), with the tick's number of decimals.
- Kept. Only the latest setup is drawn: waiting, fired or skipped. A removed setup is deleted.
The tick
- US stocks: 0.01. When the newest close is below 1, it is 0.0001 for the whole chart.
- FX and metals: one unit of the instrument's own price precision (for example 0.00001 with 5 decimals).
- Crypto: one unit of the chart's price scale. That is 0.0001 when the highest price in the data is below 1, 0.001 when it is below 10, and 0.01 otherwise.
When values change
- Closed candles only. A candle is judged once its start time plus its length has passed. The forming candle is never judged. Nothing appears or moves while a candle forms.
- The BUY shows at the candle's close, even if the price crossed the entry earlier in that candle.
- History reads like the live chart. The same rules run on past candles, so a past setup looks as it did live.
- When the page redraws. The page asks KAGAMI's servers for the drawings when you add the indicator, when the symbol or timeframe changes, when a new candle appears, and every 60 seconds while the page is open. On very short timeframes it redraws at most once every 2 seconds.
- What can change on screen. A waiting setup's lines move with each pullback candle. A trailing target moves up. A removed setup disappears. A new setup replaces the old one. A fired or skipped setup otherwise stays as it is.
- How much history. The rules run over the latest candles KAGAMI reads for the chart: up to 2,000 candles of its timeframe, fewer for some markets. On seconds charts that is at most the last 24 hours. As new candles arrive, the oldest drop out. Very rarely, this can change a setup near the start of that window.
- Not saved. The drawings are made again each time you open or reload the chart.
Timeframes
- Seconds charts (crypto only: 1, 5, 10, 15 and 30 seconds): lines are 20 candles long. A pause of more than four candles right at 00:00 UTC counts as a market close.
- Minute and hour charts: lines are 10 candles long. The day's high resets at the start of each trading day. A setup still waiting at a market close is removed.
- Daily, weekly and monthly charts: each candle is its own day. The target falls back to the pole high, and there is no market close.
- US stocks use the New York calendar day. Crypto uses the UTC day. FX and metals use the day that starts at 17:00 New York.
- When a candle counts as closed: after its full length from its start time. On a daily US stock chart that is 24 hours after the candle's start time, which is later than the 16:00 close. On a monthly chart a month counts as 30 days.
Differences from the original Pine script
KAGAMI's version follows the original script's rules step by step. These are the differences:
- No settings. Every input is fixed at its default (see Inputs).
- No alert. The original script can raise a "CBc BF: BUY" alert inside a candle. KAGAMI's indicators raise no alerts.
- No data window values. The original shows Entry, Stop, Target and Reward to risk for each candle in TradingView's data window. KAGAMI does not.
- No hover text. The original's tags and triangle explain their rule when you point at them. KAGAMI's drawings have no hover text.
- No relative-volume panel and no price band. Both are optional and off in the original.
- The tag shape. The original's tag is centred on its line. KAGAMI's tag is a bubble whose point sits on the line's right end, so it sits just above the line.
- The BUY mark. The original draws a small triangle. KAGAMI draws an arrow pointing up, its tip at the entry.
- The tick. The original uses the symbol's own minimum price step from TradingView. KAGAMI uses the rule in The tick.
- The trading day. The original starts the day with the symbol's daily session on TradingView. KAGAMI uses a fixed day start per market (see Entry, stop and target).
- How much history. The original runs on all the candles TradingView loads. KAGAMI runs on up to 2,000 candles.
- Closed daily, weekly and monthly candles. TradingView confirms a candle at the session's close. KAGAMI waits for the candle's full length from its start time (see Timeframes).
- Timeframes. The original is described for 10 seconds up to 1 day. KAGAMI also draws it on 1- and 5-second crypto charts (with the seconds line length) and on weekly and monthly charts.
Edge cases
- Too few candles. If the chart has fewer than 3 closed candles, nothing is drawn. No setup can be born before the 15th candle, because the ATR needs 14 candles.
- The first 19 candles. There is no 20-candle volume total yet, so the volume rules are off there.
- Flat prices. If the ATR is 0, no setup is born.
- No volume. If the last 20 candles traded 0 in total, the volume rules are off for that candle.
- A candle that does both. It breaks the 50% level and trades above the trigger: removed, no BUY.
- Touching the stop. A low exactly at the stop ends the trailing target.
- R just under 2. R is checked before rounding. A setup at 1.97 shows 2.0R < 2:1 and is faded.
- Missing candles. Lines count candles, not clock time. A stretch with no candles is skipped over.
- Cheap stocks. The tick for a stock follows its newest close. If it is below 1, every price on the tags uses four decimals.
- Stock splits. KAGAMI's stock prices are not adjusted for splits. A split can make the ATR and the day's high unusual for a while.
- Missing data. If KAGAMI cannot get the candles, nothing is drawn.