Advertisement
DOABrownie

Super Trend pine

Feb 24th, 2020
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. //@version=2
  2. strategy("Supertrend Cloud", overlay = true)
  3. Multiplier=input(3, minval=1,maxval = 100)
  4. Periods=input(10, minval=1,maxval = 100)
  5.  
  6.  
  7. Multiplierx2=input(6, minval=1,maxval = 100)
  8. Periodx2=input(10, minval=1,maxval = 100)
  9.  
  10.  
  11. Up=hl2-(Multiplier*atr(Periods))
  12. Dn=hl2+(Multiplier*atr(Periods))
  13. Upx2=hl2-(Multiplierx2*atr(Periodx2))
  14. Dnx2=hl2+(Multiplierx2*atr(Periodx2))
  15.  
  16. TrendUp=close[1]>TrendUp[1]? max(Up,TrendUp[1]) : Up
  17. TrendDown=close[1]<TrendDown[1]? min(Dn,TrendDown[1]) : Dn
  18. TrendUpx2=close[1]>TrendUpx2[1]? max(Upx2,TrendUpx2[1]) : Upx2
  19. TrendDownx2=close[1]<TrendDownx2[1]? min(Dnx2,TrendDownx2[1]) : Dnx2
  20.  
  21. Trend = close > TrendDown[1] ? 1: close< TrendUp[1]? -1: nz(Trend[1],1)
  22. Tsl = Trend==1? TrendUp: TrendDown
  23. Trendx2 = close > TrendDownx2[1] ? 1: close< TrendUpx2[1]? -1: nz(Trendx2[1],1)
  24. Tslx2 = Trendx2==1? TrendUpx2: TrendDownx2
  25.  
  26. linecolor = Trend == 1 ? green : red
  27. linecolorx2 = Trendx2 == 1 ? green : red
  28.  
  29. short = plot(Tsl, color = linecolor , style = line , linewidth = 2,title = "SuperTrend")
  30. long = plot(Tslx2, color = linecolorx2 , style = line , linewidth = 1,title = "SuperTrend x2")
  31. fill(short, long, color = aqua, title = "Cloud")
  32.  
  33. plotshape(cross(close,Tsl) and close>Tsl , "Up Arrow", shape.triangleup,location.belowbar,green,0,0)
  34. plotshape(cross(Tsl,close) and close<Tsl , "Down Arrow", shape.triangledown , location.abovebar, red,0,0)
  35. plotshape(cross(close,Tslx2) and close>Tslx2 , "Up Arrow", shape.triangleup,location.belowbar,green,0,0)
  36. plotshape(cross(Tslx2,close) and close<Tslx2 , "Down Arrow", shape.triangledown , location.abovebar, red,0,0)
  37.  
  38. fill(short, long, color = aqua, title = "Cloud")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement