Indicator · Pine Script v6 · Own pane

PriceCatch Stock Range Binning

by PriceCatch

PriceCatch Stock Range Binning calculates the distribution of daily percentage price changes over a configurable historical lookback period, up to 2,000 trading days.

View on GitHub

GitHub stars2on the repository
Pine versionv6current
Lines of code131
Settings7inputs
LicenceMPL-2.0
Last update1 year ago24 Apr 2025

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

131 lines of Pine Script v6 from Pinescripts/PriceCatch Stock Range Binning-v1.pinescript, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.

PriceCatch Stock Range Binning-v1.pinescript
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PriceCatch
// You must credit PriceCatch if you modify this code or use it in your scripts.

//@version=6
indicator("PriceCatch Stock Range Binning-v1", max_bars_back = 4000)
if not timeframe.isdaily
    runtime.error("Please change to daily timeframe to get the results.")


nlen = input.int(2000, title="No.of Trading Days",minval=100)
var int minus20 = na 
var int minus15 = na 
var int minus10 = na 
var int minus05 = na 
var int minus03 = na 
var int minus01 = na 
var int zero0 = na 
var int plus20 = na 
var int plus15 = na 
var int plus10 = na 
var int plus5 = na 
var int plus3 = na 
var int plus1 = na

plus20 := 0
plus15 := 0
plus10 := 0
plus5 := 0
plus3 :=0
plus1 := 0

minus01 := 0
minus03 := 0
minus05 := 0
minus10 := 0
minus15 := 0
minus20 := 0

// do it for a range of 4000 trading days.
chngprcnt = request.security("","",ta.roc(close,1))
for i = 0 to nlen
    if chngprcnt[i] > 15 and chngprcnt[i] <= 20
        plus20 += 1
    if chngprcnt[i] > 10 and chngprcnt[i] <= 15
        plus15 += 1
    if chngprcnt[i] > 5 and chngprcnt[i] <= 10
        plus10 += 1
    if chngprcnt[i] > 3 and chngprcnt[i] <= 5
        plus5 += 1
    if chngprcnt[i] > 1 and chngprcnt[i] <= 3
        plus3 += 1
    if chngprcnt[i] > 0 and chngprcnt[i] <= 1
        plus1 += 1
    if chngprcnt[i] > -1 and chngprcnt[i] <= 0
        minus01 += 1
    if chngprcnt[i] > -3 and chngprcnt[i] <= -1
        minus03 += 1
    if chngprcnt[i] > -5 and chngprcnt[i] <= -3
        minus05 += 1
    if chngprcnt[i] > -10 and chngprcnt[i] <= -5
        minus10 += 1
    if chngprcnt[i] > -15 and chngprcnt[i] <= -10
        minus15 += 1
    if chngprcnt[i] > -20 and chngprcnt[i] <= -15
        minus20 += 1





// print results
// Volume Info Panel Section
tblPos = input.string(title = 'Position on Chart', defval = 'Bottom Center', options = ['Top Left', 'Top Right', 'Bottom Left', 'Bottom Center', 'Bottom Right', 'Middle Left', 'Middle Right'], group = 'Information Panel')
tblposition = tblPos == 'Top Left' ? position.top_left : tblPos == 'Top Right' ? position.top_right : tblPos == 'Bottom Left' ? position.bottom_left : tblPos == 'Bottom Center' ? position.bottom_center : tblPos == 'Bottom Right' ? position.bottom_right : tblPos == 'Middle Left' ? position.middle_left : position.middle_right

