Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- indicator(title="Logistics Sigmoid Oscillator", shorttitle="LOSC", overlay=false, timeframe="", timeframe_gaps=true)
- len_main = input.int(36, minval=1, title="Length")
- // CALCULATIONS
- main_line = ta.ema(hl2, len_main)
- price_line = ta.ema(hl2, 3)
- stdev_main = ta.stdev(hl2, len_main)
- z_score = (price_line - main_line) / stdev_main
- sigmoid = 2 * (math.pow(1 + math.exp(-z_score), -1) - 0.5)
- // COLORS
- black_transp = color.new(color.black, 100)
- red = color.new(color.red, 60)
- green = color.new(color.green, 60)
- // LINES
- l_100_up = hline(1, linestyle=hline.style_solid, editable=false)
- l_50_up = hline(0.5, linestyle=hline.style_dotted, editable=false)
- l_00 = hline(0, color=black_transp, editable=false)
- l_50_dw = hline(-0.5, linestyle=hline.style_dotted, editable=false)
- l_100_dw = hline(-1, linestyle=hline.style_solid, editable=false)
- // PLOT
- fill(l_100_up, l_00, 1, 0, red, black_transp, editable=false)
- fill(l_100_dw, l_00, 0, -1, black_transp, green, editable=false)
- plot(sigmoid, title="Sigmoid", color=color.blue, style=plot.style_line, editable=false)
- 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