Apr 28 2019 : Kal’s MTF ADX Rangoli Roller in PineScript

in #adx6 years ago (edited)

Kaly MTF ADX Rangoli Roller is a method/study for finding trending stocks and cryptocurrencies using two different data periods (10, 5) of ADX Overlap over different time-frames (10m, 1H, 4H, 1D, 1W, 1M). In the study, I used 5-Period ADX for all mentioned time-frames. You may use 10-Period ADX for lower time-frames especially 10m and 1H.

Sample Image of the pinescript code(at the end of this post) in Tradingview looks as follows:

Note: Kal's MTF ADX Rangoli Roller is the lower Plot. The upper plot is KAL’s ADX Overlap Technical Study with MACD Filter(https://steemit.com/pinescript/@chipmaker/pine-script-for-kal-s-adx-overlap-technical-study-with-macd-filter)

Description:

Lowest row is 10m, row above is 1H, row above is 4H, then 1D, then 1W and highest row is 1M

Lime(Bright Green) dot implies Trending Uptrend for that time-frame (first phase)
Green dot implies Trending Uptrend for that time-frame (second phase near exhaustion)
Red dot implies Trending Downward for that time-frame (first phase)
Maroon dot implies Trending Downward for that time-frame (second phase near exhaustion)

Lime cross implies Strong Trending Uptrend for that time-frame (first phase)
Green cross implies Strong Trending Uptrend for that time-frame (second phase near exhaustion)
Red cross implies Trending Strong Downward for that time-frame (first phase)
Maroon cross implies Trending Strong Downward for that time-frame (second phase near exhaustion)

Yellow is ‘Squeeze On’ setting. During the squeeze period, the ADX signals are almost always ineffective. One may wait and watch over during this time. Once the Squeeze is released (i.e. no longer yellow), the trend corresponds to the color of the dots and crosses.

Black is CRSI Overbought condition for that time-frame. It’s best to wait and research for possibility of trend reversal because

        1. Profit-booking/trimming happens after CRSI Overbought condition.
        2. Large Short-sellers may take huge positions during this time pushing the stock prices up.

White is CRSI Oversold condition for that time-frame. It’s best to wait and research for possibility of trend reversal because

        1. Profit-booking/trimming happens after CRSI Oversold conditions.
        2. Large buyers may take huge positions during this time pushing the stock prices down.

I am a disabled man. Therefore, I am not able to write in detail here today. More Details will follow as time permits. Please let me know if I am missing anything…

Legal Disclaimer: I published here so I get replies from fellow viewers to educate myself and for my daily expenses. Hence, if anyone uses this script for making their decisions, I am not responsible for any failures incurred.

Safe Trading!
Kal Gandikota

PS: If you found this script interesting and edifying please follow and upvote.

PS2: Please kindly donate for my daily expenses (atleast as you would on streets) at the following addresses:
BTC Wallet: 1NeDC1GvpFa49DFLuT1v28ohFjqtoWXNQ5
ETH Wallet: 0x35e557F39A998e7d35dD27c6720C3553e1c65053
NEO Wallet: AUdiNJDW7boeUyYYNhX86p2T8eWwuELSGr

