Indicator · Pine Script v6 · Own pane

Average Sentiment Oscillator

by eddiebelaval· code credited to @thebitcoinfrontier

The Average Sentiment Oscillator (ASO) measures bullish and bearish market sentiment by evaluating intrabar and group price ranges over a specified period.

View on GitHub

GitHub stars7on the repository
Pine versionv6current
Lines of code132
Settings19inputs
LicenceNone statedfile: MPL-2.0
Last update3 months ago24 Jul 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

132 lines of Pine Script v6 from pinescript/oscillators/average-sentiment-oscillator-aso-lead.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

average-sentiment-oscillator-aso-lead.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © @thebitcoinfrontier
//@version=6
indicator("Average Sentiment Oscillator", shorttitle="Advanced ASO (lead)")

// ================================
// === ORIGINAL ASO (UNVERÄNDERT)
// ================================

length = input.int(10, "Period?", minval=1, maxval=100)
mode   = input.int(0, "Calculation Method:", minval=0, maxval=20)

intrarange = high - low
grouplow   = ta.lowest(low, length)
grouphigh  = ta.highest(high, length)
groupopen  = open[length - 1]
grouprange = grouphigh - grouplow

K1 = intrarange == 0 ? 1 : intrarange
K2 = grouprange == 0 ? 1 : grouprange

intrabarbulls = ((((close - low) + (high - open)) / 2) * 100) / K1
groupbulls    = ((((close - grouplow) + (grouphigh - groupopen)) / 2) * 100) / K2

intrabarbears = ((((high - close) + (open - low)) / 2) * 100) / K1
groupbears    = ((((grouphigh - close) + (groupopen - grouplow)) / 2) * 100) / K2

TempBufferBulls = mode == 0 ? (intrabarbulls + groupbulls) / 2 : mode == 1 ? intrabarbulls : groupbulls
TempBufferBears = mode == 0 ? (intrabarbears + groupbears) / 2 : mode == 1 ? intrabarbears : groupbears

ASOBulls = ta.sma(TempBufferBulls, length)
ASOBears = ta.sma(TempBufferBears, length)

// Original ASO
plot(ASOBulls, color=color.blue, linewidth=1, title="ASO Bulls")
plot(ASOBears, color=color.red, linewidth=1, title="ASO Bears")

// ================================
// === ASO LEAD / LAG
// ================================

showASOLead = input.bool(false, "Show ASO Lead / Lag")
asoLeadBars = input.int(0, "ASO Lead Bars (+Lead / -Lag)")

ASOBullsLead = ASOBulls[asoLeadBars]
ASOBearsLead = ASOBears[asoLeadBars]

plot(showASOLead ? ASOBullsLead : na, "ASO Bulls Lead", color.new(color.blue, 60), 1)
plot(showASOLead ? ASOBearsLead : na, "ASO Bears Lead", color.new(color.red, 60), 1)

// ================================
// === ASO DELTA
// ================================

showASODelta = input.bool(false, "Show ASO Delta (Lead - Normal)")

ASODelta = ASOBullsLead - ASOBulls
plot(showASODelta ? ASODelta : na, "ASO Delta", color.yellow, 2)
hline(0, "Delta Zero Line", color.gray, hline.style_dotted)

// ================================
// === ZYKLUS EINSTELLUNGEN
// ================================

showSin = input.bool(true, "Show Sinus")
showCos = input.bool(false, "Show Cosinus")
showFib = input.bool(false, "Show Fib Sinus")

cycleLen  = input.int(120, "Cycle Length (Bars)", minval=10)
fibLevel  = input.float(1.618, "Fib Level")
phaseShift = input.int(0, "Phase Shift (Bars)", minval=-25, maxval=25)

// ================================
// === ASO FILTER
// ================================

useASOFilter = input.bool(false, "Use ASO Extrem Filter")
upperLevel   = input.int(70, "ASO Upper Level")
lowerLevel   = input.int(30, "ASO Lower Level")

asoExtreme = ASOBulls > upperLevel or ASOBears < lowerLevel
asoGate    = useASOFilter ? asoExtreme : true

// ================================
// === MTF
// ================================

useMTF = input.bool(false, "Use Higher Timeframe Cycle")
mtfTF  = input.timeframe("M", "MTF Timeframe")

mtfIndex = request.security(syminfo.tickerid, mtfTF, bar_index)

