Indicator · Pine Script v6 · On the chart

Zen Consecutive Bar Streak

by Zen-Tim

The Zen Consecutive Bar Streak indicator calculates and tracks consecutive directional candle streaks directly on the main price chart.

View on GitHub

GitHub stars29on the repository
Pine versionv6current
Lines of code22
Settings0inputs
LicenceMIT
Last update2 weeks ago14 Oct 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

22 lines of Pine Script v6 from research-kits/Consecutive-Bar-Streaks/indicator/Zen_Consecutive_Bar_Streak_v1_0.txt, published under MIT. Keep the author's credit and licence lines when you reuse it.

Zen_Consecutive_Bar_Streak_v1_0.txt
//@version=6
indicator("Zen Consecutive Bar Streak v1.0", shorttitle="Zen CBS v1.0", overlay=true)

// --- Bar Direction ---
barDir = close > open ? 1 : close < open ? -1 : 0

// --- Streak Count ---
var int streak = 0

if barDir == 1
    streak := streak > 0 ? streak + 1 : 1
else if barDir == -1
    streak := streak < 0 ? streak - 1 : -1
else
    streak := 0

// --- Bar Colour (only colour when streak >= 2 or <= -2) ---
barcolor(streak >= 2 ? color.green : streak <= -2 ? color.red : na)

// --- Data Window Plots ---
plot(barDir, title="Bar Direction", display=display.data_window)
plot(streak, title="Streak",        display=display.data_window)

Overview

Zen Consecutive Bar Streak determines whether each bar is bullish, bearish, or neutral based on its close relative to its open. When two or more consecutive bars close in the same direction, the indicator colors the chart bars green for bullish streaks or red for bearish streaks. Neutral doji candles reset the streak counter to zero. Additionally, it outputs the raw bar direction and streak values to the TradingView data window.

Details

Published by

Zen-Tim on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Candlestick patterns, Trend

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

All Candlestick Patterns

by shunjizhan
292 stars

All Candlestick Patterns detects and highlights a wide range of bullish, bearish, and neutral candlestick patterns directly on the price chart. It features optional trend filtering using either a 50-period simple moving average or a combination of 50-period an

Indicator v4 Candlestick patternsTrend
Updated 3 years ago · None stated GitHub repository of All Candlestick Patterns
257 stars

This indicator detects a large set of classic candlestick patterns and plots colored labels on the price chart. Trend context uses a 50-period simple moving average, or the 50 and 200 averages stacked together, and can be switched off. Users filter bullish, be

Indicator v4 Candlestick patternsTrend
Updated 6 weeks ago · None stated GitHub repository of Snag - All Candlestick Patterns

Five-in-one Strategy

by capissimo
114 stars

Five-in-one Strategy combines five analytical tools into a single price chart overlay: the Dual Thrust Trading Algorithm (DTTA), Semafore, HalfTrend, Nick Rypock Trailing Reverse, and Tweezer or Kangaroo Tail candlestick patterns. It generates trade signals us

Indicator v4 TrendBreakout Repaints
Updated 1 year ago · None stated GitHub repository of Five-in-one Strategy

HA: Heikin-Ashi

by mihakralj
99 stars

This indicator calculates and plots Heikin-Ashi smoothed candlesticks directly on the price chart. It derives the smoothed close from standard price averages and recursively computes the open, high, and low values. The script does not issue trade signals or al

Indicator v6 Candlestick patternsTrend
Updated 4 weeks ago · Apache-2.0 GitHub repository of HA: Heikin-Ashi
55 stars

This indicator overlays on the price chart and provides trend and momentum analysis. It calculates and plots three exponential moving averages with fixed periods of 20, 50, and 200 using yellow, orange, and blue colors respectively. The script also computes th

Indicator v6 TrendOscillators & momentum
Updated 6 months ago · Apache-2.0 GitHub repository of Trend & Momentum Analysis

Confluence Suite

by TamaraKGreen
46 stars

The Confluence Suite indicator draws multiple trading signals and tools directly on the price chart. It generates entry and exit signals based on selected modes and filters, with an AI signal classifier rating quality from 1-4. Additional features include smar

Indicator v5 TrendSMC / ICT / price action
Updated 7 weeks ago · None stated GitHub repository of Confluence Suite

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers