xmd79

Outback RSI & Hull [TTF]

Oct 21st, 2022
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © TheTrdFloor
  3. //
  4. // We built this indicator to help simplify some of the setup for our Outback strategy, was many were having trouble setting up the
  5. // Hull Suite on top of the RSI using the Indicator on Indicator method.
  6. //
  7. //@version=5
  8. indicator(title="Outback RSI & Hull [TTF]", shorttitle="Outback RSI & Hull [TTF]", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
  9.  
  10. ///////////////////////////// Standard RSI /////////////////////////////
  11.  
  12. ma(source, length, type) =>
  13. switch type
  14. "SMA" => ta.sma(source, length)
  15. "Bollinger Bands" => ta.sma(source, length)
  16. "EMA" => ta.ema(source, length)
  17. "SMMA (RMA)" => ta.rma(source, length)
  18. "WMA" => ta.wma(source, length)
  19. "VWMA" => ta.vwma(source, length)
  20.  
  21. rsiLengthInput = input.int(618, minval=1, title="RSI Length", group="RSI Settings")
  22. rsiSourceInput = input.source(close, "Source", group="RSI Settings")
  23. rsitrigger = input.int(50, title="RSI Trigger Level", group="RSI Settings", tooltip="RSI Trigger Level for safe entry")
  24. usersitrigger = input.bool(false, title="Display Safe Entries", group="RSI Settings", tooltip="If activated, background coloring will differentiate between risk entry and safe entry (RSI above/below RSI trigger level")
  25. maTypeInput = input.string("SMA", title="MA Type", options=["SMA", "Bollinger Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="MA Settings")
  26. maLengthInput = input.int(200, title="MA Length", group="MA Settings")
  27. bbMultInput = input.float(2.0, minval=0.001, maxval=50, title="BB StdDev", group="MA Settings")
  28.  
  29. up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
  30. down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
  31. rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
  32. rsiMA = ma(rsi, maLengthInput, maTypeInput)
  33. isBB = maTypeInput == "Bollinger Bands"
  34.  
  35. plot(rsi, "RSI", color=#7E57C2)
  36. plot(rsiMA, "RSI-based MA", color=color.white)
  37. hline(50, "RSI Middle Band", color=color.new(#787B86, 50))
  38.  
  39.  
  40.  
  41. ///////////////////////////// Hull Suite by Insilico ///////////////////////////////////
  42.  
  43. length3 = input(227, title='MA Length', group = "Hull Suite")
  44. lengthMult = input(2.0, title="Length multiplier", group = "Hull Suite")
  45.  
  46. MHULL = ta.wma(2 * ta.wma(rsi,int(length3 * lengthMult) / 2) - ta.wma(rsi, int(length3 * lengthMult)), math.round(math.sqrt(int(length3 * lengthMult))))
  47.  
  48. plot(MHULL, "Hull", color=color.yellow)
  49.  
  50.  
  51. ///////////////////////////// Background filled based on Outback Criteria ///////////////////////////////////
  52.  
  53. riskentrylong = usersitrigger ? (rsi>rsiMA and rsi>MHULL and rsi<rsitrigger ? true : false) : rsi>rsiMA and rsi>MHULL ? true : false
  54. entrylong = rsi>rsiMA and rsi>MHULL and rsi>rsitrigger ? true : false
  55.  
  56. riskentryshort = usersitrigger ? (rsi<rsiMA and rsi<MHULL and rsi>rsitrigger ? true : false) : rsi<rsiMA and rsi<MHULL ? true : false
  57. entryshort = rsi<rsiMA and rsi<MHULL and rsi<rsitrigger ? true : false
  58.  
  59. bgcolor(riskentrylong ? color.new(#056656,50) : na, title="Risk Entry Long")
  60. bgcolor(entrylong and usersitrigger ? color.new(#00332a,50) : na, title="Safe Entry Long")
  61. bgcolor(riskentryshort ? color.new(#ff9800, 50) : na, title="Risk Entry Short")
  62. bgcolor(entryshort and usersitrigger ? color.new(#e65100, 50) : na, title="Safe Entry Short")
Advertisement
Add Comment
Please, Sign In to add comment