xmd79

Logistics Sigmoid Oscillator

Nov 1st, 2022
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. //@version=5
  2. indicator(title="Logistics Sigmoid Oscillator", shorttitle="LOSC", overlay=false, timeframe="", timeframe_gaps=true)
  3. len_main = input.int(36, minval=1, title="Length")
  4.  
  5. // CALCULATIONS
  6. main_line = ta.ema(hl2, len_main)
  7. price_line = ta.ema(hl2, 3)
  8. stdev_main = ta.stdev(hl2, len_main)
  9.  
  10. z_score = (price_line - main_line) / stdev_main
  11. sigmoid = 2 * (math.pow(1 + math.exp(-z_score), -1) - 0.5)
  12.  
  13. // COLORS
  14. black_transp = color.new(color.black, 100)
  15. red = color.new(color.red, 60)
  16. green = color.new(color.green, 60)
  17.  
  18. // LINES
  19. l_100_up = hline(1, linestyle=hline.style_solid, editable=false)
  20. l_50_up = hline(0.5, linestyle=hline.style_dotted, editable=false)
  21. l_00 = hline(0, color=black_transp, editable=false)
  22. l_50_dw = hline(-0.5, linestyle=hline.style_dotted, editable=false)
  23. l_100_dw = hline(-1, linestyle=hline.style_solid, editable=false)
  24.  
  25. // PLOT
  26. fill(l_100_up, l_00, 1, 0, red, black_transp, editable=false)
  27. fill(l_100_dw, l_00, 0, -1, black_transp, green, editable=false)
  28.  
  29. plot(sigmoid, title="Sigmoid", color=color.blue, style=plot.style_line, editable=false)
  30. plot(ta.ema(sigmoid, 3), title="Smoothing", color=color.red, style=plot.style_line, editable=false)
Advertisement
Add Comment
Please, Sign In to add comment