Indicator · Pine Script v5 · Own pane

Chaikin Oscillator

by sbtnc

Calculates the Chaikin Oscillator as the difference between a fast and a slow exponential average of the accumulation and distribution line, with defaults of 3 and 10.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code47
Settings7inputs
LicenceMPL-2.0
Last update9 months ago28 Jan 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

47 lines of Pine Script v5 from Chaikin Oscillator.pine, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.

Chaikin Oscillator.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © sbtnc
// Created: 2019-05-19
// Last modified: 2022-04-09
// Version 2.0

// @version=5
indicator("Chaikin Oscillator", "Chaikin Osc", format=format.volume, timeframe="", timeframe_gaps=true)

//--------------------------------------------------------------------
//                               Inputs
//--------------------------------------------------------------------

g_indicator         = "Oscillator"
g_style             = "Style"

t_gradientLength    = "Number of bars used in the oscillator's gradient coloring. The length determines the lookback for the highest positive and lowest negative values."

i_fastLength        = input.int (3,                                         "Fast Length", 1,                                               group=g_indicator)
i_slowLength        = input.int (10,                                        "Slow Length", 1,                                               group=g_indicator)
i_positiveOscColor  = input     (color.green,                               "Oscillator",                           inline="Colors",        group=g_style)
i_negativeOscColor  = input     (color.red,                                 "",                                     inline="Colors",        group=g_style)
i_gradientLength    = input     (20,                                        "Gradient Length",  t_gradientLength,                           group=g_style)
i_positiveBgColor   = input     (color.new(color.green, 90),                "Background",                           inline="Background",    group=g_style)
i_negativeBgColor   = input     (color.new(color.red, 90),                  "",                                     inline="Background",    group=g_style)

//--------------------------------------------------------------------
//                                Logic
//--------------------------------------------------------------------

osc = ta.ema(ta.accdist, i_fastLength) - ta.ema(ta.accdist, i_slowLength)

//--------------------------------------------------------------------
//                          Plotting & styling
//--------------------------------------------------------------------

// The oscillator's gradient uses the lowest and highest values of the last `i_gradientLength` bars
// The bottom value should be negative, the top value should be positive, and the center always situated on the zero level
extremeValue = math.max(ta.highest(osc, i_gradientLength), math.abs(ta.lowest(osc, i_gradientLength)))
c_osc = color.from_gradient(osc, -extremeValue, extremeValue, i_negativeOscColor, i_positiveOscColor)
chaikinOsc = plot(osc, "Oscillator", c_osc)

c_fill = osc > 0 ? i_positiveBgColor : i_negativeBgColor
mid = plot(0, "", editable=false, display=display.none)
fill(mid, chaikinOsc, c_fill)

hline(0, "Zero", color.new(color.gray, 90), hline.style_solid)

Overview

Chaikin Oscillator plots in a separate pane around a zero line, with a colour gradient based on recent extreme values and a fill that changes with the sign. The gradient lookback and colours are adjustable. It needs volume data.

Details

Published by

sbtnc on GitHub

Draws

Separate pane below the 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.

Topics

pine-scriptpinescriptpinescript-indicators

Settings

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

SettingTypeDefaultVariable
Fast Lengthint3i_fastLength
Slow Lengthint10i_slowLength
Oscillatorcolorcolor.greeni_positiveOscColor
i_negativeOscColorcolorcolor.redi_negativeOscColor
Gradient Lengthint20i_gradientLength
Backgroundcolorcolor.new(color.green, 90)i_positiveBgColor
i_negativeBgColorcolorcolor.new(color.red, 90)i_negativeBgColor
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

Money Flow Index

by everget
947 stars

Calculates the standard Money Flow Index (MFI) oscillator alongside an exponential moving average signal line in a separate pane. The script visually highlights trend conditions through dynamic ribbon filling, optional difference histogram bars, and overbought

Indicator v4 Oscillators & momentumVolume
Updated 11 days ago · GPL-3.0 GitHub repository of Money Flow Index

Commitment Gauge

by harryguiacorn
220 stars

This indicator measures directional momentum by evaluating candlestick body proportions and volume over a user-defined lookback window. It computes the ratio of candle body to total range, weights the cumulative value by volume and absolute body size, and dete

Indicator v4 VolumeCandlestick patterns
Updated 1 year ago · None stated GitHub repository of Commitment Gauge

Aggregate Signal

by capissimo
114 stars

This indicator builds an aggregate oscillator in a separate pane. It scales open, high, low, close, and volume into a 0 to 1 range, then averages scaled readings from MACD, a MACD histogram, RSI, stochastic, CCI, momentum, OBV, a directional index, volume-weig

Indicator v4 Oscillators & momentumVolume Repaints
Updated 1 year ago · None stated GitHub repository of Aggregate Signal

This indicator calculates the Bill Williams Market Facilitation Index as the high-low range divided by volume, or zero when volume is zero. It compares the index and volume with the previous bar and assigns one of four zones: green for both rising, fade for bo

Indicator v6 VolumeOscillators & momentum
Updated 4 weeks ago · Apache-2.0 GitHub repository of Bill Williams Market Facilitation Index

PPO ATR Bands

by cryptorife
75 stars

PPO ATR Bands plots a percentage price oscillator in a separate pane. It compares a Hull average of typical price with a volume-weighted exponential average of Parabolic SAR, then scales three true-range bands around the slow average into matching oscillator l

Indicator v4 Oscillators & momentumMoving averages
Updated 3 years ago · GPL-3.0 GitHub repository of PPO ATR Bands

Chaikin Oscillator

by be-thomas
65 stars

Calculates the Chaikin Oscillator by taking the difference between a fast exponential moving average and a slow exponential moving average of the Accumulation/Distribution line. It plots the resulting line in a separate pane alongside a dashed zero reference l

Indicator v4 Oscillators & momentumVolume
Updated 5 days ago · GPL-3.0 GitHub repository of Chaikin Oscillator

More Volume 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