Indicator · Pine Script v4 · On the chart

Aroon-based Strategy

by capissimo

This indicator overlay generates buy and sell signals based on Aroon extreme levels combined with optional volume or volatility filters.

View on GitHub

GitHub stars114on the repository
Pine versionv4older, still runs
Lines of code147
Settings9inputs
LicenceNone statedfile: MPL-2.0
Last update1 year ago7 Nov 2024

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

147 lines of Pine Script v4 from scripts/108-Aroon-based-Strategy.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

108-Aroon-based-Strategy.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © capissimo

//@version=4
study('Aroon-based Strategy', '', true)

//-------------------- Inputs

lag       = input(9,     'Aroon Lag |1..n|',        minval=1)
HighLevel = input(85,    'Overbought Level |1..n|', minval=1)
LowLevel  = input(15,    'Oversold Level |1..n|',   minval=1)
ftype     = input('None','Filter Signals by',       options=['Volatility','Volume','Both','None'])
af        = input(1,     'Short ATR Lag |1..n|',    minval=1)
as        = input(10,    'Long ATR Lag |2..n|',     minval=2)
holding_p = input(9,     'Holding Period |1..n|',   minval=1)

//-------------------- System Variables

var int BUY       = -1
var int SELL      =  1
var int HOLD      =  0

//-------------------- Dynamic Arrays

var float Bulls    = 0.0
var float Bears    = 0.0
var int   signal   = HOLD
var int LastTrend  = HOLD

var int hp_counter = 0

//-------------------- Custom Functions

volumeBreak(thres) =>  
    rsivol   = rsi(volume, 14)  
    osc      = hma(rsivol, 10)  
    osc > thres                     

volatilityBreak(volmin, volmax) => atr(volmin) > atr(volmax)

//-------------------- Logic

filter =   ftype=='Volatility' ? volatilityBreak(af, as) 
         : ftype=='Volume'     ? volumeBreak(49) 
         : ftype=='Both'       ? volatilityBreak(af, as) and volumeBreak(49)
         :                       true

BULLS = 100 * (highestbars(high, lag+1) + lag) / lag
BEARS = 100 * (lowestbars(low, lag+1)   + lag) / lag
Range = 0.0

if BULLS>HighLevel and BEARS<LowLevel
    if LastTrend == SELL
        for count=0 to 10
            Range := abs(high[count]-low[count])
        Bulls = low-(Range*0.5/10)
    LastTrend := BUY

if BULLS<LowLevel and BEARS>HighLevel
    if LastTrend == BUY
        for count=0 to 10 
            Range := abs(high[count]-low[count])
        Bears = high+(Range*0.5/10)
    LastTrend := SELL

signal :=  change(LastTrend) and BULLS<LowLevel and BEARS>HighLevel and filter ? SELL 
         : change(LastTrend) and BULLS>HighLevel and BEARS<LowLevel and filter ? BUY 
         : nz(signal[1])

changed = change(signal)

hp_counter := changed ? 0 : hp_counter + 1

startLongTrade  = changed and signal==BUY    
startShortTrade = changed and signal==SELL   
endLongTrade    = (changed and signal==SELL) or (signal==BUY  and hp_counter==holding_p and not changed) 
endShortTrade   = (changed and signal==BUY)  or (signal==SELL and hp_counter==holding_p and not changed) 

//-------------------- Rendering

plotshape(startLongTrade,  'Buy',  shape.labelup,   location.belowbar, color.blue, 0, 0, '', color.white, size=size.small)
plotshape(startShortTrade, 'Sell', shape.labeldown, location.abovebar, color.red,  0, 0, '', color.white, size=size.small)
plot(endLongTrade         ? high : na, 'StopBuy',  color.blue, 2, plot.style_cross)
plot(endShortTrade        ? low  : na, 'StopSell', color.red,  2, plot.style_cross)

//-------------------- Alerting

if changed and signal==BUY 
    alert("Buy Alert", alert.freq_once_per_bar)  // alert.freq_once_per_bar_close
if changed and signal==SELL 
    alert("Sell Alert", alert.freq_once_per_bar)
    
alertcondition(startLongTrade,  "Buy Alert",  "Go Long!")
alertcondition(startShortTrade, "Sell Alert", "Go Short!") 

//-------------------- Backtesting

show_info = input(true, '===Information===')
lot_size  = input(0.01,  'Lot Size', options=[0.01,0.1,0.2,0.3,0.5,1,2,3,5,10,20,30,50,100,1000]) 

tbase   = (time - time[1]) / 1000
tcurr   = (timenow - time_close[1]) / 1000
barlife = tcurr / tbase

bidask  = (open+high+low)/3

var float start_long_trade  = bidask  
var float long_trades       = 0.
var float start_short_trade = bidask  
var float short_trades      = 0.
var int   wins              = 0
var int   trade_count       = 0

if startLongTrade 
    start_long_trade := bidask 
if endLongTrade
    ldiff         = (bidask - start_long_trade)
    wins         := ldiff > 0 ? 1 : 0
    long_trades  := ldiff * lot_size   
    trade_count  := 1
if startShortTrade 
    start_short_trade := bidask
if endShortTrade
    sdiff         = (start_short_trade - bidask)
    wins         := sdiff > 0 ? 1 : 0
    short_trades := sdiff * lot_size 
    trade_count  := 1
    
cumreturn   = cum(long_trades) + cum(short_trades)  //-- cumulative return 
totaltrades = cum(trade_count)
totalwins   = cum(wins)  
totallosses = totaltrades - totalwins == 0 ? 1 : totaltrades - totalwins

//------------------- Information

var label lbl = na

info =  'CR='          + tostring(cumreturn,             '#.#') 
      + '\nTrades: '   + tostring(totaltrades,           '#')
      + '\nWin/Loss: ' + tostring(totalwins/totallosses, '#.##') 
      + '\nWinrate: '  + tostring(totalwins/totaltrades, '#.#%')       
      + '\nBar Time: ' + tostring(barlife,               '#.#%')

if show_info and barstate.islast  
    lbl := label.new(bar_index, ohlc4, info, xloc.bar_index, yloc.price, 
                     color.new(color.blue, 100), label.style_label_left, color.black, size.small, text.align_left)
    label.delete(lbl[1])

Overview

Aroon-based Strategy calculates Aroon Up and Aroon Down lines using localized high and low lookbacks, generating trade entries when Aroon reaches overbought or oversold thresholds. Signals can be filtered using relative volatility or volume oscillator conditions. Positions automatically close after a configurable maximum holding period or upon receiving a reverse signal. Signals and exits are plotted directly on the main price chart.

Details

Published by

capissimo on GitHub

Type

Indicator, Pine Script v4

Draws

On the price chart

Category

Trend, Oscillators & momentum, Volatility & bands, Volume

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
Aroon Lag |1..n|int9lag
Overbought Level |1..n|int85HighLevel
Oversold Level |1..n|int15LowLevel
Filter Signals bystringNoneftype
Short ATR Lag |1..n|int1af
Long ATR Lag |2..n|int10as
Holding Period |1..n|int9holding_p
===Information===booltrueshow_info
Lot Sizefloat0.01lot_size
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

The Momentum Setup is a multi-indicator visual tool designed for trend and momentum analysis directly on the price chart. It combines Relative Strength Index (RSI), Money Flow Index (MFI), Commodity Channel Index (CCI), Supertrend, and a 250-bar percentage cha

Indicator v5 Oscillators & momentumTrend
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - Ankush Bajaj Momentum Investing Setup
92 stars

This indicator plots a volume-weighted average price of the typical price on the chart and colors that line by ADX strength. It draws a standard-deviation envelope around VWAP and tints the fill green when plus DI leads and red when minus DI leads. Triangle ma

Indicator v5 TrendOscillators & momentum
Updated 8 weeks ago · Custom licence GitHub repository of Moon Dev VWAP x ADX Explosion
7 stars

The MACD RSI EMA Aggressive indicator generates momentum and trend-following signals on the price chart. It combines a MACD crossover or crossunder with an RSI threshold filter, price location relative to an Exponential Moving Average, volume expansion above a

Indicator v5 TrendOscillators & momentum
Updated 3 months ago · None stated GitHub repository of MACD RSI EMA Aggressive + ATR SLTP
6 stars

Capital41 Fusion Oscillator v3 measures multi-condition market confluence in a separate pane with a smoothed composite score ranging from 0 to 100. It evaluates four criteria: EMA trend direction, RSI oversold or overbought turns, Williams %R thresholds, and A

Indicator v6 Oscillators & momentumTrend
Updated 8 weeks ago · MIT GitHub repository of Capital41 Fusion Oscillator v3
257 stars

An overlay indicator that combines an ATR-based SuperTrend trailing stop with an integrated RSI-derived midline calculation on the price chart. The SuperTrend uses an ATR period and factor multiplier to plot dynamic green or red trend lines based on price dire

Indicator v5 TrendVolatility & bands
Updated 6 weeks ago · None stated GitHub repository of SuperTrend ATR + RSI

LiqSpikeBounceLong Feb2026

by agutinbaigo28
147 stars

LiqSpikeBounceLong Feb2026 is an indicator designed to identify long bounce entries following high-volume liquidation cascades in bearish market contexts. It checks if price is below an exponential moving average, then detects large single-bar drops exceeding

Indicator v5 Volatility & bandsVolume
Updated 6 weeks ago · MIT GitHub repository of LiqSpikeBounceLong Feb2026

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