soru

soru dynamic SR (v1.3)

236 0 21
Hi Guys,
updated version of my indicator.
Default settings are for 5 min charts.
For 4h chart:
- go to indicator properties untick TW1 and TW2.
- tick TW3 and TW4

Please test other settings and share with us if you find anything interesting:)

Cheers,
Remove from Favorite Scripts Add to Favorite Scripts
study(title="soru dynamic SR (v1.3)", shorttitle="soru dynamic SR (v1.3)", overlay=true) 
//general
periods=input(200, minval=1, title="MA Period")
add_lines = input(title="additional lines?", type=bool, defval=true)

TW1_dyn = input("5", title="Timewindow1 for dynamics")
TW2_dyn = input("90", title="Timewindow2 for dynamics")
TW3_dyn = input("480", title="Timewindow1 for dynamics")
TW4_dyn = input("4D", title="Timewindow2 for dynamics")
S1_d = input(title="Show TW1 dynamics", type=bool, defval=true)
S2_d = input(title="Show TW2 dynamics", type=bool, defval=true)
S3_d = input(title="Show TW3 dynamics", type=bool, defval=false)
S4_d = input(title="Show TW4 dynamics", type=bool, defval=false)
S1_dm = input(title="Show TW1 dyn m area", type=bool, defval=true)
S2_dm = input(title="Show TW2 dyn m area", type=bool, defval=true)
S3_dm = input(title="Show TW3 dyn m area", type=bool, defval=false)
S4_dm = input(title="Show TW4 dyn m area", type=bool, defval=false)
vis1_multi = 4
vis2_multi = 4
vis3_multi = 4
vis4_multi = 4

vis1_c = gray
vis2_c = black
vis3_c = gray
vis4_c = black
vis1_w = 1
vis2_w = 2
vis3_w = 1
vis4_w = 2
m1 = 2.5
m2 = 5
m3=7.5
m4=10
m5=12.5 
m6=15
hld = iff(close > sma(high,periods)[1], 1, iff(close<sma(low,periods)[1],-1, 0))



//TW1

hld_d1 = security(tickerid, TW1_dyn, hld)
hlv = valuewhen(hld_d1 != 0, hld_d1, 1)

sma_l1 = security(tickerid, TW1_dyn, sma(low, periods))
sma_h1 = security(tickerid, TW1_dyn, sma(high, periods))
hi = S1_d and hlv == -1 ? sma_h1 : na
lo = S1_d and hlv == 1 ? sma_l1 : na
vis1 = vis1_multi*(sma_h1-sma_l1)
cond1 = sma_h1-sma_l1
s_25 = abs(sma_h1+m1*cond1-close) < vis1 ? 1:0
s_50 = abs(sma_h1+m2*cond1-close) < vis1 ? 1:0
s_75 = abs(sma_h1+m3*cond1-close) < vis1 ? 1:0
s_100 =abs(sma_h1+m4*cond1-close) < vis1 ? 1:0
s_125 =abs(sma_h1+m5*cond1-close) < vis1 ? 1:0
s_150 = abs(sma_h1+m6*cond1-close) < vis1 ? 1:0
s_m25 = abs(close - sma_h1+m1*cond1) < vis1 ? 1:0
s_m50 = abs(close - sma_h1+m2*cond1) < vis1 ? 1:0
s_m75 = abs(close - sma_h1+m3*cond1) < vis1 ? 1:0
s_m100 =abs(close - sma_h1+m4*cond1) < vis1 ? 1:0
s_m125 =abs(close - sma_h1+m5*cond1) < vis1 ? 1:0
s_m150 = abs(close - sma_h1+m6*cond1) < vis1 ? 1:0
s_1 = abs(close- sma_h1)<vis1 ? 1:0
h1 = plot(s_1 and S1_dm ? sma_h1:na, color=vis1_c, style=linebr,linewidth=vis1_w)
l1 = plot(s_1 and S1_dm ? sma_l1:na, color=vis1_c, style=linebr,linewidth=vis1_w)
fill(l1,h1,color=vis1_c, transp=90)
plot(lo and s_25 ? sma_h1+m1*cond1:na, color=vis1_c, style=linebr,linewidth=vis1_w)
plot(hi and s_m25 ? sma_l1-m1*cond1:na, color=vis1_c, style=linebr,linewidth=vis1_w)
plot(hi and s_m50? sma_l1-m2*cond1:na, color=vis1_c, style=linebr,linewidth=vis1_w)
plot(lo and s_50 ? sma_h1+m2*cond1:na, color=vis1_c, style=linebr,linewidth=vis1_w)
plot(hi and s_m75 ? sma_l1-m3*cond1:na, color=vis1_c, style=linebr,linewidth=vis1_w)
plot(lo and s_75 ? sma_h1+m3*cond1:na, color=vis1_c, style=linebr,linewidth=vis1_w)
plot(hi and s_m100 ? sma_l1-m4*cond1:na, color=vis1_c, style=linebr,linewidth=vis1_w)
plot(lo and s_100 ? sma_h1+m4*cond1:na, color=vis1_c, style=linebr,linewidth=vis1_w)
plot(hi and add_lines and s_m125 ? sma_l1-m5*cond1:na, color=vis1_c, style=linebr,linewidth=vis1_w)
plot(lo and add_lines and s_125 ? sma_h1+m5*cond1:na, color=vis1_c, style=linebr,linewidth=vis1_w)
plot(hi and add_lines and s_m150 ? sma_l1-m5*cond1:na, color=vis1_c, style=linebr,linewidth=vis1_w)
plot(lo and add_lines and s_150 ? sma_h1+m6*cond1:na, color=vis1_c, style=linebr,linewidth=vis1_w)