tblBorderColor = input(title = 'Border Color', defval = #636363, group = 'Information Panel')

title1_bgColor = input(title = 'Title Background', defval = #004074, group = 'Information Panel')
title1_textColor = input(title = 'Title Text', defval = #7AC3ff, group = 'Information Panel')

_upBgColor = input(title = 'Up Background Color', defval = #000000, group = 'Information Panel')
_upTextColor = input(title = 'Up Text Color', defval = #daeefe, group = 'Information Panel')


var table resultsTable = na

resultsTable := table.new(position = tblposition, columns = 2, rows = 13, bgcolor = #ffffff, border_width = 0, frame_color = tblBorderColor, frame_width = 2)

_info_text_color = _upTextColor
_info_bg_color = _upBgColor



table.cell(resultsTable, column = 0, row = 0, text = "Change% Band", text_color = title1_textColor, text_halign = text.align_left, text_valign = text.align_center, bgcolor = title1_bgColor, text_size = size.normal, text_font_family = font.family_monospace)
table.cell(resultsTable, column = 1, row = 0, text = "Occurrence\nNo.of Times", text_color = title1_textColor, text_halign = text.align_right, text_valign = text.align_center, bgcolor = title1_bgColor, text_size = size.normal, text_font_family = font.family_monospace)
table.cell(resultsTable, column = 0, row = 1, text = "15 - 20", text_color = _upTextColor, text_halign = text.align_left, text_valign = text.align_center, bgcolor = _upBgColor, text_size = size.normal, text_font_family = font.family_monospace)
table.cell(resultsTable, column = 1, row = 1, text = str.tostring(plus20, '#####'), text_color = _upTextColor, text_halign = text.align_right, text_valign = text.align_center, bgcolor = _upBgColor, text_size = size.normal, text_font_family = font.family_monospace)
table.cell(resultsTable, column = 0, row = 2, text = "10 - 15", text_color = _upTextColor, text_halign = text.align_left, text_valign = text.align_center, bgcolor = _upBgColor, text_size = size.normal, text_font_family = font.family_monospace)
table.cell(resultsTable, column = 1, row = 2, text = str.tostring(plus15, '#####'), text_color = _upTextColor, text_halign = text.align_right, text_valign = text.align_center, bgcolor = _upBgColor, text_size = size.normal, text_font_family = font.family_monospace)


table.cell(resultsTable, column = 0, row = 3, text = '5 - 10', text_color = _upTextColor, text_halign = text.align_left, text_valign = text.align_center, bgcolor = _upBgColor, text_size = size.normal, text_font_family = font.family_monospace)
table.cell(resultsTable, column = 1, row = 3, text = str.tostring(plus10, '#####'), text_color = _upTextColor, text_halign = text.align_right, text_valign = text.align_center, bgcolor = _upBgColor, text_size = size.normal, text_font_family = font.family_monospace)
table.cell(resultsTable, column = 0, row = 4, text = '3 - 5', text_color = _upTextColor, text_halign = text.align_left, text_valign = text.align_center, bgcolor = _upBgColor, text_size = size.normal, text_font_family = font.family_monospace)
table.cell(resultsTable, column = 1, row = 4, text = str.tostring(plus5, '#####'), text_color = _upTextColor, text_halign = text.align_right, text_valign = text.align_center, bgcolor = _upBgColor, text_size = size.normal, text_font_family = font.family_monospace)
table.cell(resultsTable, column = 0, row = 5, text = '1 - 3', text_color = _upTextColor, text_halign = text.align_left, text_valign = text.align_center, bgcolor = _upBgColor, text_size = size.normal, text_font_family = font.family_monospace)
table.cell(resultsTable, column = 1, row = 5, text = str.tostring(plus3, '#####'), text_color = _upTextColor, text_halign = text.align_right, text_valign = text.align_center, bgcolor = _upBgColor, text_size = size.normal, text_font_family = font.family_monospace)

table.cell(resultsTable, column = 0, row = 6, text = '0 - 1', text_color = _upTextColor, text_halign = text.align_left, text_valign = text.align_center, bgcolor = _upBgColor, text_size = size.normal, text_font_family = font.family_monospace)
table.cell(resultsTable, column = 1, row = 6, text = str.tostring(plus1), text_color = _upTextColor, text_halign = text.align_right, text_valign = text.align_center, bgcolor = _upBgColor, text_size = size.normal, text_font_family = font.family_monospace)

table.cell(resultsTable, column = 0, row = 7, text = '-1 - 0', text_color = _upTextColor, text_halign = text.align_left, text_valign = text.align_center, bgcolor = _upBgColor, text_size = size.normal, text_font_family = font.family_monospace)
table.cell(resultsTable, column = 1, row = 7, text = str.tostring(minus01), text_color = _upTextColor, text_halign = text.align_right, text_valign = text.align_center, bgcolor = _upBgColor, text_size = size.normal, text_font_family = font.family_monospace)

table.cell(resultsTable, column = 0, row = 8, text = '-3 - -1', text_color = _upTextColor, text_halign = text.align_left, text_valign = text.align_center, bgcolor = _upBgColor, text_size = size.normal, text_font_family = font.family_monospace)
table.cell(resultsTable, column = 1, row = 8, text = str.tostring(minus03), text_color = _upTextColor, text_halign = text.align_right, text_valign = text.align_center, bgcolor = _upBgColor, text_size = size.normal, text_font_family = font.family_monospace)

table.cell(resultsTable, column = 0, row = 9, text = '-5 - -3', text_color = _upTextColor, text_halign = text.align_left, text_valign = text.align_center, bgcolor = _upBgColor, text_size = size.normal, text_font_family = font.family_monospace)
table.cell(resultsTable, column = 1, row = 9, text = str.tostring(minus05), text_color = _upTextColor, text_halign = text.align_right, text_valign = text.align_center, bgcolor = _upBgColor, text_size = size.normal, text_font_family = font.family_monospace)

table.cell(resultsTable, column = 0, row = 10, text = '-10 - -5', text_color = _upTextColor, text_halign = text.align_left, text_valign = text.align_center, bgcolor = _upBgColor, text_size = size.normal, text_font_family = font.family_monospace)
table.cell(resultsTable, column = 1, row = 10, text = str.tostring(minus10), text_color = _upTextColor, text_halign = text.align_right, text_valign = text.align_center, bgcolor = _upBgColor, text_size = size.normal, text_font_family = font.family_monospace)

table.cell(resultsTable, column = 0, row = 11, text = '-15 - -10', text_color = _upTextColor, text_halign = text.align_left, text_valign = text.align_center, bgcolor = _upBgColor, text_size = size.normal, text_font_family = font.family_monospace)
table.cell(resultsTable, column = 1, row = 11, text = str.tostring(minus15), text_color = _upTextColor, text_halign =text.align_right, text_valign = text.align_center, bgcolor = _upBgColor, text_size = size.normal, text_font_family = font.family_monospace)

table.cell(resultsTable, column = 0, row = 12, text = '-20 - -15', text_color = _upTextColor, text_halign = text.align_left, text_valign = text.align_center, bgcolor = _upBgColor, text_size = size.normal, text_font_family = font.family_monospace)
table.cell(resultsTable, column = 1, row = 12, text = str.tostring(minus20), text_color = _upTextColor, text_halign = text.align_right, text_valign = text.align_center, bgcolor = _upBgColor, text_size = size.normal, text_font_family = font.family_monospace)

/// eof

Overview

PriceCatch Stock Range Binning categorizes daily rate-of-change values into specific positive and negative percentage bins ranging from -20% to +20%. The resulting occurrence counts are displayed in a customizable summary table on the chart. Settings allow users to adjust the lookback window, table position, border, and text styling. This indicator requires a daily timeframe to execute.

Details

Published by

PriceCatch on GitHub

Type

Indicator, Pine Script v6

Draws

Separate pane below the chart

Category

Screeners & dashboards, Volatility & bands

Markets

Stocks

Timeframes

H4 and above

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

javascriptlightweight-chartspinescriptpythontrading-strategies

Settings

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

SettingTypeDefaultVariable
No.of Trading Daysint2000nlen
Position on ChartstringBottom CentertblPos
Border Colorcolor#636363tblBorderColor
Title Backgroundcolor#004074title1_bgColor
Title Textcolor#7AC3fftitle1_textColor
Up Background Colorcolor#000000_upBgColor
Up Text Colorcolor#daeefe_upTextColor
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 scans a pasted list of symbols and shows matching long and short setups in a table in a separate pane. It uses a Supertrend crossover, then applies an ATR or fixed-point volatility range so quiet, sideways conditions can be skipped. Optional fil

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

Test 009 Stat Mining

by ricardosantos79
261 stars

This statistical analysis tool mines historical relationships between RSI values and candle volatility. It calculates a 14-period RSI from the previous bar and normalizes absolute price change using a 14-period Average True Range (ATR). Based on the normalized

Indicator v4 Oscillators & momentumVolatility & bands
Updated 4 years ago · None stated GitHub repository of Test 009 Stat Mining

Market Speedometer

by TradersPost
218 stars

Market Speedometer plots a 0-100 market speed reading in a separate pane. It measures movement by bar-to-bar change, true range, or a short average of recent bars, then ranks that movement against ATR and a percentile lookback. An EMA smooths the reading, and

Indicator v6 Volatility & bandsOscillators & momentum
Updated 3 months ago · None stated GitHub repository of Market Speedometer
46 stars

This indicator summarizes higher-timeframe candle range statistics by time of day and shows them in a table in a separate pane. It groups candles into slots for 5-minute, 15-minute, 1-hour, 4-hour, 8-hour, or 12-hour periods over a chosen lookback in days, and

Indicator v5 Screeners & dashboardsSessions & time Repaints
Updated 7 weeks ago · None stated GitHub repository of HTF Candle Stats by Time of Day
41 stars

This indicator transforms standard RSI calculations into logit space, estimating rolling distributions to derive empirical z-scores mapped back to the 0–100 RSI scale. Plotted in a separate pane, it features multi-horizon central lines—fast and structural cent

Indicator v6 Oscillators & momentumVolatility & bands
Updated 2 days ago · None stated GitHub repository of Calibrated RSI Position Zones

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