Advertisement
danucante

Untitled

Nov 21st, 2023
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © steveelias
  3.  
  4. //@version=5
  5. indicator("Supersupertrend")
  6. /////// ATR2
  7. Factor2= input.float(1, "Factor", step = 0.01)
  8. Pd2 = input.int(20, minval=1,maxval = 100)
  9.  
  10.  
  11. Up2 = hl2 - (Factor2 * ta.atr(Pd2))
  12. Dn2 = hl2 + (Factor2 * ta.atr(Pd2))
  13.  
  14. TrendUp2 = Up2
  15. if (close[1] > TrendUp2[1])
  16. TrendUp2 := math.max(Up2, TrendUp2[1])
  17.  
  18. TrendDown2 = Dn2
  19. if (close[1] < TrendDown2[1])
  20. TrendDown2 := math.min(Dn2, TrendDown2[1])
  21.  
  22. Trend2 = 1
  23. if (close <= TrendDown2[1])
  24. if (close < TrendUp2[1])
  25. Trend2 := -1
  26. else
  27. Trend2 := nz(Trend2[1], 1)
  28.  
  29. Tsl2 = Trend2 == 1 ? TrendUp2 : TrendDown2
  30.  
  31. linecolor2 = Trend2 == 5 ? color.rgb(255, 255, 255) : color.rgb(255, 212, 69)
  32.  
  33. plot(Tsl2, color = linecolor2, style = plot.style_line, linewidth = 5, title = "SuperTrend")
  34.  
  35.  
  36. plotshape(barstate.isconfirmed and ta.cross(Tsl2, close) and close < Tsl2 , "Down Arrow2", shape.triangledown , location.abovebar, color.red,0)
  37. plotshape(barstate.isconfirmed and ta.cross(Tsl2, close) and close > Tsl2 , "Up Arrow2", shape.triangleup , location.belowbar, color.rgb(38, 255, 0),0)
  38. //plot(Trend==1 and Trend==-1,color = linecolor, style = circles, linewidth = 3,title="Trend")
  39.  
  40. plotarrow(barstate.isconfirmed and Trend2 == 1 and Trend2[1] == -1 ? Trend2 : na, title="Up Entry Arrow", colorup=color.lime)
  41. plotarrow(barstate.isconfirmed and Trend2 == -1 and Trend2[1] == 1 ? Trend2 : na, title="Down Entry Arrow", colordown=color.red)
  42.  
  43. ATRdn2 = ta.cross(Tsl2, close) and close < Tsl2
  44. ATRup2 = ta.cross(Tsl2, close) and close > Tsl2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement