Strategy · Pine Script v4 · Own pane

AwesomeADX

by koradiyakaushal· code credited to kaushal

AwesomeADX is a Pine Script v4 strategy that combines an Awesome Oscillator, ADX directional movement, and Bollinger percent B with an optional four-length moving-average trend filter.

View on GitHub

GitHub stars12on the repository
Pine versionv4older, still runs
Lines of code229
Settings19inputs
LicenceMIT
Last update5 years ago30 Jul 2021

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

229 lines of Pine Script v4 from [STRAT]AwesomeADX.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

[STRAT]AwesomeADX.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © kaushal

// Strategy By TradePro
// https://www.youtube.com/watch?v=cKuTSFwUpPE&ab_channel=TradePro

//@version=4
SystemName = "AwesomeADX"
is_overlay = true
InitCapital = 1000
InitPosition = 100
InitCommission = 0
CalcOnorderFills = false

strategy(title=SystemName, shorttitle=SystemName, 
 initial_capital=InitCapital, default_qty_type=strategy.percent_of_equity, 
 default_qty_value=InitPosition,commission_type=strategy.commission.percent, commission_value=InitCommission, calc_on_order_fills=CalcOnorderFills, 
 precision=6, max_lines_count=500, max_labels_count=500, overlay=is_overlay, max_bars_back=20)

DateFilter      = input(false, "═════════════ Backtest Date Range Filtering", group="Date")

i_startTime = input(defval = timestamp("01 Jun 2021 00:00 +0000"), title = "Start Time", type = input.time, group="Date")
i_endTime = input(defval = timestamp("30 Dec 2021 23:30 +0000"), title = "End Time", type = input.time, group="Date")

TradeDateIsAllowed() => DateFilter ? time >= i_startTime and time <= i_endTime : true

//Filter Parameter

section1        = input(false,  "═════════ Filter Parameter ════════")

use_mafilt      = input(true,   title="Use MA Filter")

mafilt_type     = input("EMA",  title="MA Filter Type", options = ["EMA","SMA","WMA","RMA","VWMA"])
mafilt_len_1    = input(5,    title="EMA 01")
mafilt_len_2    = input(21,   title="EMA 02")
mafilt_len_3    = input(50,   title="EMA 03")
mafilt_len_4    = input(100,   title="EMA 04")

//Indicator Parameter
section2        = input(false,  "═════════ Signal Parameter ════════")
src             = input(close, title="Source", type=input.source)


//************************************************//
// Main Indicator Function
//************************************************//

//Filter Indicator Calculation --> MA
get_MA(typ, len) =>
    float maVal = na
    if (typ == "EMA")
        maVal := ema(src, len)
    if (typ == "SMA")
        maVal := sma(src, len)
    if (typ == "WMA")
        maVal := wma(src, len)
    if (typ == "RMA")
        maVal := rma(src, len)
    if (typ == "VWMA")
        maVal := vwma(src, len)
    maVal

MAfilt_01 = get_MA(mafilt_type, mafilt_len_1)
MAfilt_02 = get_MA(mafilt_type, mafilt_len_2)
MAfilt_03 = get_MA(mafilt_type, mafilt_len_3)
MAfilt_04 = get_MA(mafilt_type, mafilt_len_4)

// ADX
adxlen = input(14, title="ADX Smoothing", group="ADX")
dilen = input(14, title="DI Length", group="ADX")

dirmov(len) =>
    up = change(high)
    down = -change(low)
    plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
    minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
    truerange = rma(tr, len)
    plus = fixnan(100 * rma(plusDM, len) / truerange)
    minus = fixnan(100 * rma(minusDM, len) / truerange)
    [plus, minus]

adx(dilen, adxlen) =>
    [plus, minus] = dirmov(dilen)
    sum = plus + minus
    adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)

sig = adx(dilen, adxlen)

// BB %
length = input(20, minval=1, group="BB%")
mult = input(2.0, minval=0.001, maxval=50, title="StdDev", group="BB%")
basis = sma(src, length)
dev = mult * stdev(src, length)
upper = basis + dev
lower = basis - dev
bbr = (src - lower)/(upper - lower)

// Awesome oscillator
ao = sma(hl2,5) - sma(hl2,34)

Uptrend = false
Dntrend = false

