RiverFlow ADX Screener
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © traderharikrishna

//@version=5
indicator("RiverFlow ADX Screener")
length = input.int(20, minval=1)
riverflow()=>
    lower = ta.lowest(length)
    upper = ta.highest(length)
    basis = math.avg(upper, lower)
    int trend = 0
    trend := close > upper[1] ? 1 : close < lower[1] ? -1 : nz(trend[1])
    trendcolor= trend == 1 ?   #00ff00 :   trend == -1 ?   #ff0000 : color.rgb(114, 114, 113)
    dontime=ta.barssince(ta.change(trend))
    [plus,minus,adx]=ta.dmi(14,14)
    adxtime=ta.barssince(ta.cross(plus,minus))
    adxcol=adx>20 and plus>minus?color.rgb(12, 238, 19)
           :adx>20 and plus<minus?color.rgb(255, 1, 1)
           :color.rgb(141, 141, 139)
    adxsignal=plus>minus and plus>20?color.rgb(12, 238, 19)
              :plus>minus and plus<20?color.rgb(132, 252, 136, 68)
              :plus<minus and minus>20?color.rgb(255, 1, 1)
              :plus<minus and minus<20?color.rgb(250, 144, 144, 68)
              :color.rgb(129, 129, 128)
    vwapcolor=close>ta.ema(close,200)?color.rgb(12, 238, 19):color.rgb(255, 1, 1)
    [vwapcolor,trendcolor,dontime,adx,adxsignal,adxtime,adxcol]


[plus,minus,adx]=ta.dmi(14,14)
threshold=20
a=plot(adx, color=#00000070, title="ADX",style = plot.style_area)
t=plot(20,color=plus>minus?color.green:color.red,linewidth=5)
p=plot(plus, color=#2ffd06, title="+DI",linewidth=2)
m=plot(minus, color=#ff0000, title="-DI",linewidth=2)

z=plot(0,display=display.none)

s1=plot(20-5 ,color=adx>threshold?na:color.rgb(255, 255, 0),linewidth=2)
s2=plot(20+5 ,color=adx>threshold?na:color.rgb(255, 255, 0),linewidth=2)
fill(s1,s2,color=adx>threshold?na:color.rgb(120, 123, 134, 52))
fill(t,p,color=plus>minus?color.rgb(1, 109, 5):color.red)

[vwapcolor1,trendcolor1,dontime1,adx1,adxsignal1,adxtime1,adxcol1]=request.security(syminfo.tickerid,'5',riverflow())
[vwapcolor2,trendcolor2,dontime2,adx2,adxsignal2,adxtime2,adxcol2]=request.security(syminfo.tickerid,'15',riverflow())
[vwapcolor3,trendcolor3,dontime3,adx3,adxsignal3,adxtime3,adxcol3]=request.security(syminfo.tickerid,'30',riverflow())
[vwapcolor4,trendcolor4,dontime4,adx4,adxsignal4,adxtime4,adxcol4]=request.security(syminfo.tickerid,'60',riverflow())
[vwapcolor5,trendcolor5,dontime5,adx5,adxsignal5,adxtime5,adxcol5]=request.security(syminfo.tickerid,'240',riverflow())
[vwapcolor6,trendcolor6,dontime6,adx6,adxsignal6,adxtime6,adxcol6]=request.security(syminfo.tickerid,'1D',riverflow())

status = table.new(position.middle_right, 11, 20, border_width=1)
table.cell(status, 0, 1, text='Chart', bgcolor=color.gray,text_color=color.white, text_size=size.small,text_halign=text.align_left)
table.cell(status, 0, 2, text='5M', bgcolor=vwapcolor1,text_color=color.white, text_size=size.small,text_halign=text.align_left)
table.cell(status, 0, 3, text='15M', bgcolor=vwapcolor2,text_color=color.white, text_size=size.small,text_halign=text.align_left)
table.cell(status, 0, 4, text='30M', bgcolor=vwapcolor3,text_color=color.white, text_size=size.small,text_halign=text.align_left)
table.cell(status, 0, 5, text='1H', bgcolor=vwapcolor4,text_color=color.white, text_size=size.small,text_halign=text.align_left)
table.cell(status, 0, 6, text='4H', bgcolor=vwapcolor5,text_color=color.white, text_size=size.small,text_halign=text.align_left)
table.cell(status, 0, 7, text='D', bgcolor=vwapcolor6,text_color=color.white, text_size=size.small,text_halign=text.align_left)


table.cell(status, 1, 1, text='Don', bgcolor=color.gray,text_color=color.white, text_size=size.small,text_halign=text.align_left)
table.cell(status, 1, 2, text=str.tostring(dontime1), bgcolor=trendcolor1,text_color=color.white, text_size=size.small,text_halign=text.align_left)
table.cell(status, 1, 3, text=str.tostring(dontime2), bgcolor=trendcolor2,text_color=color.white, text_size=size.small,text_halign=text.align_left)
table.cell(status, 1, 4, text=str.tostring(dontime3), bgcolor=trendcolor3,text_color=color.white, text_size=size.small,text_halign=text.align_left)
table.cell(status, 1, 5, text=str.tostring(dontime4), bgcolor=trendcolor4,text_color=color.white, text_size=size.small,text_halign=text.align_left)
table.cell(status, 1, 6, text=str.tostring(dontime5), bgcolor=trendcolor5,text_color=color.white, text_size=size.small,text_halign=text.align_left)
table.cell(status, 1, 7, text=str.tostring(dontime6), bgcolor=trendcolor6,text_color=color.white, text_size=size.small,text_halign=text.align_left)

table.cell(status, 2, 1, text='ADX', bgcolor=color.gray,text_color=color.white, text_size=size.small,text_halign=text.align_left)
table.cell(status, 2, 2, text=str.tostring(adx1,'##.##'), bgcolor=adxcol1,text_color=color.white, text_size=size.small,text_halign=text.align_left)
table.cell(status, 2, 3, text=str.tostring(adx2,'##.##'), bgcolor=adxcol2,text_color=color.white, text_size=size.small,text_halign=text.align_left)
table.cell(status, 2, 4, text=str.tostring(adx3,'##.##'), bgcolor=adxcol3,text_color=color.white, text_size=size.small,text_halign=text.align_left)
table.cell(status, 2, 5, text=str.tostring(adx4,'##.##'), bgcolor=adxcol4,text_color=color.white, text_size=size.small,text_halign=text.align_left)
table.cell(status, 2, 6, text=str.tostring(adx5,'##.##'), bgcolor=adxcol5,text_color=color.white, text_size=size.small,text_halign=text.align_left)
table.cell(status, 2, 7, text=str.tostring(adx6,'##.##'), bgcolor=adxcol6,text_color=color.white, text_size=size.small,text_halign=text.align_left)

table.cell(status, 3, 1, text='Cross', bgcolor=color.gray,text_color=color.white, text_size=size.small,text_halign=text.align_left)
table.cell(status, 3, 2, text=str.tostring(adxtime1), bgcolor=adxsignal1,text_color=color.white, text_size=size.small,text_halign=text.align_left)
table.cell(status, 3, 3, text=str.tostring(adxtime2), bgcolor=adxsignal2,text_color=color.white, text_size=size.small,text_halign=text.align_left)
table.cell(status, 3, 4, text=str.tostring(adxtime3), bgcolor=adxsignal3,text_color=color.white, text_size=size.small,text_halign=text.align_left)
table.cell(status, 3, 5, text=str.tostring(adxtime4), bgcolor=adxsignal4,text_color=color.white, text_size=size.small,text_halign=text.align_left)
table.cell(status, 3, 6, text=str.tostring(adxtime5), bgcolor=adxsignal5,text_color=color.white, text_size=size.small,text_halign=text.align_left)
table.cell(status, 3, 7, text=str.tostring(adxtime6), bgcolor=adxsignal6,text_color=color.white, text_size=size.small,text_halign=text.align_left)

