You are on page 1of 2

//@version=3

study(title="Supply/Demand", shorttitle="SD",overlay=true)
src = close, len = input(14, minval=1, title="Length")
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
tresh = input(30,minval=1,title="Treshold eg. 100 - 30 = 70")
uppertreshold = 100 - tresh
lowertreshold = 0 + tresh

count = input(3,title="Confirmation Bars")

rsu = 0
rsd = 0
rsx = 0
incrementer_up = rsi > uppertreshold ? 1 : 0
incrementer_down = rsi < lowertreshold ? 1 : 0
incrementer_both = rsi > uppertreshold or rsi < lowertreshold ? 1 : 0

if incrementer_both
rsx := nz(rsx[1],0) + incrementer_both
else
rsx = 0

rxH = if (rsx >= count)


x = high
rxL = if (rsx >= count)
y = low

rH = fixnan(rxH)
rL = fixnan(rxL)

if incrementer_up
rsu := nz(rsu[1],0) + incrementer_up
else
rsu = 0

rssH = if (rsu >= count)


x = high

rssL = if (rsu >= count)


y = low

if incrementer_down
rsd := nz(rsd[1],0) + incrementer_down
else
rsd = 0

rsrH = if (rsd >= count)


x = high

rsrL = if (rsd >= count)


y = low

rsh = fixnan(rssH)
rsl = fixnan(rssL)
rrh = fixnan(rsrH)
rrl = fixnan(rsrL)
p1 = plot(rsh,style=cross,title="Resistance Zone High",transp=100)
p2 = plot(rsl,style=cross,title="Resistance Zone High",transp=100)
p3 = plot(rrh,style=cross,title="Support Zone High",transp=100)
p4 = plot(rrl,style=cross,title="Support Zone Low",transp=100)
p5 = plot(rH,style=cross,title="Demand Below / Supply Above | High")
p6 = plot(rL,style=cross,title="Demand Below / Supply Above | Low")
fill(p1,p2,color=green,transp=100)
fill(p3,p4,color=green,transp=100)
fill(p5,p6,color=blue)

____________________________________________________________________________
Telegram :-
https://telegram.me/MDiscord

Discord Invite :-
https://discord.gg/X38u4RnRbS

For Rare Stock Market And Entrepreneurship Courses :-


http://telegram.me/MegaPremiumzoneV2

You might also like