if(((use_mafilt==true and MAfilt_01 > MAfilt_02 and MAfilt_03 > MAfilt_04) or use_mafilt==false))
    Uptrend := true

if(((use_mafilt==true and MAfilt_01 < MAfilt_02 and MAfilt_03 < MAfilt_04) or use_mafilt==false))
    Dntrend := true

BuySignal  = (sig > 15 and bbr > 0.75 and ao > 2)
SellSignal = (sig > 15 and bbr < 0.25 and ao < -2)


//****************************************************************************************************************************************************************************************//
// Backtest Section
//****************************************************************************************************************************************************************************************//

BTsection       = input(false,          "═════════ Backtest Parameter ════════")
SL_Fixed_Perc   = input(2,              title="Stop Loss Fixed Percentage", minval=0.1, step=0.1)
reward_ratio    = input(0.5,            title="TP Reward to Risk Ratio", minval=0.1, step=0.1)
//************************************************//

int open_pos    = 0
int long_pos    = 0
int short_pos   = 0

float _EntryPrice   = na
float _StopLoss     = na
float _TakeProfit   = na

float _EP = na
float _SL = na
float _TP = na

open_pos    := (open_pos [1] == 1) ? 1 : 0
long_pos    := (long_pos [1] == 1) ? 1 : 0
short_pos   := (short_pos[1] == 1) ? 1 : 0

_EP         := (open_pos[1] == 1) ? _EP[1] : na
_SL         := (open_pos[1] == 1) ? _SL[1] : na
_TP         := (open_pos[1] == 1) ? _TP[1] : na

//************************************************//
// Stoploss Function
//************************************************//

get_SL(_entry,_signal)=>
    ret_sl = 0.0
    
    if(_signal=="Buy")
        ret_sl := _entry - (_entry * (SL_Fixed_Perc/100)) 
    
    if(_signal=="Sell")
        ret_sl := _entry + (_entry * (SL_Fixed_Perc/100))

    ret_sl

//************************************************//
// Generate Entry/Exit Level
//************************************************//

//Buy
if(Uptrend and BuySignal)
    _EntryPrice     := close
    _StopLoss       := get_SL(_EntryPrice,"Buy")
    _TakeProfit     := (_EntryPrice + ((_EntryPrice - _StopLoss)*reward_ratio))

//Sell
if(Dntrend and SellSignal)
    _EntryPrice     := close
    _StopLoss       := get_SL(_EntryPrice,"Sell")
    _TakeProfit     := (_EntryPrice - ((_StopLoss - _EntryPrice)*reward_ratio))    

//************************************************//
// Trade Entry Function
//************************************************//

//Buy
if(open_pos == 0 and Uptrend and BuySignal and TradeDateIsAllowed())
    long_pos    := 1
    open_pos    := 1
    _EP         := _EntryPrice
    _SL         := _StopLoss
    _TP         := _TakeProfit
    strategy.entry("Long", strategy.long)

//Sell 
if(open_pos == 0 and Dntrend and SellSignal and TradeDateIsAllowed())
    short_pos   := 1
    open_pos    := 1
    _EP         := _EntryPrice
    _SL         := _StopLoss
    _TP         := _TakeProfit
    strategy.entry("Short", strategy.short)

//************************************************//
// Exit Function
//************************************************//

bool long_Profit_Label  = false
bool short_Profit_Label = false
bool long_Loss_Label    = false
bool short_Loss_Label   = false


//Exit Long Condition
if (long_pos[0] == 1 and low <= _SL)
    long_pos            := 0
    open_pos            := 0
    long_Loss_Label     := true
    strategy.close(id="Long", comment="sl", when=_SL)

if (long_pos[0] == 1 and high >= _TP)
    long_pos            := 0
    open_pos            := 0
    long_Profit_Label   := true
    strategy.close(id="Long", comment="tp", when=_TP)

if (short_pos[0] == 1 and high >= _SL)
    short_pos           := 0
    open_pos            := 0
    short_Loss_Label    := true
    strategy.close(id="Short", comment="sl", when=_SL)

if (short_pos[0] == 1 and low <= _TP)
    short_pos           := 0
    open_pos            := 0
    short_Profit_Label  := true
    strategy.close(id="Short", comment="tp", when=_TP)