PS3: For more information on ADX and CRSI, please 'Google' or search here yourself.
PS4: This study is intended for research in creating automated Python Trading Systems using Pandas(https://steemit.com/python/@chipmaker/how-to-find-guidance-on-building-python-based-cryptocurrency-trading-bots).

Test this code out in your pine editor with a free account on https://www.tradingview.com. More details follow as time permits!

//BEGIN============================================
///////////////////////////////////////////////////////////////////////
//@version=3
//Author: KAL GANDIKOTA
// Kaly MTF ADX Rangoli Roller is a method/study for finding trending stocks 
// and cryptocurrencies using two different data periods (10, 5) of ADX Overlap 
// over different time-frames (10m, 1H, 4H, 1D, 1W, 1M)
//
// Copyright (C) APR 2019 KAL GANDIKOTA
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
// 
// Please Kindly Donate for my Daily Expenses and Greater Works Than These
//
// BTC Wallet: 1NeDC1GvpFa49DFLuT1v28ohFjqtoWXNQ5
// ETH Wallet: 0x35e557F39A998e7d35dD27c6720C3553e1c65053
// NEO Wallet: AUdiNJDW7boeUyYYNhX86p2T8eWwuELSGr
// SteemID: chipmaker
//https://www.twitter.com/chipmaker_tweet
//https://steemit.com/@chipmaker
///////////////////////////////////////////////////////////////////////

study(title="Kal’s MTF ADX Rangoli Roller", shorttitle="KALY_MTF_ADX_RANGOLI_ROLLER")

//ADX
adx_len_var = input(5, minval=1, title="DI Length")
adx_lensig_var = input(5, title="ADX Smoothing", minval=1, maxval=50)
adx_BW_exLevels = input(false, title="Show ADX exLevels in Black and White")
adx_exLevel=input(90,title="Exhaustion Level for ADX, default = 70")
adx_brLevel=input(10,title="BreakOut Level for ADX, default = 25")

//ADX2
adx2_len_var = input(10, minval=1, title="DI Length")
adx2_lensig_var = input(10, title="ADX Smoothing", minval=1, maxval=50)
adx2_BW_exLevels = input(false, title="Show ADX exLevels in Black and White")
adx2_exLevel=input(90,title="Exhaustion Level for ADX, default = 70")
adx2_brLevel=input(10,title="BreakOut Level for ADX, default = 25")

//SQZ_M
lengthBB = input(20, title="BB Length")
multBB = input(2.0,title="BB MultFactor")
lengthKC=input(20, title="KC Length")
multKC = input(1.5, title="KC MultFactor")
useATrueRange = input(true, title="Use TrueRange (KC)", type=bool)

// Calculate BB
basis = sma(close, lengthBB)
dev = multBB * stdev(close, lengthBB)
upperBB = basis + dev
lowerBB = basis - dev

// Calculate KC
ma = sma(close, lengthKC)
range = useATrueRange ? tr : (high - low)
rangema = sma(range, lengthKC)
upperKC = ma + rangema * multKC
lowerKC = ma - rangema * multKC

//Calculate Squeeze
sqzOn  = (lowerBB > lowerKC) and (upperBB < upperKC)
sqzOff = (lowerBB < lowerKC) and (upperBB > upperKC)
noSqz  = (sqzOn == false) and (sqzOff == false)

//CRSI
updown(s) => 
    isEqual = s == s[1]
    isGrowing = s > s[1]
    ud = 0.0
    ud := isEqual ? 0 : isGrowing ? (nz(ud[1]) <= 0 ? 1 : nz(ud[1])+1) : (nz(ud[1]) >= 0 ? -1 : nz(ud[1])-1)
    ud

ud=updown(close)

f_crsi_cond(src_var, ud) =>
    src = src_var, lenrsi = 3, lenupdown = 2, lenroc = 100
    rsi = rsi(src, lenrsi)
    updownrsi = rsi(ud, lenupdown)
    percentrank = percentrank(roc(src, 1), lenroc)
    crsi = avg(rsi, updownrsi, percentrank)
    crsi_cond = (crsi > 95) ? 1 : (crsi < 5) ? -1 : 0

//ADX 
chg_high = change(high)
chg_low  = -change(low)

f_plusDM(up, down) =>
    plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
    plusDM

f_minusDM(up, down) =>
    minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
    minusDM

f_trur(len) => 
    trur = rma(tr, len)
    trur

f_plus(len, plusDM, trur) => 
    plus = fixnan(100 * rma(plusDM, len) / trur)
    plus

f_minus(len, minusDM, trur) => 
    minus = fixnan(100 * rma(minusDM, len) / trur)
    minus

f_adx(len, lensig, plus, minus) => 
    sum = plus + minus
    adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), lensig)
    adx

plusDM = f_plusDM(chg_high, chg_low)
minusDM = f_minusDM(chg_high, chg_low)

//ADX1
trur = f_trur(adx_len_var)
plus=f_plus(adx_len_var, plusDM, trur)
minus=f_minus(adx_len_var, minusDM, trur)
adx=f_adx(adx_len_var, adx_lensig_var, plus, minus)

adx_rising = adx > adx[1]
adx_brex_check = adx >= adx_brLevel and adx <= adx_exLevel
adx_rising_brex_check = adx_rising and adx_brex_check
PGM = (plus > minus)
PLM = (plus < minus)

adx1_c1 = adx_rising_brex_check and PGM
adx1_c2 = adx_rising_brex_check and PLM

//ADX2
trur2 = f_trur(adx2_len_var)
plus2=f_plus(adx2_len_var, plusDM, trur2)
minus2=f_minus(adx2_len_var, minusDM, trur2)
adx2=f_adx(adx2_len_var, adx2_lensig_var, plus2, minus2)

adx2_rising = adx2 > adx2[1]
adx2_brex_check = adx2 >= adx2_brLevel and adx2 <= adx2_exLevel
adx2_rising_brex_check = adx2_rising and adx2_brex_check
adx2PGM = (plus2 > minus2)
adx2PLM = (plus2 < minus2)

adx2_c1 = adx2_rising_brex_check and adx2PGM
adx2_c2 = adx2_rising_brex_check and adx2PLM

//ADX OVERLAP CONDITIONS
adxBS =  (adx1_c1 and adx2_c1) or (adx1_c2 and adx2_c2)

//crsi OB and OS Conditions
crsi_cond = f_crsi_cond(close, ud)

//ADX_Color
f_adx_color(adx, PGM, PLM, brLevel, exLevel, sqzOn, crsi_cond) => 
    ADX_UP  = (adx > adx[1])
    ADX_DN  = (adx < adx[1])
    ADX_WT  = (adx <= 45)
    colorADX_B = ADX_UP ? (ADX_WT ? color(lime,0):color(green,0)) : (ADX_DN ? (ADX_WT ? color(silver, 30) : color(olive, 40)) : color(blue,0))
    colorADX_S = ADX_UP ? (ADX_WT ? color(red,0):color(maroon,0)) : (ADX_DN ? (ADX_WT ? color(orange, 50) :color(maroon, 60)) : color(blue,0))
    ADX_color_sqz= sqzOn ? color(yellow,0) : ((adx >= adx_brLevel) ? (PGM ? colorADX_B :(PLM ? colorADX_S: color(blue, 0))):color(blue,0))
    ADX_color = (crsi_cond==1) ? color(black, 0) : (crsi_cond==-1) ? color(white, 0) : ADX_color_sqz
    ADX_color

