Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © faytterro
- //@version=5
- indicator("Support and Resistance", overlay = true, max_bars_back =1000)
- len=input.int(75, "new zones transp")
- len2=input.int(85, "old zones transp")
- r = high<low[2]-(high[2]-low[2])
- and math.abs(close[1]-open[1])>(high[2]-low[2])*2
- r2 = high<math.min(low[3],low[4])-(math.max(high[3],high[4])-math.min(low[3],low[4]))
- and math.abs(close[1]-open[2])>(math.max(high[3],high[4])-math.min(low[3],low[4]))*2
- for i=1 to 4
- r2:= r2 and r2[i]==false
- r:= r and r2[i-1]==false
- s= low>high[2]-(high[2]-low[2])
- and math.abs(close[1]-open[1])>(high[2]-low[2])*2
- s2 = low>math.max(high[3],high[4])+(math.max(high[3],high[4])-math.min(low[3],low[4]))
- and math.abs(close[1]-open[2])>(math.max(high[3],high[4])-math.min(low[3],low[4]))*2
- for i=1 to 4
- s2 := s2 and s2[i]==false
- s:= s and s2[i-1]==false
- ass= ta.crossover(close,high[ta.barssince(r)+2])
- for i = 1 to ta.barssince(r)
- ass:= ass and ass[i]==false
- k=ta.barssince(ass)<ta.barssince(r)? ta.barssince(ass) : -2
- box=box.new(last_bar_index-ta.barssince(r)-2,high[ta.barssince(r)+2],
- last_bar_index-k,low[ta.barssince(r)+2], bgcolor = color.rgb(255,0,0,80), border_color = color.rgb(71, 89, 139,100))
- box.delete(box[1])
- bass= ta.crossunder(close,high[ta.barssince(r)+2])
- for i = 1 to ta.barssince(r)
- bass:= bass and bass[i]==false
- bk=ta.barssince(bass)<ta.barssince(r)? ta.barssince(bass) : -2
- bbox=box.new(last_bar_index-k,high[ta.barssince(r)+2],
- last_bar_index-bk,low[ta.barssince(r)+2], bgcolor = color.rgb(0,255,0,80), border_color = color.rgb(71, 89, 139,100))
- box.delete(bbox[1])
- ass2= ta.crossover(close,math.max(high[ta.barssince(r2)+3], high[ta.barssince(r2)+4]))
- for i = 1 to ta.barssince(r2)
- ass2:= ass2 and ass2[i]==false
- k2=ta.barssince(ass2)<ta.barssince(r2)? ta.barssince(ass2) : -2
- box2=box.new(last_bar_index-ta.barssince(r2)-4,
- math.max(high[ta.barssince(r2)+3], high[ta.barssince(r2)+4]),
- last_bar_index-k2,
- math.min(low[ta.barssince(r2)+3], low[ta.barssince(r2)+4]),
- bgcolor = color.rgb(255,0,0,len), border_color = color.rgb(71, 89, 139,100))
- box.delete(box2[1])
- bass2= ta.crossunder(close,math.max(high[ta.barssince(r2)+3], high[ta.barssince(r2)+4]))
- for i = 1 to ta.barssince(r2)
- bass2:= bass2 and bass2[i]==false
- bk2=ta.barssince(bass2)<ta.barssince(r2)? ta.barssince(bass2) : -2
- bbox2=box.new(last_bar_index-k2,
- math.max(high[ta.barssince(r2)+3], high[ta.barssince(r2)+4]),
- last_bar_index-bk2,
- math.min(low[ta.barssince(r2)+3], low[ta.barssince(r2)+4]),
- bgcolor = color.rgb(0,255,0,len), border_color = color.rgb(71, 89, 139,100))
- box.delete(bbox2[1])
- akk = ta.crossunder(close,low[ta.barssince(s)+2])
- for i=1 to ta.barssince(s)
- akk:= akk and akk[i]==false
- k4=ta.barssince(akk)<ta.barssince(s)? ta.barssince(akk) : -2
- box4=box.new(last_bar_index-ta.barssince(s)-2,
- high[ta.barssince(s)+2],
- last_bar_index-k4,
- low[ta.barssince(s)+2],
- bgcolor = color.rgb(0,255,0,len), border_color = color.rgb(71, 89, 139,100))
- box.delete(box4[1])
- bakk = ta.crossover(close,low[ta.barssince(s)+2])
- for i=1 to ta.barssince(s)
- bakk:= bakk and bakk[i]==false
- bk4=ta.barssince(bakk)<ta.barssince(s)? ta.barssince(bakk) : -2
- bbox4=box.new(last_bar_index-k4,
- high[ta.barssince(s)+2],
- last_bar_index-bk4,
- low[ta.barssince(s)+2],
- bgcolor = color.rgb(255,0,0,len), border_color = color.rgb(71, 89, 139,100))
- box.delete(bbox4[1])
- akk2 = ta.crossunder(close,math.min(low[ta.barssince(s2)+3],low[ta.barssince(s2)+4]))
- for i=1 to ta.barssince(s2)
- akk2:= akk2 and akk2[i]==false
- k5=ta.barssince(akk2)<ta.barssince(s2)? ta.barssince(akk2) : -2
- box5=box.new(last_bar_index-ta.barssince(s2)-2-2,
- math.max(high[ta.barssince(s2)+3],high[ta.barssince(s2)+4]),
- last_bar_index-k5,
- math.min(low[ta.barssince(s2)+3],low[ta.barssince(s2)+4]),
- bgcolor = color.rgb(0,255,0,len), border_color = color.rgb(71, 89, 139,100))
- box.delete(box5[1])
- bakk2 = ta.crossover(close,math.min(low[ta.barssince(s2)+3],low[ta.barssince(s2)+4]))
- for i=1 to ta.barssince(s2)
- bakk2:= bakk2 and bakk2[i]==false
- bk5=ta.barssince(bakk2)<ta.barssince(s2)? ta.barssince(bakk2) : -2
- bbox5=box.new(last_bar_index-k5,
- math.max(high[ta.barssince(s2)+3],high[ta.barssince(s2)+4]),
- last_bar_index-bk5,
- math.min(low[ta.barssince(s2)+3],low[ta.barssince(s2)+4]),
- bgcolor = color.rgb(255,0,0,len), border_color = color.rgb(71, 89, 139,100))
- box.delete(bbox5[1])
- obox = box.new(last_bar_index-ta.barssince(r)-2-ta.barssince(r)[ta.barssince(r)+1]-1,
- high[ta.barssince(r)+2+ta.barssince(r)[ta.barssince(r)+1]+1],
- last_bar_index-k[ta.barssince(r)+1]-ta.barssince(r)-2+1,
- low[ta.barssince(r)+2+ta.barssince(r)[ta.barssince(r)+1]+1], bgcolor = color.rgb(255,0,0,len2), border_color = color.rgb(1,1,1,100))
- box.delete(obox[1])
- bobox = box.new(last_bar_index-k[ta.barssince(r)+1]-ta.barssince(r)-2+1,
- high[ta.barssince(r)+2+ta.barssince(r)[ta.barssince(r)+1]+1],
- last_bar_index-bk[ta.barssince(r)+1]-ta.barssince(r)-2+1,
- low[ta.barssince(r)+2+ta.barssince(r)[ta.barssince(r)+1]+1], bgcolor = color.rgb(0,255,0,len2), border_color = color.rgb(1,1,1,100))
- box.delete(bobox[1])
- obox2 = box.new(last_bar_index-ta.barssince(r2)-4-ta.barssince(r2)[ta.barssince(r2)+1]-1,
- math.max(high[ta.barssince(r2)+3+ta.barssince(r2)[ta.barssince(r2)+1]+1], high[ta.barssince(r2)+4+ta.barssince(r2)[ta.barssince(r2)+1]+1]),
- last_bar_index-k2[ta.barssince(r2)+1]-ta.barssince(r2)-4+1+1,
- math.min(low[ta.barssince(r2)+3+ta.barssince(r2)[ta.barssince(r2)+1]+1], low[ta.barssince(r2)+4+ta.barssince(r2)[ta.barssince(r2)+1]+1]),
- bgcolor = color.rgb(255,0,0,len2), border_color = color.rgb(71, 89, 139,100))
- box.delete(obox2[1])
- bobox2 = box.new(last_bar_index-k2[ta.barssince(r2)+1]-ta.barssince(r2)-4+1+1,
- math.max(high[ta.barssince(r2)+3+ta.barssince(r2)[ta.barssince(r2)+1]+1], high[ta.barssince(r2)+4+ta.barssince(r2)[ta.barssince(r2)+1]+1]),
- last_bar_index-bk2[ta.barssince(r2)+1]-ta.barssince(r2)-4+1+1,
- math.min(low[ta.barssince(r2)+3+ta.barssince(r2)[ta.barssince(r2)+1]+1], low[ta.barssince(r2)+4+ta.barssince(r2)[ta.barssince(r2)+1]+1]),
- bgcolor = color.rgb(0,255,0,len2), border_color = color.rgb(71, 89, 139,100))
- box.delete(bobox2[1])
- obox3 = box.new(last_bar_index-ta.barssince(s)-2-ta.barssince(s)[ta.barssince(s)+1]-1,
- high[ta.barssince(s)+2+ta.barssince(s)[ta.barssince(s)+1]+1],
- last_bar_index-k4[ta.barssince(s)+1]-ta.barssince(s)-2+1,
- low[ta.barssince(s)+2+ta.barssince(s)[ta.barssince(s)+1]+1],
- bgcolor = color.rgb(0,255,0,len2), border_color = color.rgb(71, 89, 139,100))
- box.delete(obox3[1])
- bobox3 = box.new(last_bar_index-k4[ta.barssince(s)+1]-ta.barssince(s)-2+1,
- high[ta.barssince(s)+2+ta.barssince(s)[ta.barssince(s)+1]+1],
- last_bar_index-bk4[ta.barssince(s)+1]-ta.barssince(s)-2+1,
- low[ta.barssince(s)+2+ta.barssince(s)[ta.barssince(s)+1]+1],
- bgcolor = color.rgb(255,0,0,len2), border_color = color.rgb(71, 89, 139,100))
- box.delete(bobox3[1])
- obox4 = box.new(last_bar_index-ta.barssince(s2)-4-ta.barssince(s2)[ta.barssince(s2)+1]-1,
- math.max(high[ta.barssince(s2)+3+ta.barssince(s2)[ta.barssince(s2)+1]+1], high[ta.barssince(s2)+4+ta.barssince(s2)[ta.barssince(s2)+1]+1]),
- last_bar_index-k5[ta.barssince(s2)+1]-ta.barssince(s2)-4+1,
- math.min(low[ta.barssince(s2)+3+ta.barssince(s2)[ta.barssince(s2)+1]+1], low[ta.barssince(s2)+4+ta.barssince(s2)[ta.barssince(s2)+1]+1]),
- bgcolor = color.rgb(0,255,0,len2), border_color = color.rgb(71, 89, 139,100))
- box.delete(obox4[1])
- bobox4 = box.new(last_bar_index-k5[ta.barssince(s2)+1]-ta.barssince(s2)-4+1,
- math.max(high[ta.barssince(s2)+3+ta.barssince(s2)[ta.barssince(s2)+1]+1], high[ta.barssince(s2)+4+ta.barssince(s2)[ta.barssince(s2)+1]+1]),
- last_bar_index-bk5[ta.barssince(s2)+1]-ta.barssince(s2)-4+1,
- math.min(low[ta.barssince(s2)+3+ta.barssince(s2)[ta.barssince(s2)+1]+1], low[ta.barssince(s2)+4+ta.barssince(s2)[ta.barssince(s2)+1]+1]),
- bgcolor = color.rgb(255,0,0,len2), border_color = color.rgb(71, 89, 139,100))
- box.delete(bobox4[1])
Advertisement
Add Comment
Please, Sign In to add comment