//TW2

hld_d2 = security(tickerid, TW2_dyn, hld)
hlv2 = valuewhen(hld_d2 != 0, hld_d2, 1)


sma_l2 = security(tickerid, TW2_dyn, sma(low, periods))
sma_h2 = security(tickerid, TW2_dyn, sma(high, periods))
hi2 = S2_d and hlv2 == -1 ? sma_h2 : na
lo2 = S2_d and hlv2 == 1 ? sma_l2 : na
vis2 = vis2_multi*(sma_h2-sma_l2)
cond2 = sma_h2-sma_l2
s2_25 = abs(sma_h2+m1*cond2-close) < vis2 ? 1:0
s2_50 = abs(sma_h2+m2*cond2-close) < vis2 ? 1:0
s2_75 = abs(sma_h2+m3*cond2-close) < vis2 ? 1:0
s2_100 =abs(sma_h2+m4*cond2-close) < vis2 ? 1:0
s2_125 =abs(sma_h2+m5*cond2-close) < vis2 ? 1:0
s2_150 = abs(sma_h2+m6*cond2-close) < vis2 ? 1:0
s2_m25 = abs(close - sma_h2+m1*cond2) < vis2 ? 1:0
s2_m50 = abs(close - sma_h2+m2*cond2) < vis2 ? 1:0
s2_m75 = abs(close - sma_h2+m3*cond2) < vis2 ? 1:0
s2_m100 =abs(close - sma_h2+m4*cond2) < vis2 ? 1:0
s2_m125 =abs(close - sma_h2+m5*cond2) < vis2 ? 1:0
s2_m150 = abs(close - sma_h2+m6*cond2) < vis2 ? 1:0
s_2 = abs(close- sma_h2)<vis2 ? 1:0
h2 = plot(s_2 and S2_dm ? sma_h2:na, color=vis2_c, style=linebr,linewidth=vis2_w)
l2 = plot(s_2 and S2_dm ? sma_l2:na, color=vis2_c, style=linebr,linewidth=vis2_w)
fill(l2,h2,color=vis2_c, transp=90)
plot(lo2 and s2_25 ? sma_h2+m1*cond2:na, color=vis2_c, style=linebr,linewidth=vis2_w)
plot(hi2 and s2_m25? sma_l2-m1*cond2:na, color=vis2_c, style=linebr,linewidth=vis2_w)
plot(hi2 and s2_m50? sma_l2-m2*cond2:na, color=vis2_c, style=linebr,linewidth=vis2_w)
plot(lo2 and s2_50 ? sma_h2+m2*cond2:na, color=vis2_c, style=linebr,linewidth=vis2_w)
plot(hi2 and s2_m75? sma_l2-m3*cond2:na, color=vis2_c, style=linebr,linewidth=vis2_w)
plot(lo2 and s2_75 ? sma_h2+m3*cond2:na, color=vis2_c, style=linebr,linewidth=vis2_w)
plot(hi2 and s2_m100? sma_l2-m4*cond2:na, color=vis2_c, style=linebr,linewidth=vis2_w)
plot(lo2 and s2_100? sma_h2+m4*cond2:na, color=vis2_c, style=linebr,linewidth=vis2_w)
plot(hi2 and add_lines and s2_m125 ? sma_l2-m5*cond2:na, color=vis2_c, style=linebr,linewidth=vis2_w)
plot(lo2 and add_lines and s2_125 ? sma_h2+m5*cond2:na, color=vis2_c, style=linebr,linewidth=vis2_w)
plot(hi2 and add_lines and s2_m150? sma_l2-m6*cond2:na, color=vis2_c, style=linebr,linewidth=vis2_w)
plot(lo2 and add_lines and s2_150? sma_h2+m6*cond2:na, color=vis2_c, style=linebr,linewidth=vis2_w)