Overview

AwesomeADX sizes each position as a percentage of equity and can limit trades to a chosen backtest date range. Moving-average type and lengths, ADX smoothing, DI length, Bollinger length and deviation, and inputs for a fixed-percentage stop and reward-to-risk target are the main settings. Overlay is enabled, so it draws on the price chart. No stop loss is applied by default.

Details

Published by

koradiyakaushal on GitHub

Code credit

kaushal, as written in the script's header

Type

Strategy, Pine Script v4

Draws

Separate pane below the chart

Category

Oscillators & momentum, Moving averages, Volatility & bands

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • The strategy enters trades without a stop loss

Settings

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

SettingTypeDefaultVariable
═════════════ Backtest Date Range FilteringboolfalseDateFilter
Start Timetimetimestamp("01 Jun 2021 00:00 +0000")i_startTime
End Timetimetimestamp("30 Dec 2021 23:30 +0000")i_endTime
═════════ Filter Parameter ════════boolfalsesection1
Use MA Filterbooltrueuse_mafilt
MA Filter TypestringEMAmafilt_type
EMA 01int5mafilt_len_1
EMA 02int21mafilt_len_2
EMA 03int50mafilt_len_3
EMA 04int100mafilt_len_4
═════════ Signal Parameter ════════boolfalsesection2
Sourcesourceclosesrc
Show all 19 settings
SettingTypeDefaultVariable
ADX Smoothingint14adxlen
DI Lengthint14dilen
lengthint20length
StdDevfloat2.0mult
═════════ Backtest Parameter ════════boolfalseBTsection
Stop Loss Fixed Percentageint2SL_Fixed_Perc
TP Reward to Risk Ratiofloat0.5reward_ratio
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

106 stars

This strategy captures strong bullish momentum by combining a 200-period SMA baseline, a custom Bollinger Band, the True Strength Index (TSI) smoothed with WMAs, and the ADX trend strength indicator. It initiates long positions when price is above the 200 SMA,

Strategy v4 TrendOscillators & momentum
Updated 2 years ago · GPL-3.0 GitHub repository of ADX_TSI_Bol Band Trend Chaser

EMA Ribbon MACD

by iamrichardD
57 stars

This strategy combines an EMA ribbon with MACD confirmation and plots in a separate pane. It enters when ribbon alignment, optional MACD zero or signal crosses, volume, smart-money, and multi-timeframe filters agree, then exits with percentage stop loss and ta

Strategy v6 TrendMoving averages
Updated 1 year ago · Apache-2.0 GitHub repository of EMA Ribbon MACD
25 stars

This Pine Script strategy calculates Bayesian probabilities of price breaking up or down relative to Bollinger Bands and a Simple Moving Average. It plots these breakout and breakdown probability lines as oscillators in a separate pane. Long entries trigger wh

Strategy v4 Oscillators & momentumVolatility & bands
Updated 6 years ago · None stated GitHub repository of Bayesian BBSMA Oscillator Strategy

Greeffer BB Strategy

by SammyEnigma
18 stars

This strategy combines Bollinger Bands, Bollinger Band Width, and the Relative Strength Index (RSI) for mean-reversion trades. It enters long when price crosses below the lower band with oversold RSI, or when band width contracts under low volatility. Short en

Strategy v4 Mean reversionOscillators & momentum
Updated 6 years ago · None stated GitHub repository of Greeffer BB Strategy
330 stars

This strategy plots MACD line, signal line, Bollinger Bands, and RSI on the price chart. It signals long entries on MACD crossover above signal with RSI below 50 and price below BB basis, plus optional DMI filter. Short entries are available but disabled by de

Strategy v5 Oscillators & momentumVolatility & bands
Updated 2 months ago · None stated GitHub repository of MACD + BB + RSI [Alorse]

Take Profits & Stop Losses

by PythonForForex
64 stars

This educational strategy demonstrates moving average crossovers filtered by RSI momentum, incorporating ATR-based risk management. It calculates a 10-period SMA, a 30-period SMA, a 14-period RSI, and a 14-period ATR. Long entries trigger when the fast SMA cro

Strategy v5 Moving averagesOscillators & momentum
Updated 4 years ago · None stated GitHub repository of Take Profits & Stop Losses

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