Indicator · Pine Script v5 · On the chart

CSW Sequence Candles Pro

by g-moe· code credited to goodgains

CSW Sequence Candles Pro calculates 5-period EMA-smoothed Open, High, Low, and Close values to render custom sequence candlesticks directly on the main price chart.

View on GitHub

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code71
Settings9inputs
LicenceNone statedfile: MPL-2.0
Last update5 months ago27 May 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

71 lines of Pine Script v5 from Tradingview/csw-sequence-candles-pro.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

csw-sequence-candles-pro.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © goodgains


//@version=5
indicator("CSW Sequence Candles Pro", overlay = true)

// @keywords: smoothed-candlesticks, ema-smoothed-ohlc, sequence-candles, trend-body-fill, bollinger-bands, buy-sell-labels, trend-flip-alerts, momentum-signals, crossover-signals, custom-plotcandle, lower-band-touch, upper-band-touch, trend-direction, signal-debounce, instruction-tooltip, ema-trend-filter, band-squeeze-entry, bar-confirmation, single-signal-filter, plotshape-markers

//--INSTRUCTIONS--//
instructions_tooltip = "• The CSW Sequence Candles are mostly secret sauce that we can't talk too much about. 
 \nThe candles are better variation of the classic Japanese candlesticks. The CSW Sequence Candles should be used 
 \nto keep you on the right side of trend and momentum. \n\nFor best performance turn the default Tradingview candles transparency to 0 so they are hidden entirely."

instructions = input.bool(title='Show Instructions', defval=false, inline='1', tooltip = instructions_tooltip)
if barstate.islast and instructions
    var label instruction_label = na
    if not na(instruction_label[1])
        label.delete(instruction_label[1])
    instruction_label := label.new(bar_index + 5, close, instructions_tooltip, xloc = xloc.bar_index , yloc = yloc.price, color = color.black , style = label.style_label_left, textcolor = color.white, size = size.large, textalign = text.align_left) 
//--INSTRUCTIONS--//

show_signals = input.bool(title = 'Show Signals', defval = true, inline = '2')
show_candle = input.bool(title = 'Show Sequence Candles', defval = true, inline = '3')

color_up = input.color(color.new(#27a69b,0), title='Body', inline='1', group='Bull Candle Settings')
wick_up = input.color(color.new(#27a69b,30), title='Wick', inline='1', group='Bull Candle Settings')
border_up = input.color(color.new(#27a69b,30), title='Border', inline='1', group='Bull Candle Settings')

color_down = input.color(color.new(#b63632,0), title='Body', inline='1', group='Bear Candle Settings')
wick_down = input.color(color.new(#b63632,30), title='Wick', inline='1', group='Bear Candle Settings')
border_down = input.color(color.new(#b63632,30), title='Border', inline='1', group='Bear Candle Settings')

var openMA = 0.00
var highMA = 0.00
var lowMA = 0.00
var closeMA = 0.00

period = 5

openMA := bar_index < period + 1 ? open : ta.ema(open,period)
highMA := bar_index < period + 1 ? high : ta.ema(high,period)
lowMA := bar_index < period + 1 ? low : ta.ema(low,period)
closeMA := bar_index < period + 1 ? close : ta.ema(close,period)

halow = math.min(lowMA, openMA)
hahigh = math.max(highMA, openMA)

candle_ema = ta.ema(closeMA, 20)
body_color = closeMA >= candle_ema ? color_up : color_down
wick_color = closeMA >= candle_ema ? wick_up : wick_down
border_color = closeMA >= candle_ema ? border_up : border_down

var trend_color = 0
trend_color := closeMA >= candle_ema ? 1 : -1

plotcandle(show_candle ? openMA : na , show_candle ? highMA : na ,show_candle ? lowMA : na,show_candle ? closeMA : na, color = body_color, wickcolor = wick_color, bordercolor = border_color, editable = false)

alertcondition(barstate.isconfirmed and body_color != body_color[1] and body_color == color_up, "Trend Chg Bull","Trend Chg Bull")
alertcondition(barstate.isconfirmed and body_color != body_color[1] and body_color == color_down, "Trend Chg Bear","Trend Chg Bear")

[middle, upper, lower] = ta.bb(closeMA, 50, 0.10)

//PLOTTING SIGNAL CODE
//MAIN

buy = barstate.isconfirmed and ta.crossover(trend_color,0) and highMA <= lower
sell = barstate.isconfirmed and ta.crossunder(trend_color,0) and lowMA >= upper

plotshape(show_signals and buy and math.sum(buy == true ? 1 : 0,10) == 1  ? math.min(lowMA,lower) - (syminfo.mintick * 20) : na, style=shape.labelup, editable=false, text= "Buy", textcolor=color.white, location= location.absolute, color=color.new(color_up, 30), size=size.tiny)
plotshape(show_signals and sell and math.sum(sell == true ? 1 : 0,10) == 1  ? math.max(highMA,upper) + (syminfo.mintick * 20) : na, style=shape.labeldown, editable=false, text='Sell', textcolor=color.white, location=location.absolute, color=color.new(color_down, 30), size=size.tiny)

Overview

CSW Sequence Candles Pro determines trend direction by comparing the smoothed close to a 20-period EMA, dynamically coloring the candles for bullish or bearish momentum. Users can customize body, wick, and border colors, toggle candle visibility, display instruction panels, and receive alerts on confirmed trend changes.

Details

Published by

g-moe on GitHub

Code credit

goodgains, as written in the script's header

Draws

On the price chart

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.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Show Instructionsboolfalseinstructions
Show Signalsbooltrueshow_signals
Show Sequence Candlesbooltrueshow_candle
Bodycolorcolor.new(#27a69b,0)color_up
Wickcolorcolor.new(#27a69b,30)wick_up
Bordercolorcolor.new(#27a69b,30)border_up
Bodycolorcolor.new(#b63632,0)color_down
Wickcolorcolor.new(#b63632,30)wick_down
Bordercolorcolor.new(#b63632,30)border_down
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

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

Hanging Man - Bearish

by TWODS-CAPITAL
37 stars

This overlay indicator marks a bearish hanging man candlestick on the price chart. It looks for a small real body sitting in the upper part of the range, a lower shadow at least twice the body, and no upper shadow, and only while an uptrend filter is active. T

Indicator v5 Candlestick patternsTrend
Updated 3 years ago · MIT GitHub repository of Hanging Man - Bearish
29 stars

Zen EMA Pullback Patterns identifies pullback formations relative to an Exponential Moving Average on the price chart. It detects 3-bar pullbacks consisting of three consecutive bearish bars above the EMA or bullish bars below it, as well as 4-bar micro channe

Indicator v6 Moving averagesCandlestick patterns
Updated 2 weeks ago · MIT GitHub repository of Zen EMA Pullback Patterns
15 stars

This indicator plots Bollinger Bands and smoothed HAMA candles on the price chart. It builds each candle from separate moving averages of open, high, low and close, using selectable EMA, SMA or WMA lengths. A simple moving average forms the band basis, and an

Indicator v5 Candlestick patternsMoving averages
Updated 4 months ago · Apache-2.0 GitHub repository of NSDT HAMA Candles with Bollinger Bands

Calculates adaptive arithmetic candles by blending price data with Kaufman Efficiency Ratio smoothing and a linear regression anchor. It measures trend health using a zero-to-hundred Quality Score derived from market efficiency, regression slope, and normalize

Indicator v6 TrendCandlestick patterns
Updated 3 days ago · MIT GitHub repository of Adaptive Arithmetic Candles + Quality Score [WavesUnchained]

More Candlestick patterns scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

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

Compare brokers