ADX_color_temp = f_adx_color(adx, PGM, PLM, adx_brLevel, adx_exLevel, sqzOn, crsi_cond)

// ADX_1_color = security(tickerid,"1", ADX_color_temp, lookahead=barmerge.lookahead_on)
// ADX_5_color = security(tickerid,"5", ADX_color_temp, lookahead=barmerge.lookahead_on)
ADX_10_color = security(tickerid,"10", ADX_color_temp, lookahead=barmerge.lookahead_on)
ADX_60_color = security(tickerid,"60", ADX_color_temp, lookahead=barmerge.lookahead_on)
ADX_240_color = security(tickerid,"240", ADX_color_temp, lookahead=barmerge.lookahead_on)
ADX_D_color = security(tickerid,"D", ADX_color_temp, lookahead=barmerge.lookahead_on)
ADX_W_color = security(tickerid,"W", ADX_color_temp, lookahead=barmerge.lookahead_on)
ADX_M_color = security(tickerid,"M", ADX_color_temp, lookahead=barmerge.lookahead_on)

// ADX_1_BS = security(tickerid,"1", adxBS, lookahead=barmerge.lookahead_on)
// ADX_5_BS = security(tickerid,"5", adxBS, lookahead=barmerge.lookahead_on)
ADX_10_BS = security(tickerid,"10", adxBS, lookahead=barmerge.lookahead_on)
ADX_60_BS = security(tickerid,"60", adxBS, lookahead=barmerge.lookahead_on)
ADX_240_BS = security(tickerid,"240", adxBS, lookahead=barmerge.lookahead_on)
ADX_D_BS = security(tickerid,"D", adxBS, lookahead=barmerge.lookahead_on)
ADX_W_BS = security(tickerid,"W", adxBS, lookahead=barmerge.lookahead_on)
ADX_M_BS = security(tickerid,"M", adxBS, lookahead=barmerge.lookahead_on)

//PLOTS
// plot0 = plot(ADX_1_BS ? na:3, color= ADX_1_color, style=circles, linewidth=4)
// plot5 = plot(ADX_5_BS ? na:4, color= ADX_5_color, style=circles, linewidth=4)
plot10 = plot(ADX_10_BS ? na:5, color= ADX_10_color, style=circles, linewidth=4)
plot60 = plot(ADX_60_BS ? na:6, color= ADX_60_color, style=circles, linewidth=4)
plot240 = plot(ADX_240_BS ? na:7, color= ADX_240_color, style=circles, linewidth=4)
plotD = plot(ADX_D_BS ? na:8, color= ADX_D_color, style=circles, linewidth=4)
plotW = plot(ADX_W_BS ? na: 9, color= ADX_W_color, style=circles, linewidth=4)
plotM = plot(ADX_M_BS ? na:10, color= ADX_M_color, style=circles, linewidth=4)

// plot1_cross = plot(ADX_1_BS ? 3:na, color= ADX_1_color, style=cross, linewidth=4)
// plot5_cross = plot(ADX_5_BS ? 4:na, color= ADX_5_color, style=cross, linewidth=4)
plot10_cross = plot(ADX_10_BS ? 5:na, color= ADX_10_color, style=cross, linewidth=4)
plot60_cross = plot(ADX_60_BS ? 6:na, color= ADX_60_color, style=cross, linewidth=4)
plot240_cross = plot(ADX_240_BS ? 7:na, color= ADX_240_color, style=cross, linewidth=4)
plotD_cross = plot(ADX_D_BS ? 8:na, color= ADX_D_color, style=cross, linewidth=4)
plotW_cross = plot(ADX_W_BS ? 9:na, color= ADX_W_color, style=cross, linewidth=4)
plotM_cross = plot(ADX_M_BS ? 10:na, color= ADX_M_color, style=cross, linewidth=4)
//END=============================================================

Screenshots of the above pinescript code in Tradingview Looks as follows:


10minute Screenshot of Kal's MTF ADX Rangoli Roller (Above)


1 Hour Screenshot of Kal's MTF ADX Rangoli Roller (Above)


4 Hour Screenshot of Kal's MTF ADX Rangoli Roller (Above)


1 Day Screenshot of Kal's MTF ADX Rangoli Roller (Above)


1 Week Screenshot of Kal's MTF ADX Rangoli Roller (Above)


1 Month Screenshot of Kal's MTF ADX Rangoli Roller (Above)

Coin Marketplace

STEEM 0.26
TRX 0.20
JST 0.038
BTC 95553.33
ETH 3596.23
USDT 1.00
SBD 3.79