RicardoSantos

[RS]Range Adaptive Channel V2

267 views
25
267 0
EXPERIMENTAL:
high moves bottom, low moves top.
Remove from Favorite Scripts Add to Favorite Scripts
//@version=2
study(title='[RS]Range Adaptive Channel V2', shorttitle='RAC', overlay=true)
reversal_type = input('ATR')
reversal_modifier = input(type=float, defval=14)
reversal_multiplier = input(3)
USE_ALT_TF = input(title='Use Alternative Timeframe?', type=bool, defval=false)
ALT_TF = input(title='Alternative Timeframe:', type=string, defval='D', confirm=false)

reversal_block = reversal_multiplier * (reversal_type == 'ATR' ? atr(round(reversal_modifier)) : reversal_type == 'Traditional' ? reversal_modifier :  0 )

bot_base = na(bot_base[1]) ? high-reversal_block : bot_base[1] + reversal_block < high ? high-reversal_block : low < bot_base[1] ? low : bot_base[1]
top_base = na(top_base[1]) ? low+reversal_block : top_base[1] - reversal_block > low ? low+reversal_block : high > top_base[1] ? high : top_base[1]
bot = USE_ALT_TF ? security(tickerid, ALT_TF, bot_base) : bot_base
top = USE_ALT_TF ? security(tickerid, ALT_TF, top_base) : top_base

top_f = change(bot)<0 or change(top)<0 ? top : na
bot_f = change(bot)<0 or change(top)<0 ? bot : na
top_r = change(bot)>0 or change(top)>0 ? top : na
bot_r = change(bot)>0 or change(top)>0 ? bot : na

top_border = top - (top-bot)*0.25
bot_border = bot + (top-bot)*0.25
mid_border = bot + (top-bot)*0.50

plot(title='tf', series=top_f, style=areabr, color=red, transp=50)
plot(title='bf', series=bot_f, style=areabr, color=white, transp=0)
plot(title='tf', series=top_r, style=areabr, color=lime, transp=50)
plot(title='bf', series=bot_r, style=areabr, color=white, transp=0)
//fill(tf, bf, color=gray, transp=50)
plot(title='Range', series=bot, color=lime)
plot(title='Range', series=top, color=red)

plot(title='Border', series=top_border, style=circles, color=red, transp=70)
plot(title='Border', series=bot_border, style=circles, color=lime, transp=70)
plot(title='Border', series=mid_border, style=circles, color=black, transp=90)

Home Stock Screener Forex Screener Crypto Screener Economic Calendar How It Works Chart Features Pricing House Rules Moderators Website & Broker Solutions Widgets Charting Solutions Help Center Feature Request Blog & News FAQ Wiki Twitter
Profile Profile Settings Account and Billing TradingView Coins My Support Tickets Help Center Ideas Published Followers Following Private Messages Chat Sign Out