Strategy · Pine Script v4 · Own pane

Aroon Oscillator Strategy

by hasnocool· code credited to mohanee

This strategy calculates the Aroon Oscillator along with the Relative Strength Index (RSI) to generate long trading signals.

View on GitHub

GitHub stars106on the repository
Pine versionv4older, still runs
Lines of code57
Settings4inputs
LicenceGPL-3.0
Last update2 years ago18 Sep 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 strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

57 lines of Pine Script v4 from Aroon Oscillator Strategy.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.

Aroon Oscillator Strategy.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mohanee
//@version=4
strategy(title="Aroon Oscillator Strategy", overlay=false, pyramiding=2,    initial_capital=10000, currency=currency.USD)  //default_qty_value=10, default_qty_type=strategy.fixed, 
var stopLossVal=0.00
//variables BEGIN
aroonLength=input(169,title="Aroon Length")   //square root of 13
rsiLength=input(13, title="RSI Length")
stopLoss = input(title="Stop Loss%", defval=5, minval=1)
//variables  END
//RSI 
rsi13=rsi(close,rsiLength)
fastEma1=ema(close,5)
ema13=ema(close,13)
ema169=ema(close,169)
exitOnAroonOscCrossingDown = input(true, title="Exit when Aroon Osc cross down zero ")
// Drawings
//Aroon oscillator
arronUpper = 100 * (highestbars(high, aroonLength+1) + aroonLength)/aroonLength
aroonLower = 100 * (lowestbars(low, aroonLength+1) + aroonLength)/aroonLength
aroonOsc  = arronUpper - aroonLower
aroonMidpoint = 0
oscPlot = plot(aroonOsc, color=color.green)
midLine= plot(aroonMidpoint, color=color.green)
topLine = plot(90,style=plot.style_circles, color=color.green)
bottomLine = plot(-90,style=plot.style_circles, color=color.red)
fill(oscPlot, midLine, color=aroonOsc>0?color.green:color.red, transp=50)
fill(topLine,bottomLine, color=color.blue)
fill(topLine,oscPlot, color=aroonOsc>90?color.purple:na, transp=25)
// RSI 
//plot(rsi13, title="RSI", linewidth=2, color=color.purple)
//hline(50, title="Middle Line", linestyle=hline.style_dotted)
//obLevel = hline(80, title="Overbought", linestyle=hline.style_dotted)
//osLevel = hline(30, title="Oversold", linestyle=hline.style_dotted)
//fill(obLevel, osLevel, title="Background", color=rsi13 >=30 ? color.green:color.purple, transp=65)  // longTermRSI >=50
//Entry--
strategy.entry(id="Long Entry", comment="LE", qty=(strategy.initial_capital * 0.10)/close, long=true,  when= crossover(aroonOsc,0)   )     //crossover(close,ema34)  //and close>ema34  //crossover(rsi5Val,rsiBuyLine)
//Add
if(strategy.position_size>=1 and aroonOsc>0  and close < strategy.position_avg_price and crossover(rsi13,30))
    qty1=(strategy.initial_capital * 0.30)/close
    stopLossVal:= abs(strategy.position_size)>1 ?  ( (close > close[1] and close > open and close>strategy.position_avg_price) ? close[1]*(1-stopLoss*0.01) : stopLossVal ) : 0.00 
    //stopLossVal:= abs(strategy.position_size)>1 ?  strategy.position_avg_price*(1-stopLoss*0.01) :  0.00 
    strategy.order(id="Long Entry", comment="Add SL="+tostring(stopLossVal, "####.##"), qty=qty1, long=true )     //crossover(close,ema34)  //and close>ema34  //crossover(rsi5Val,rsiBuyLine)  --
//stopLossVal:= abs(strategy.position_size)>1 ? strategy.position_avg_price*(1-0.5) : 0.00 
stopLossVal:= abs(strategy.position_size)>1 ?  ( (close > close[1] and close > open and close>strategy.position_avg_price) ? close[1]*(1-stopLoss*0.01) : stopLossVal ) : 0.00 
//stopLossVal:= abs(strategy.position_size)>1 ?  strategy.position_avg_price*(1-stopLoss*0.01) :  0.00
barcolor(color=strategy.position_size>=1? aroonOsc>90 ? color.purple: color.blue:na)
//close partial
strategy.close(id="Long Entry", comment="Partial X  SL="+tostring(stopLossVal, "####.##"),  qty=strategy.position_size/5, when=abs(strategy.position_size)>=1 and crossunder(aroonOsc, 90) )   //close<ema55 and rsi5Val<20 //ema34<ema55
//strategy.close(id="Long Entry", comment="Partial X  SL="+tostring(stopLossVal, "####.##"),  qty=strategy.position_size/3, when=abs(strategy.position_size)>=1 and ( (close - ema169)  > ema169*0.10 ) and crossunder(close,ema13))   //close<ema55 and rsi5Val<20 //ema34<ema55 
//close All
if(exitOnAroonOscCrossingDown)
    strategy.close(id="Long Entry", comment="Exit All",  when=abs(strategy.position_size)>=1 and crossunder(aroonOsc, 0) )   //close<ema55 and rsi5Val<20 //ema34<ema55  //close<ema89
