Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © GenZai 18-08-2021 v5
- indicator('OSCAR', timeframe='')
- len = input(title='Oscar Candles', defval=8)
- slowLen = input(title='Slow Oscar Candles', defval=16)
- smoothing = input.string(title='Oscar Smoothing', defval='RMA', options=['RMA', 'SMA', 'EMA', 'WMA', 'LSMA', 'HMA', 'NONE'])
- slowOscarSmoothing = input.string(title='Slow Oscar Smoothing', defval='WMA', options=['RMA', 'SMA', 'EMA', 'WMA', 'LSMA', 'HMA', 'NONE'])
- crossSignalSensitivity = input.float(title='Cross Signal Sensitivity', defval=0.5, step=0.1)
- OscarOfIndicator = input(title='Choose input type', defval=close)
- bottomSignalLine = input.int(title='Bottom Signal Line', defval=35, step=5)
- topSignalLine = input.int(title='Top Signal Line', defval=65, step=5)
- ma(smoothing, OscarParam, len) =>
- if smoothing == 'RMA'
- ta.rma(OscarParam, len)
- else
- if smoothing == 'SMA'
- ta.sma(OscarParam, len)
- else
- if smoothing == 'EMA'
- ta.ema(OscarParam, len)
- else
- if smoothing == 'WMA'
- ta.wma(OscarParam, len)
- else
- if smoothing == 'LSMA'
- ta.linreg(OscarParam, len, 0)
- else
- if smoothing == 'HMA'
- ta.hma(OscarParam, len)
- else
- OscarParam
- A = ta.highest(OscarOfIndicator, len)
- B = ta.lowest(OscarOfIndicator, len)
- OscarRough = (OscarOfIndicator - B) / (A - B) * 100
- Oscar1 = OscarRough[1] / 3 * 2
- OscarThird = OscarRough / 3
- Oscar = Oscar1 + OscarThird
- smoothedOscarRough = ma(smoothing, OscarRough, len)
- smoothedOscar = ma(smoothing, Oscar, len)
- plot(smoothedOscarRough, title='Oscar Rough', linewidth=2, color=color.new(color.green, 0))
- plot(smoothedOscar, title='Oscar', linewidth=2, color=color.new(color.red, 0))
- hline(bottomSignalLine, title='Bottom Signal', color=color.green, linestyle=hline.style_dashed)
- hline(topSignalLine, title='Top Signal', color=color.red, linestyle=hline.style_dashed)
- hline(20, title='Bottom Level', color=color.gray, linestyle=hline.style_dashed)
- hline(80, title='Top Level', color=color.gray, linestyle=hline.style_dashed)
- crossSensitivity = math.max(smoothedOscarRough, smoothedOscar) - math.min(smoothedOscarRough, smoothedOscar)
- plotchar(crossSensitivity, 'cross sensitivity Value', '', location=location.top, color=color.new(color.blue, 0))
- plotshape(ta.crossover(smoothedOscarRough, smoothedOscar) and crossSensitivity > crossSignalSensitivity and smoothedOscarRough < bottomSignalLine, color=color.new(color.green, 0), style=shape.triangleup, location=location.bottom)
- plotshape(ta.crossover(smoothedOscarRough, smoothedOscar)[1] and crossSensitivity > crossSignalSensitivity and smoothedOscarRough > smoothedOscar and smoothedOscar < bottomSignalLine, color=color.new(color.green, 0), style=shape.arrowup, location=location.bottom)
- plotshape(ta.crossunder(smoothedOscarRough, smoothedOscar) and crossSensitivity > crossSignalSensitivity and smoothedOscarRough > topSignalLine, color=color.new(color.red, 0), style=shape.triangledown, location=location.top)
- plotshape(ta.crossunder(smoothedOscarRough, smoothedOscar)[1] and crossSensitivity > crossSignalSensitivity and smoothedOscar > smoothedOscarRough and smoothedOscar > topSignalLine, color=color.new(color.red, 0), style=shape.arrowdown, location=location.top)
- // Slow Oscar
- slowOscarMa(slowOscarSmoothing, slowOscarParam, slowLen) =>
- if slowOscarSmoothing == 'RMA'
- ta.rma(slowOscarParam, slowLen)
- else
- if slowOscarSmoothing == 'SMA'
- ta.sma(slowOscarParam, slowLen)
- else
- if slowOscarSmoothing == 'EMA'
- ta.ema(slowOscarParam, slowLen)
- else
- if slowOscarSmoothing == 'WMA'
- ta.wma(slowOscarParam, slowLen)
- else
- if slowOscarSmoothing == 'LSMA'
- ta.linreg(slowOscarParam, slowLen, 0)
- else
- if slowOscarSmoothing == 'HMA'
- ta.hma(slowOscarParam, slowLen)
- else
- slowOscarParam
- slowA = ta.highest(OscarOfIndicator, slowLen)
- slowB = ta.lowest(OscarOfIndicator, slowLen)
- slowOscarRough = (OscarOfIndicator - slowB) / (slowA - slowB) * 100
- slowOscar1 = slowOscarRough[1] / 3 * 2
- slowOscarThird = slowOscarRough / 3
- slowOscar = slowOscar1 + slowOscarThird
- smoothedSlowOscar = slowOscarMa(slowOscarSmoothing, slowOscar, slowLen)
- plot(smoothedSlowOscar, title='slowOscar', linewidth=2, color=color.new(color.purple, 0), display=display.none)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement