xmd79

Hi/Lo Swing Index

Sep 26th, 2021
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. //
  2. // Author hajixde
  3. // This indicator finds the High/Low swinging index
  4.  
  5.  
  6. //@version=4
  7. study(title = "Hi/Lo Swing Index", overlay = false, format=format.price, precision=2, resolution="")
  8.  
  9. maLen = input(10, title = "MA Length")
  10. maLen2 = input(7, title = "Smoothing Length")
  11. histLen = input(200, title = "Memory Length")
  12. showTrend = input(true, title = "Show Trend Direction ?")
  13.  
  14. hlDiff = high - low
  15. hlRatio = hl2 / hlDiff
  16.  
  17. hlRatioMa = ema(hlRatio, maLen)
  18. hlRatioNormalized = 100 *((hlRatioMa - lowest(hlRatioMa,histLen)) / (highest(hlRatioMa, histLen) - lowest(hlRatioMa, histLen)))
  19.  
  20. hlRatioNormalizedSmoothed = wma(hlRatioNormalized, maLen2)
  21.  
  22. plot(hlRatioNormalized, color = color.blue)
  23. plot(showTrend ? hlRatioNormalizedSmoothed : na, color = hlRatioNormalizedSmoothed > hlRatioNormalizedSmoothed[1] ? color.green : color.red, linewidth = 2)
  24. plot(not showTrend ? hlRatioNormalizedSmoothed : na, color = color.red, linewidth = 1)
  25.  
  26. l1 = hline(0)
  27. l2 = hline(20)
  28. l3 = hline(80)
  29. l4 = hline(100)
  30.  
  31. fill(l2, l3, color = color.blue)
  32. fill(l1, l2, color = color.red)
  33. fill(l3, l4, color = color.red)
  34.  
Advertisement
Add Comment
Please, Sign In to add comment