Indicator · Pine Script v6 · Own pane

Accumulation Swing Index (ASI)

by mihakralj

Calculates J.

View on GitHub

GitHub stars99on the repository
Pine versionv6current
Lines of code48
Settings1inputs
LicenceApache-2.0
Last update4 weeks ago27 Sep 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

48 lines of Pine Script v6 from lib/momentum/asi/asi.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

asi.pine
// Licensed under the Apache License, Version 2.0
// © mihakralj
//@version=6
indicator("Accumulation Swing Index (ASI)", "ASI", overlay=false)

//@function Computes Wilder's Swing Index for a single bar.
//@param high     Current bar high price
//@param low      Current bar low price
//@param close    Current bar close price
//@param open     Current bar open price
//@param prevHigh Previous bar high price
//@param prevLow  Previous bar low price (unused in SI formula but kept for completeness)
//@param prevClose Previous bar close price
//@param prevOpen  Previous bar open price
//@param limitMove Maximum daily limit move value (T parameter)
//@returns Single-bar Swing Index value
//@optimized O(1) per bar — no buffer allocation, pure arithmetic

asi(float high, float low, float close, float open, float prevClose, float prevOpen, float limitMove) =>
    float K = math.max(math.abs(high - prevClose), math.abs(low - prevClose))
    float absHC = math.abs(high - prevClose)
    float absLC = math.abs(low - prevClose)
    float absHL = math.abs(high - low)
    float absC1O1 = math.abs(prevClose - prevOpen)
    float R = absHC >= absLC and absHC >= absHL ?
        absHC - 0.5 * absLC + 0.25 * absC1O1 :
        absLC >= absHC and absLC >= absHL ?
        absLC - 0.5 * absHC + 0.25 * absC1O1 :
        absHL + 0.25 * absC1O1
    float SI = R != 0.0 ? 50.0 * ((close - prevClose) + 0.5 * (close - open) + 0.25 * (prevClose - prevOpen)) / R * (K / limitMove) : 0.0
    SI

//@param i_limitMove Limit move value T — the maximum daily price movement (must be > 0)
i_limitMove = input.float(3.0, title="Limit Move", minval=0.001, tooltip="Maximum daily price change (T). Use 3.0 for stocks, adjust for futures/forex.")

// ---------- Main loop ----------

var float asi_val = 0.0
float prevClose = nz(close[1], close)
float prevOpen = nz(open[1], open)
float prevHigh = nz(high[1], high)
float prevLow = nz(low[1], low)

float si = bar_index == 0 ? 0.0 : asi(high, low, close, open, prevClose, prevOpen, i_limitMove)
asi_val := nz(asi_val[1], 0.0) + si

hline(0, "Zero Line", color=color.new(color.gray, 60), linestyle=hline.style_dashed)
plot(asi_val, title="ASI", color=color.yellow, linewidth=2)

Overview

Welles Wilder's Accumulation Swing Index (ASI) to evaluate underlying price momentum and market trend strength. It computes the individual bar Swing Index based on current and previous open, high, low, and close prices relative to a maximum daily limit move parameter, then cumulatively sums these values over time. The resulting indicator line is plotted in a separate pane alongside a zero line reference.

Details

Published by

mihakralj on GitHub

Type

Indicator, Pine Script v6

Draws

Separate pane below the chart

Category

Oscillators & momentum, Trend

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

algorithmic-tradingcsharpdotnetpinescriptpythonquantitative-financesimdta-libtechnical-analysistechnical-indicators

Settings

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

SettingTypeDefaultVariable
Limit Movefloat3.0i_limitMove
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

Schaff Trend Cycle

by everget
948 stars

This indicator plots the Schaff Trend Cycle in a separate pane. It subtracts a slow exponential moving average from a fast one, applies a stochastic cycle twice, and smooths each result to form a 0–100 oscillator. Line color follows the slope, or the upper and

Indicator v4 Oscillators & momentumTrend
Updated 10 days ago · GPL-3.0 GitHub repository of Schaff Trend Cycle

Beep Boop

by magic8bot
409 stars

This indicator calculates a modified MACD oscillator and signal line alongside a trend EMA filter, plotting the output as a stylized column histogram in a separate pane. Instead of plotting true MACD distance, it quantifies positive and negative histogram mome

Indicator v4 Oscillators & momentumTrend
Updated 3 years ago · MIT GitHub repository of Beep Boop

[RS]Standardized Trend Map

by ricardosantos79
261 stars

Standardized Trend Map calculates series momentum relative to active price range across 40 distinct lookback periods ranging from 2 to 80 bars on an exponential moving average source. Each standardized calculation rounds to an integer values of -1, 0, or 1 to

Indicator v4 TrendOscillators & momentum
Updated 4 years ago · None stated GitHub repository of [RS]Standardized Trend Map

ADX Histogram

by harryguiacorn
219 stars

This indicator calculates and displays the Average Directional Index (ADX) as a column histogram in a separate pane. It evaluates market trend strength by calculating directional movement metrics based on specified smoothing and DI length inputs. When the ADX

Indicator v5 TrendOscillators & momentum
Updated 1 year ago · None stated GitHub repository of ADX Histogram
218 stars

Multi-Timeframe Analysis Suite calculates trend direction and momentum conditions across five user-selected timeframes using moving averages, RSI, and Stochastic oscillators. It evaluates moving average slope and oscillator levels to compute trend alignment, m

Indicator v6 Screeners & dashboardsTrend
Updated 3 months ago · None stated GitHub repository of Multi-Timeframe Analysis Suite

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