//close All on stop loss
if(not exitOnAroonOscCrossingDown)
    strategy.close(id="Long Entry", comment="Stoploss X",  when=abs(strategy.position_size)>=1 and close < stopLossVal )   //close<ema55 and rsi5Val<20 //ema34<ema55  //close<ema89
Expand (84 lines)

Overview

Aroon Oscillator Strategy opens an initial long position when the Aroon Oscillator crosses above the zero line, and pyramids into the position if price dips below average price while RSI crosses above 30. Partial exits occur when the Aroon Oscillator crosses below 90. Plots Aroon lines, boundaries, and background fills in a separate indicator pane.

Details

Published by

hasnocool on GitHub

Code credit

mohanee, as written in the script's header

Type

Strategy, Pine Script v4

Draws

Separate pane below the chart

Category

Trend, Oscillators & momentum

Markets

Crypto

Timeframes

M1-M5

Risk Notes

  • The strategy can add several entries in the same direction
  • The strategy enters trades without a stop loss

Topics

analysisbtcusdtcryptocurrencydatapandaspythonsimulationtradingtradingview

Settings

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

SettingTypeDefaultVariable
Aroon Lengthint169aroonLength
RSI Lengthint13rsiLength
Stop Loss%int5stopLoss
Exit when Aroon Osc cross down zero booltrueexitOnAroonOscCrossingDown
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

330 stars

MACD + Divergences [Alorse] is a momentum strategy that calculates the MACD oscillator and identifies regular and hidden divergences using pivot high and low points. It filters trade signals with dual Exponential Moving Averages (EMA 150 and 600) to ensure tra

Strategy v4 Oscillators & momentumDivergence Repaints
Updated 2 months ago · None stated GitHub repository of MACD + Divergences [Alorse]

Q-Trend + KVO Strategy

by TradersPost
218 stars

This strategy combines the ATR-banded Q-Trend indicator with the Klinger Volume Oscillator (KVO) to execute confluence trades. It enters long when a Q-Trend buy trigger aligns with a positive KVO value and a bullish candle confirmation, taking short trades und

Strategy v6 TrendVolume
Updated 3 months ago · None stated GitHub repository of Q-Trend + KVO Strategy

MACD Crossover (tutorial)

by pineforge-4pass
193 stars

This strategy calculates the Moving Average Convergence Divergence indicator and plots the MACD line, signal line, and histogram in a separate pane. It enters long positions when the MACD line crosses above the signal line and enters short positions when it cr

Strategy v6 Oscillators & momentumMoving averages
Updated today · Apache-2.0 GitHub repository of MACD Crossover (tutorial)

BTC MACD Basic Tests

by iamrichardD
57 stars

BTC MACD Basic Tests implements a Pine Script unit-testing framework designed to validate components of a long-only Bitcoin MACD trading system. It constructs structured test cases to evaluate mock functions for MACD crossover calculations, volume threshold ch

Strategy v6 Oscillators & momentumTrend
Updated 1 year ago · Apache-2.0 GitHub repository of BTC MACD Basic Tests

Trailering S002

by ruckard
13 stars

Trailering S002 is a long-only automated strategy template built for Zignaly webhook execution. It evaluates historical price stats and maximum excursion to trigger long trades, dynamically adjusting capital allocation based on active signal conditions. The sc

Strategy v5 TrendOscillators & momentum
Updated 1 year ago · None stated GitHub repository of Trailering S002

This strategy evaluates the dynamic relationship between price and a chosen moving average across six diagnostic dimensions: trend, respect, extension, compression, acceleration, and exhaustion. It plots a normalized relationship oscillator bounded between -10

Strategy v6 TrendMoving averages
Updated yesterday · MIT GitHub repository of Market–Average Relationship Engine [WavesUnchained]

More strategys

Trade Your Charts With a Regulated Broker

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

Compare brokers