Advertisement
xmd79

Oscar osc

Jan 2nd, 2023
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.79 KB | None | 0 0
  1. //@version=5
  2. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  3. // © GenZai 18-08-2021 v5
  4.  
  5. indicator('OSCAR', timeframe='')
  6. len = input(title='Oscar Candles', defval=8)
  7. slowLen = input(title='Slow Oscar Candles', defval=16)
  8. smoothing = input.string(title='Oscar Smoothing', defval='RMA', options=['RMA', 'SMA', 'EMA', 'WMA', 'LSMA', 'HMA', 'NONE'])
  9. slowOscarSmoothing = input.string(title='Slow Oscar Smoothing', defval='WMA', options=['RMA', 'SMA', 'EMA', 'WMA', 'LSMA', 'HMA', 'NONE'])
  10. crossSignalSensitivity = input.float(title='Cross Signal Sensitivity', defval=0.5, step=0.1)
  11. OscarOfIndicator = input(title='Choose input type', defval=close)
  12. bottomSignalLine = input.int(title='Bottom Signal Line', defval=35, step=5)
  13. topSignalLine = input.int(title='Top Signal Line', defval=65, step=5)
  14.  
  15.  
  16. ma(smoothing, OscarParam, len) =>
  17. if smoothing == 'RMA'
  18. ta.rma(OscarParam, len)
  19. else
  20. if smoothing == 'SMA'
  21. ta.sma(OscarParam, len)
  22. else
  23. if smoothing == 'EMA'
  24. ta.ema(OscarParam, len)
  25. else
  26. if smoothing == 'WMA'
  27. ta.wma(OscarParam, len)
  28. else
  29. if smoothing == 'LSMA'
  30. ta.linreg(OscarParam, len, 0)
  31. else
  32. if smoothing == 'HMA'
  33. ta.hma(OscarParam, len)
  34. else
  35. OscarParam
  36.  
  37. A = ta.highest(OscarOfIndicator, len)
  38. B = ta.lowest(OscarOfIndicator, len)
  39. OscarRough = (OscarOfIndicator - B) / (A - B) * 100
  40. Oscar1 = OscarRough[1] / 3 * 2
  41. OscarThird = OscarRough / 3
  42. Oscar = Oscar1 + OscarThird
  43. smoothedOscarRough = ma(smoothing, OscarRough, len)
  44. smoothedOscar = ma(smoothing, Oscar, len)
  45. plot(smoothedOscarRough, title='Oscar Rough', linewidth=2, color=color.new(color.green, 0))
  46. plot(smoothedOscar, title='Oscar', linewidth=2, color=color.new(color.red, 0))
  47. hline(bottomSignalLine, title='Bottom Signal', color=color.green, linestyle=hline.style_dashed)
  48. hline(topSignalLine, title='Top Signal', color=color.red, linestyle=hline.style_dashed)
  49. hline(20, title='Bottom Level', color=color.gray, linestyle=hline.style_dashed)
  50. hline(80, title='Top Level', color=color.gray, linestyle=hline.style_dashed)
  51.  
  52. crossSensitivity = math.max(smoothedOscarRough, smoothedOscar) - math.min(smoothedOscarRough, smoothedOscar)
  53. plotchar(crossSensitivity, 'cross sensitivity Value', '', location=location.top, color=color.new(color.blue, 0))
  54.  
  55. plotshape(ta.crossover(smoothedOscarRough, smoothedOscar) and crossSensitivity > crossSignalSensitivity and smoothedOscarRough < bottomSignalLine, color=color.new(color.green, 0), style=shape.triangleup, location=location.bottom)
  56. 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)
  57. plotshape(ta.crossunder(smoothedOscarRough, smoothedOscar) and crossSensitivity > crossSignalSensitivity and smoothedOscarRough > topSignalLine, color=color.new(color.red, 0), style=shape.triangledown, location=location.top)
  58. 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)
  59.  
  60. // Slow Oscar
  61.  
  62. slowOscarMa(slowOscarSmoothing, slowOscarParam, slowLen) =>
  63. if slowOscarSmoothing == 'RMA'
  64. ta.rma(slowOscarParam, slowLen)
  65. else
  66. if slowOscarSmoothing == 'SMA'
  67. ta.sma(slowOscarParam, slowLen)
  68. else
  69. if slowOscarSmoothing == 'EMA'
  70. ta.ema(slowOscarParam, slowLen)
  71. else
  72. if slowOscarSmoothing == 'WMA'
  73. ta.wma(slowOscarParam, slowLen)
  74. else
  75. if slowOscarSmoothing == 'LSMA'
  76. ta.linreg(slowOscarParam, slowLen, 0)
  77. else
  78. if slowOscarSmoothing == 'HMA'
  79. ta.hma(slowOscarParam, slowLen)
  80. else
  81. slowOscarParam
  82.  
  83. slowA = ta.highest(OscarOfIndicator, slowLen)
  84. slowB = ta.lowest(OscarOfIndicator, slowLen)
  85. slowOscarRough = (OscarOfIndicator - slowB) / (slowA - slowB) * 100
  86. slowOscar1 = slowOscarRough[1] / 3 * 2
  87. slowOscarThird = slowOscarRough / 3
  88. slowOscar = slowOscar1 + slowOscarThird
  89. smoothedSlowOscar = slowOscarMa(slowOscarSmoothing, slowOscar, slowLen)
  90. plot(smoothedSlowOscar, title='slowOscar', linewidth=2, color=color.new(color.purple, 0), display=display.none)
  91.  
  92.  
  93.  
  94.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement