Indicator · Pine Script v4 · Own pane

Close-to-Close % Change Distribution

by everget

This indicator calculates the distribution of close-to-close percentage changes using rate of change on closing prices.

View on GitHub

GitHub stars948on the repository
Pine versionv4older, still runs
Lines of code180
Settings3inputs
LicenceGPL-3.0
Last update10 days ago18 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

180 lines of Pine Script v4 from statistics/close_to_close_percent_change_distribution.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.

close_to_close_percent_change_distribution.pine
//@version=4
// Copyright (c) 2019-present, Alex Orekhov (everget)
// Close-to-Close % Change Distribution script may be freely distributed under the terms of GPL-3.0 license.
study("Close-to-Close % Change Distribution")

reboot = input(title="Reboot ?", defval=false)
width = input(title="Columns Width", defval=12)
space = input(title="Space Between Columns", defval=4)

columnColor = #ffb74d
labelColor = #1e90ff
whiteColor = color.white

roc = roc(close, 1)
total = bar_index + 1

p025 = cum(0 <= roc and roc < 0.25 ? 1 : 0)
plot(100 * p025 / total, offset=(-23 * space), title="0-0.25%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)
plotshape(0, offset=(-floor(23.5 * space)), title="0%", text=" 0% ", color=labelColor, textcolor=whiteColor, style=shape.labelup, location=location.absolute, size=size.small, show_last=1, transp=0, editable=false)

p05 = cum(0.25 <= roc and roc < 0.5 ? 1 : 0)
plot(100 * p05 / total, offset=(-22 * space), title="0.25-0.5%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

p075 = cum(0.5 <= roc and roc < 0.75 ? 1 : 0)
plot(100 * p075 / total, offset=(-21 * space), title="0.5-0.75%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

p1 = cum(0.75 <= roc and roc < 1 ? 1 : 0)
plot(100 * p1 / total, offset=(-20 * space), title="0.75-1%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

p125 = cum(1 <= roc and roc < 1.25 ? 1 : 0)
plot(100 * p125 / total, offset=(-19 * space), title="1-1.25%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)
plotshape(0, offset=(-floor(19.5 * space)), title="1%", text=" 1% ", color=labelColor, textcolor=whiteColor, style=shape.labelup, location=location.absolute, size=size.small, show_last=1, transp=0, editable=false)

p15 = cum(1.25 <= roc and roc < 1.5 ? 1 : 0)
plot(100 * p15 / total, offset=(-18 * space), title="1.25-1.5%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

p175 = cum(1.5 <= roc and roc < 1.75 ? 1 : 0)
plot(100 * p175 / total, offset=(-17 * space), title="1.5-1.75%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

p2 = cum(1.75 <= roc and roc < 2 ? 1 : 0)
plot(100 * p2 / total, offset=(-16 * space), title="1.75-2%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

p225 = cum(2 <= roc and roc < 2.25 ? 1 : 0)
plot(100 * p225 / total, offset=(-15 * space), title="2-2.25%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)
plotshape(0, offset=(-floor(15.5 * space)), title="2%", text=" 2% ", color=labelColor, textcolor=whiteColor, style=shape.labelup, location=location.absolute, size=size.small, show_last=1, transp=0, editable=false)

p25 = cum(2.25 <= roc and roc < 2.5 ? 1 : 0)
plot(100 * p25 / total, offset=(-14 * space), title="2.25-2.5%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

p275 = cum(2.5 <= roc and roc < 2.75 ? 1 : 0)
plot(100 * p275 / total, offset=(-13 * space), title="2.5-2.75%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

p3 = cum(2.75 <= roc and roc < 3 ? 1 : 0)
plot(100 * p3 / total, offset=(-12 * space), title="2.75-3%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

p325 = cum(3 <= roc and roc < 3.25 ? 1 : 0)
plot(100 * p325 / total, offset=(-11 * space), title="3-3.25%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)
plotshape(0, offset=(-floor(11.5 * space)), title="3%", text=" 3% ", color=labelColor, textcolor=whiteColor, style=shape.labelup, location=location.absolute, size=size.small, show_last=1, transp=0, editable=false)

p35 = cum(3.25 <= roc and roc < 3.5 ? 1 : 0)
plot(100 * p35 / total, offset=(-10 * space), title="3.25-3.5%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

p375 = cum(3.5 <= roc and roc < 3.75 ? 1 : 0)
plot(100 * p375 / total, offset=(-9 * space), title="3.5-3.75%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

p4 = cum(3.75 <= roc and roc < 4 ? 1 : 0)
plot(100 * p4 / total, offset=(-8 * space), title="3.75-4%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

p425 = cum(4 <= roc and roc < 4.25 ? 1 : 0)
plot(100 * p425 / total, offset=(-7 * space), title="4-4.25%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)
plotshape(0, offset=(-floor(7.5 * space)), title="4%", text=" 4% ", color=labelColor, textcolor=whiteColor, style=shape.labelup, location=location.absolute, size=size.small, show_last=1, transp=0, editable=false)

p45 = cum(4.25 <= roc and roc < 4.5 ? 1 : 0)
plot(100 * p45 / total, offset=(-6 * space), title="4.25-4.5%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

p475 = cum(4.5 <= roc and roc < 4.75 ? 1 : 0)
plot(100 * p475 / total, offset=(-5 * space), title="4.5-4.75%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

p5 = cum(4.75 <= roc and roc < 5 ? 1 : 0)
plot(100 * p5 / total, offset=(-4 * space), title="4.75-5%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

p525 = cum(5 <= roc and roc < 5.25 ? 1 : 0)
plot(100 * p525 / total, offset=(-3 * space), title="5-5.25%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)
plotshape(0, offset=(-floor(3.5 * space)), title="5%", text=" 5% ", color=labelColor, textcolor=whiteColor, style=shape.labelup, location=location.absolute, size=size.small, show_last=1, transp=0, editable=false)

p55 = cum(5.25 <= roc and roc < 5.5 ? 1 : 0)
plot(100 * p55 / total, offset=(-2 * space), title="5.25-5.5%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

p575 = cum(5.5 <= roc and roc < 5.75 ? 1 : 0)
plot(100 * p575 / total, offset=(-1 * space), title="5.5-5.75%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

p6 = cum(5.75 <= roc and roc < 6 ? 1 : 0)
plot(100 * p6 / total, offset=(0 * space), title="5.75-6%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

p625 = cum(roc >= 6 ? 1 : 0)
plot(100 * p625 / total, offset=(1 * space), title="≥ 6%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)
plotshape(0, offset=(floor(0.5 * space)), title="≥ 6%", text=" ≥ 6% ", color=labelColor, textcolor=whiteColor, style=shape.labelup, location=location.absolute, size=size.small, show_last=1, transp=0, editable=false)

//------------------------------------------------------------------------------

n025 = cum(-0.25 < roc and roc < 0 ? 1 : 0)
plot(100 * n025 / total, offset=(-24 * space), title="-0-0.25%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

n05 = cum(-0.5 < roc and roc <= -0.25 ? 1 : 0)
plot(100 * n05 / total, offset=(-25 * space), title="-0.25-0.5%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

n075 = cum(-0.75 < roc and roc <= -0.5 ? 1 : 0)
plot(100 * n075 / total, offset=(-26 * space), title="-0.5-0.75%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

n1 = cum(-1 < roc and roc <= -0.75 ? 1 : 0)
plot(100 * n1 / total, offset=(-27 * space), title="-0.75-1%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

n125 = cum(-1.25 < roc and roc <= -1 ? 1 : 0)
plot(100 * n125 / total, offset=(-28 * space), title="-1-1.25%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)
plotshape(0, offset=(-floor(27.5 * space)), title="-1%", text=" -1% ", color=labelColor, textcolor=whiteColor, style=shape.labelup, location=location.absolute, size=size.small, show_last=1, transp=0, editable=false)

n15 = cum(-1.5 < roc and roc <= -1.25 ? 1 : 0)
plot(100 * n15 / total, offset=(-29 * space), title="-1.25-1.5%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

n175 = cum(-1.75 < roc and roc <= -1.5 ? 1 : 0)
plot(100 * n175 / total, offset=(-30 * space), title="-1.5-1.75%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

n2 = cum(-2 < roc and roc <= -1.75 ? 1 : 0)
plot(100 * n2 / total, offset=(-31 * space), title="-1.75-2%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

n225 = cum(-2.25 < roc and roc <= -2 ? 1 : 0)
plot(100 * n225 / total, offset=(-32 * space), title="-2-2.25%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)
plotshape(0, offset=(-floor(31.5 * space)), title="-2%", text=" -2% ", color=labelColor, textcolor=whiteColor, style=shape.labelup, location=location.absolute, size=size.small, show_last=1, transp=0, editable=false)

n25 = cum(-2.5 < roc and roc <= -2.25 ? 1 : 0)
plot(100 * n25 / total, offset=(-33 * space), title="-2.25-2.5%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

n275 = cum(-2.75 < roc and roc <= -2.5 ? 1 : 0)
plot(100 * n275 / total, offset=(-34 * space), title="-2.5-2.75%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

n3 = cum(-3 < roc and roc <= -2.75 ? 1 : 0)
plot(100 * n3 / total, offset=(-35 * space), title="-2.75-3%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

n325 = cum(-3.25 < roc and roc <= -3 ? 1 : 0)
plot(100 * n325 / total, offset=(-36 * space), title="-3-3.25%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)
plotshape(0, offset=(-floor(35.5 * space)), title="-3%", text=" -3% ", color=labelColor, textcolor=whiteColor, style=shape.labelup, location=location.absolute, size=size.small, show_last=1, transp=0, editable=false)

n35 = cum(-3.5 < roc and roc <= -3.25 ? 1 : 0)
plot(100 * n35 / total, offset=(-37 * space), title="-3.25-3.5%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

n375 = cum(-3.75 < roc and roc <= -3.5 ? 1 : 0)
plot(100 * n375 / total, offset=(-38 * space), title="-3.5-3.75%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

n4 = cum(-4 < roc and roc <= -3.75 ? 1 : 0)
plot(100 * n4 / total, offset=(-39 * space), title="-3.75-4%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

n425 = cum(-4.25 < roc and roc <= -4 ? 1 : 0)
plot(100 * n425 / total, offset=(-40 * space), title="-4-4.25%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)
plotshape(0, offset=(-floor(39.5 * space)), title="-4%", text=" -4% ", color=labelColor, textcolor=whiteColor, style=shape.labelup, location=location.absolute, size=size.small, show_last=1, transp=0, editable=false)

n45 = cum(-4.5 < roc and roc <= -4.25 ? 1 : 0)
plot(100 * n45 / total, offset=(-41 * space), title="-4.25-4.5%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

n475 = cum(-4.75 < roc and roc <= -4.5 ? 1 : 0)
plot(100 * n475 / total, offset=(-42 * space), title="-4.5-4.75%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

n5 = cum(-5 < roc and roc <= -4.75 ? 1 : 0)
plot(100 * n5 / total, offset=(-43 * space), title="-4.75-5%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

n525 = cum(-5.25 < roc and roc <= -5 ? 1 : 0)
plot(100 * n525 / total, offset=(-44 * space), title="-5-5.25%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)
plotshape(0, offset=(-floor(43.5 * space)), title="-5%", text=" -5% ", color=labelColor, textcolor=whiteColor, style=shape.labelup, location=location.absolute, size=size.small, show_last=1, transp=0, editable=false)

n55 = cum(-5.5 < roc and roc <= -5.25 ? 1 : 0)
plot(100 * n55 / total, offset=(-45 * space), title="-5.25-5.5%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

n575 = cum(-5.75 < roc and roc <= -5.5 ? 1 : 0)
plot(100 * n575 / total, offset=(-46 * space), title="-5.5-5.75%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

n6 = cum(-6 < roc and roc <= -5.75 ? 1 : 0)
plot(100 * n6 / total, offset=(-47 * space), title="-5.75-6%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)

n625 = cum(roc <= -6 ? 1 : 0)
plot(100 * n625 / total, offset=(-48 * space), title="≤ -6%", style=plot.style_histogram, linewidth=width, color=columnColor, show_last=1, transp=0, editable=false)
plotshape(0, offset=(-floor(47.5 * space)), title="≤ -6%", text=" ≤ -6% ", color=labelColor, textcolor=whiteColor, style=shape.labelup, location=location.absolute, size=size.small, show_last=1, transp=0, editable=false)

Overview

Close-to-Close % Change Distribution bins percentage changes into intervals of 0.25 percent increments from negative to positive values and plots a normalized cumulative histogram in a separate pane. Columns represent percentages of bars falling into each bin. Inputs adjust column width, spacing, and provide a reboot option to reset cumulative counts. Labels mark reference points at 0 percent, 1 percent, and 2 percent.

Details

Published by

everget on GitHub

Type

Indicator, Pine Script v4

Draws

Separate pane below the chart

Category

Volatility & bands

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

pinepinescripttechnical-indicatorsindicatorsoscillatorbandsaveragetradingviewindicatormoving-average

Settings

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

SettingTypeDefaultVariable
Reboot ?boolfalsereboot
Columns Widthint12width
Space Between Columnsint4space
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

This indicator plots a Supertrend-based trend-following setup in a separate pane and skips conditions it treats as a sideways market. A volatility range is built from an ATR value, with RMA, SMA, EMA, or WMA smoothing, or from a fixed point distance. Optional

Indicator v5 TrendVolatility & bands
Updated 1 year ago · MPL-2.0 GitHub repository of Trend Following Setup - Sideways Market Skipper
330 stars

This indicator plots candle range and open-to-close movement as percentages in a separate pane. Range is the high-low difference divided by the low, and change is the close-open difference divided by the open. Both series draw as columns. Teal columns show ran

Indicator v5 Volatility & bands
Updated 2 months ago · None stated GitHub repository of Percent & Volatility [Alorse]

Mojito v3 Strategy

by namuan
318 stars

The Mojito v3 Strategy indicator evaluates volatility term structure by calculating the ratio between front-month and second-month VIX futures contracts. It smooths this ratio using a configurable median filter and compares the result against user-defined uppe

Indicator v5 Volatility & bands
Updated 2 months ago · MIT GitHub repository of Mojito v3 Strategy

Function - Logistic Equation

by ricardosantos79
261 stars

Calculates dynamic modeling values by applying a mathematical logistic differential equation to price change over a specified lookback length. It measures price momentum relative to the recent high-low price range. The script plots positive and negative logist

Indicator v5 Oscillators & momentumVolatility & bands
Updated 4 years ago · None stated GitHub repository of Function - Logistic Equation

MACD-V

by harryguiacorn
219 stars

MACD-V is a volatility-normalized momentum indicator based on research by Alex Spiroglou. It calculates the standard MACD histogram and normalizes it by dividing by the Average True Range (ATR). Plotted in a separate pane as a colored histogram, it includes us

Indicator v5 Oscillators & momentumVolatility & bands
Updated 1 year ago · None stated GitHub repository of MACD-V
218 stars

This indicator detects a Bollinger Band squeeze when the bands sit inside Keltner Channels, marking low volatility. It plots red dots during a squeeze and green dots when the bands are outside, in a separate pane. An optional histogram shows momentum as the cl

Indicator v6 Volatility & bandsOscillators & momentum
Updated 3 months ago · None stated GitHub repository of Bollinger Band Squeeze Detector

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