//TW3

hld_d3 = security(tickerid, TW3_dyn, hld)
hlv3 = valuewhen(hld_d3 != 0, hld_d3, 1)


sma_l3 = security(tickerid, TW3_dyn, sma(low, periods))
sma_h3 = security(tickerid, TW3_dyn, sma(high, periods))
hi3 = S3_d and hlv3 == -1 ? sma_h3 : na
lo3 = S3_d and hlv3 == 1 ? sma_l3 : na
vis3 = vis3_multi*(sma_h3-sma_l3)
cond3 = sma_h3-sma_l3
s3_25 = abs(sma_h3+m1*cond3-close) < vis3 ? 1:0
s3_50 = abs(sma_h3+m2*cond3-close) < vis3 ? 1:0
s3_75 = abs(sma_h3+m3*cond3-close) < vis3 ? 1:0
s3_100 =abs(sma_h3+m4*cond3-close) < vis3 ? 1:0
s3_125 =abs(sma_h3+m5*cond3-close) < vis3 ? 1:0
s3_150 = abs(sma_h3+m6*cond3-close) < vis3 ? 1:0
s3_m25 = abs(close - sma_h3+m1*cond3) < vis3 ? 1:0
s3_m50 = abs(close - sma_h3+m2*cond3) < vis3 ? 1:0
s3_m75 = abs(close - sma_h3+m3*cond3) < vis3 ? 1:0
s3_m100 =abs(close - sma_h3+m4*cond3) < vis3 ? 1:0
s3_m125 =abs(close - sma_h3+m5*cond3) < vis3 ? 1:0
s3_m150 = abs(close - sma_h3+m6*cond3) < vis3 ? 1:0
s_3 = abs(close- sma_h3)<vis3 ? 1:0
h3 = plot(s_3 and S3_dm ? sma_h3:na, color=vis3_c, style=linebr,linewidth=vis3_w)
l3 = plot(s_3 and S3_dm ? sma_l3:na, color=vis3_c, style=linebr,linewidth=vis3_w)
fill(l3,h3,color=vis3_c, transp=90)
plot(lo3 and s3_25 ? sma_h3+m1*cond3:na, color=vis3_c, style=linebr,linewidth=vis3_w)
plot(hi3 and s3_m25? sma_l3-m1*cond3:na, color=vis3_c, style=linebr,linewidth=vis3_w)
plot(hi3 and s3_m50? sma_l3-m2*cond3:na, color=vis3_c, style=linebr,linewidth=vis3_w)
plot(lo3 and s3_50 ? sma_h3+m2*cond3:na, color=vis3_c, style=linebr,linewidth=vis3_w)
plot(hi3 and s3_m75? sma_l3-m3*cond3:na, color=vis3_c, style=linebr,linewidth=vis3_w)
plot(lo3 and s3_75 ? sma_h3+m3*cond3:na, color=vis3_c, style=linebr,linewidth=vis3_w)
plot(hi3 and s3_m100? sma_l3-m4*cond3:na, color=vis3_c, style=linebr,linewidth=vis3_w)
plot(lo3 and s3_100? sma_h3+m4*cond3:na, color=vis3_c, style=linebr,linewidth=vis3_w)
plot(hi3 and add_lines and s3_m125 ? sma_l3-m5*cond3:na, color=vis3_c, style=linebr,linewidth=vis3_w)
plot(lo3 and add_lines and s3_125 ? sma_h3+m5*cond3:na, color=vis3_c, style=linebr,linewidth=vis3_w)
plot(hi3 and add_lines and s3_m150? sma_l3-m6*cond3:na, color=vis3_c, style=linebr,linewidth=vis3_w)
plot(lo3 and add_lines and s3_150? sma_h3+m6*cond3:na, color=vis3_c, style=linebr,linewidth=vis3_w)

//TW4
hld_d4 = security(tickerid, TW4_dyn, hld)
hlv4 = valuewhen(hld_d4 != 0, hld_d4, 1)


sma_l4 = security(tickerid, TW4_dyn, sma(low, periods))
sma_h4 = security(tickerid, TW4_dyn, sma(high, periods))
hi4 = S4_d and hlv4 == -1 ? sma_h4 : na
lo4 = S4_d and hlv4 == 1 ? sma_l4 : na
vis4 = vis4_multi*(sma_h4-sma_l4)
cond4 = sma_h4-sma_l4
s4_25 = abs(sma_h4+m1*cond4-close) < vis4 ? 1:0
s4_50 = abs(sma_h4+m2*cond4-close) < vis4 ? 1:0
s4_75 = abs(sma_h4+m3*cond4-close) < vis4 ? 1:0
s4_100 =abs(sma_h4+m4*cond4-close) < vis4 ? 1:0
s4_125 =abs(sma_h4+m5*cond4-close) < vis4 ? 1:0
s4_150 = abs(sma_h4+m6*cond4-close) < vis4 ? 1:0
s4_m25 = abs(close - sma_h4+m1*cond4) < vis4 ? 1:0
s4_m50 = abs(close - sma_h4+m2*cond4) < vis4 ? 1:0
s4_m75 = abs(close - sma_h4+m3*cond4) < vis4 ? 1:0
s4_m100 =abs(close - sma_h4+m4*cond4) < vis4 ? 1:0
s4_m125 =abs(close - sma_h4+m5*cond4) < vis4 ? 1:0
s4_m150 = abs(close - sma_h4+m6*cond4) < vis4 ? 1:0
s_4 = abs(close- sma_h4)<vis4 ? 1:0
h4 = plot(s_4 and S4_dm ? sma_h4:na, color=vis4_c, style=linebr,linewidth=vis4_w)
l4 = plot(s_4 and S4_dm ? sma_l4:na, color=vis4_c, style=linebr,linewidth=vis4_w)
fill(l4,h4,color=vis4_c, transp=90)
plot(lo4 and s4_25 ? sma_h4+m1*cond4:na, color=vis4_c, style=linebr,linewidth=vis4_w)
plot(hi4 and s4_m25? sma_l4-m1*cond4:na, color=vis4_c, style=linebr,linewidth=vis4_w)
plot(hi4 and s4_m50? sma_l4-m2*cond4:na, color=vis4_c, style=linebr,linewidth=vis4_w)
plot(lo4 and s4_50 ? sma_h4+m2*cond4:na, color=vis4_c, style=linebr,linewidth=vis4_w)
plot(hi4 and s4_m75? sma_l4-m3*cond4:na, color=vis4_c, style=linebr,linewidth=vis4_w)
plot(lo4 and s4_75 ? sma_h4+m3*cond4:na, color=vis4_c, style=linebr,linewidth=vis4_w)
plot(hi4 and s4_m100? sma_l4-m4*cond4:na, color=vis4_c, style=linebr,linewidth=vis4_w)
plot(lo4 and s4_100? sma_h4+m4*cond4:na, color=vis4_c, style=linebr,linewidth=vis4_w)
plot(hi4 and add_lines and s4_m125 ? sma_l4-m5*cond4:na, color=vis4_c, style=linebr,linewidth=vis4_w)
plot(lo4 and add_lines and s4_125 ? sma_h4+m5*cond4:na, color=vis4_c, style=linebr,linewidth=vis4_w)
plot(hi4 and add_lines and s4_m150? sma_l4-m6*cond4:na, color=vis4_c, style=linebr,linewidth=vis4_w)
plot(lo4 and add_lines and s4_150? sma_h4+m6*cond4:na, color=vis4_c, style=linebr,linewidth=vis4_w)

Ideas Scripts Chart
United States
United Kingdom
India
España
Italia
Brasil
Россия
Türkiye
日本
한국
Home Stock Screener Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Billing Sign Out