Library · Pine Script v6 · Library

Commonlib

by InNoobWeTrust

Commonlib is a Pine Script v6 library of bar-geometry helpers that draws nothing by itself.

View on GitHub

GitHub stars4on the repository
Pine versionv6current
Lines of code55
Settings0inputs
LicenceNone statedfile: MPL-2.0
Last updatetoday28 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 library, select all of the template text and paste. Press Save and give it a name.
  4. 4Publish or import itA library draws nothing. Publish it from the editor, then import its functions in your own scripts.

Source Code

55 lines of Pine Script v6 from .innoobwetrust/life_hacks/tradingview/lib/commonlib.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

commonlib.pine
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © InNoobWeTrust

//@version=6

// @description InNoobWeTrust's commonlib
library('commonlib')

// @function calculate percentage of candle's wick which is longer
// @returns the wick's percentage, negative value if wick is lower wick
export bar_wick_percent() =>
    spread = high - low
    upper_wick = open < close ? high - close : high - open
    lower_wick = open < close ? open - low : close - low
    max_wick = math.max(upper_wick, lower_wick)
    bias = max_wick / spread
    bias * (max_wick == lower_wick ? 1.0 : -1.0)

// @function calculate percentage of candle's body
// @returns the body's percentage, negative value if close price is lower than open
export bar_body_percent() =>
    spread = high - low
    body = (close - open) / spread
    body

// @function Calculate the skewness of the bar as length percentage from the longer edge
// @returns the skewness in percentage, negative value means downard
export bar_skewness_percent() =>
    wick = bar_wick_percent()
    body = bar_body_percent()
    bias_sign = math.sign(wick * body)
    switch bias_sign
        1. => wick + body
        -1. => wick

// @function Calculate visible price range
// @returns tuple of [lowest, highest] price within visible range
export visible_price_range() =>
    period_ms = timeframe.in_seconds() * 1000
    lookback = chart.right_visible_bar_time - chart.left_visible_bar_time
    left_bars = math.round(lookback / period_ms)
    l = ta.lowest(left_bars)
    h = ta.highest(left_bars)
    // Return lowest and highest visible price
    [l, h]

// @function calculate spread-based power of the bar
// @returns tuple of bar power and bias value, calculated from bar information
export bar_structure() =>
    bar_balance = close - open
    bull_pwr = math.max(high - open, high - close[1])
    bear_pwr = math.max(open - low, close[1] - low)
    bar_bias = bar_balance + bull_pwr - bear_pwr
    bar_pwr = open + bar_bias
    [bar_pwr, bar_bias]

Overview

Commonlib measures the longer wick as a share of the high-low range, signed when the lower wick is longer, and the candle body as a signed share of that range. It combines those readings into a skewness value and returns a bar power and bias from the open, close, and prior close. It also returns the lowest and highest prices across bars currently visible on the chart.

Details

Published by

InNoobWeTrust on GitHub

Type

Library, Pine Script v6

Draws

Library (no plots)

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

dotfiles

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

261 stars

AIActivationFunctionsBipolarSigmoid is a Pine Script library that provides mathematical implementations of the bipolar sigmoid activation function and its derivatives for machine learning algorithms. It calculates bipolar sigmoid values bounded between -1 and

Library v5 AI / machine learning
Updated 4 years ago · None stated GitHub repository of AIActivationFunctionsBipolarSigmoid

KernelFunctions

by artificial-intelligence-edge
75 stars

KernelFunctions is a Pine Script v5 library that exports kernel weight functions for Nadaraya-Watson style estimation. It calculates a Rational Quadratic kernel, a Gaussian kernel based on a radial basis function, and a periodic kernel that models repeating be

Library v5
Updated 2 days ago · MIT GitHub repository of KernelFunctions

Ta

by nersent
29 stars

This Pine Script v5 library exports thin wrappers around built-in technical analysis functions. It covers moving averages, momentum measures such as RSI and CCI, volatility tools including ATR and standard deviation, range extremes, cross detection, and runnin

Library v5
Updated 11 months ago · Custom licence GitHub repository of Ta

Bands

by heyphat
26 stars

This library exports a Band type and functions that build a simple-moving-average basis with upper and lower envelopes from standard deviation. It classifies a source as above, below, or inside those envelopes, measures band width, and scales an imported z-sco

Library v6 Volatility & bandsMoving averages
Updated 2 months ago · AGPL-3.0 GitHub repository of Bands

Mylib

by ferranbt
21 stars

This script serves as a minimal utility library written in Pine Script v6. It provides an exported helper function that calculates the sum of two numeric arguments. As a reusable code library, it produces no visual plots, charts, or trading signals, and it con

Library v6
Updated 7 weeks ago · MPL-2.0 GitHub repository of Mylib

HLevel

by stupenkov
14 stars

HLevel is a Pine Script v5 utility library designed to manage horizontal price levels for cryptocurrency charts. It defines custom types for pivots and levels, along with methods to initialize, add, track, and expire price levels based on pivot high and pivot

Library v5
Updated 3 years ago · None stated GitHub repository of HLevel

More libraries

Trade Your Charts With a Regulated Broker

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

Compare brokers