// ================================
// === PHASEN ROTATION
// ================================

useRotation = input.bool(false, "Use Phase Rotation")
rotationOpt = input.string("0°", "Rotation Angle", options=["0°","90°","180°","270°"])

rotation = rotationOpt == "90°" ? math.pi/2 :
           rotationOpt == "180°" ? math.pi :
           rotationOpt == "270°" ? math.pi*1.5 : 0.0

// ================================
// === PHASENBERECHNUNG
// ================================

idx = useMTF ? mtfIndex : bar_index
basePhase = 2 * math.pi * (idx + phaseShift) / cycleLen
phase = useRotation ? basePhase + rotation : basePhase

// ================================
// === ZYKLUS KURVEN
// ================================

baseAmp = 50.0

sinCurve = math.sin(phase) * baseAmp
cosCurve = math.cos(phase) * baseAmp
fibCurve = math.sin(phase) * baseAmp * fibLevel

plot(showSin and asoGate ? sinCurve : na, "Sinus Cycle", color.green, 2)
plot(showCos and asoGate ? cosCurve : na, "Cosinus Cycle", color.orange, 2)
plot(showFib and asoGate ? fibCurve : na, "Fib Sinus Cycle", color.purple, 2)

// ================================
// === KREISPROJEKTION
// ================================

showCircle = input.bool(false, "Show Cycle Circle Projection")
circleY = math.sin(phase) * baseAmp
plot(showCircle ? circleY : na, "Cycle Circle Projection", color.aqua, 2)

Overview

Average Sentiment Oscillator plots bull and bear sentiment lines in a separate pane along with optional shifted lead or lag lines and a delta oscillator. The indicator features modular settings for cycle projections (sine, cosine, and Fibonacci sine), phase rotation, multi-timeframe cycle analysis, and extreme level filtering.

Details

Published by

eddiebelaval on GitHub

Code credit

@thebitcoinfrontier, as written in the script's header

Type

Indicator, Pine Script v6

Draws

Separate pane below the chart

Category

Oscillators & momentum, 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.

Settings

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

SettingTypeDefaultVariable
Period?int10length
Calculation Method:int0mode
Show ASO Lead / LagboolfalseshowASOLead
ASO Lead Bars (+Lead / -Lag)int0asoLeadBars
Show ASO Delta (Lead - Normal)boolfalseshowASODelta
Show SinusbooltrueshowSin
Show CosinusboolfalseshowCos
Show Fib SinusboolfalseshowFib
Cycle Length (Bars)int120cycleLen
Fib Levelfloat1.618fibLevel
Phase Shift (Bars)int0phaseShift
Use ASO Extrem FilterboolfalseuseASOFilter
Show all 19 settings
SettingTypeDefaultVariable
ASO Upper Levelint70upperLevel
ASO Lower Levelint30lowerLevel
Use Higher Timeframe CycleboolfalseuseMTF
MTF TimeframetimeframeMmtfTF
Use Phase RotationboolfalseuseRotation
Rotation Anglestring0°rotationOpt
Show Cycle Circle ProjectionboolfalseshowCircle
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

TTM Squeeze

by Alorse
330 stars

This indicator plots a TTM Squeeze momentum oscillator in a separate pane. It compares a Bollinger Band offset to a Keltner Channel offset and marks the zero line white when the difference is non-negative and black when the bands are inside the channel. A line

Indicator v5 Oscillators & momentumVolatility & bands
Updated 2 months ago · None stated GitHub repository of TTM Squeeze

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
147 stars

This indicator generates trade entry signals and target levels optimized for 1-hour timeframes, designed for external signal extraction. It calculates 7-period and 16-period EMAs alongside 10-period RSI and ATR filters. Long signals occur when the fast EMA cro

Indicator v5 TrendOscillators & momentum
Updated 6 weeks ago · MIT GitHub repository of Signal Strategy 100 Candles of 1H Timeframe

Bubbles Indicator

by capissimo
114 stars

The Bubbles Indicator measures volatility squeezes and expansion bursts using Bollinger Bands combined with a sinusoid oscillator and RSI divergence. It processes price data through scaled Bollinger Bands to highlight volatility changes while confirming trend

Indicator v4 Volatility & bandsOscillators & momentum Repaints
Updated 1 year ago · None stated GitHub repository of Bubbles Indicator

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