Nick42_for_win

FREE ALGOs [TBO]

Mar 9th, 2022 (edited)
2,396
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.79 KB | None | 0 0
  1. // 8888888888 8888888b. 8888888888 8888888888 d8888 888 .d8888b. .d88888b. As you
  2. // 888 888 Y88b 888 888 d88888 888 d88P Y88b d88P" "Y88b Can see
  3. // 888 888 888 888 888 d88P888 888 888 888 888 888 Are all
  4. // 8888888 888 d88P 8888888 8888888 d88P 888 888 888 888 888 .d8888b Basic free
  5. // 888 8888888P" 888 888 d88P 888 888 888 88888 888 888 88K tradingview
  6. // 888 888 T88b 888 888 d88P 888 888 888 888 888 888 "Y8888b. indicators
  7. // 888 888 T88b 888 888 d8888888888 888 Y88b d88P Y88b. .d88P X88 repackaged
  8. // 888 888 T88b 8888888888 8888888888 d88P 888 88888888 "Y8888P88 "Y88888P" 88888P' into one
  9. //
  10. // FAQ
  11. //
  12. // Why?
  13. // I want you to see what you are willing to pay hundereds of dollars a month
  14.  
  15. // Has the code been leaked/hacked?
  16. // No, this code has been created from scratch only using common sense and public information from the internet
  17.  
  18. // What's the accuracy I can expect from this version of the indicator?
  19. // I'd say it's about 95% the same as the one you would pay
  20.  
  21. // The indicator needs to be updated?
  22. // Write me a private message on TradingView (Nick42_for_win)
  23.  
  24. // Can I suggest an indicator to get a FREE ALGOs version?
  25. // Write me a private message on TradingView (Nick42_for_win)
  26.  
  27. // Do you get any monetary return from this project?
  28. // Nope, 0$
  29.  
  30. // Enjoy ;)
  31.  
  32. //@version=5
  33. indicator("FREE ALGOs [TBO]", overlay=true)
  34.  
  35. //------------------------- TBO | https://www.thebettertraders.com -----------//
  36. // Get user input
  37. bool enableCustomTBO = input(false, "Enable?", "Custom trend settings are not enabled by default. The default settings loaded are not shown publicly. You have the option to enter your own custom settings as you get more familiar with the TBO.", group="CUSTOM TREND STRENGTH SETTINGS")
  38. var fastLen = input.int(1, "TBO Fast", 1, group="CUSTOM TREND STRENGTH SETTINGS")
  39. var mediumLen = input.int(2, "TBO Medium", 2, group="CUSTOM TREND STRENGTH SETTINGS")
  40. var medfastLen = input.int(3, "TBO Med Fast", 3, group="CUSTOM TREND STRENGTH SETTINGS")
  41. var slowLen = input.int(4, "TBO Slow", 4, group="CUSTOM TREND STRENGTH SETTINGS")
  42. bool enableRSI = input(false, "Enable?", "Enable this if you wish to combine an RSI requirement with the TBO Long or TBO Short signal. The default settings shown here have no importance, they are just placeholders and are not significant. It is raccomended to have the RSI showing when this is enabled so you can see what kind of settings will work.", group="TBO LONG/SHORT W/ RSI")
  43. var shortRsiBand = input.int(70, "Short RSI Band", 1, 100, group="TBO LONG/SHORT W/ RSI")
  44. var shortBandGL = input.string("Greater Than", "Greater/Less Than", ["Greater Than", "Less Than"], group="TBO LONG/SHORT W/ RSI")
  45. var longRsiBand = input.int(30, "Long RSI Band", 1, 100, group="TBO LONG/SHORT W/ RSI")
  46. var longBandGL = input.string("Less Than", "Greater/Less Than", ["Greater Than", "Less Than"], group="TBO LONG/SHORT W/ RSI")
  47. var rsiLen = input.int(14, "TBO Med Fast", 1, group="TBO LONG/SHORT W/ RSI")
  48. bool enableTP = input(false, "Enable?", group="TAKE PROFIT SETTINGS")
  49. var longTPperc = input.int(9, "TP Long %", 1, group="TAKE PROFIT SETTINGS")
  50. var shortTPperc = input.int(9, "TP Short %", 1, group="TAKE PROFIT SETTINGS")
  51. bool static = input(false, "Static", "If enabled will plot a signal every time volume gets greater than your defined value.", group="DHP VOLUME SCALPING")
  52. var volThreshold = input.int(20000, "Volume", 1, group="DHP VOLUME SCALPING")
  53. bool maMultiple = input(false, "MA Multiple", "If enabled will plot a signal every time volume gets greater than his average multiplied by your defined value.", group="DHP VOLUME SCALPING")
  54. var average = input.int(20, "Average", 2, tooltip="Number of bars back used to calculate the volume's average.", group="DHP VOLUME SCALPING")
  55. var multipleX = input.int(3, "Multiple X", 1, tooltip="Number of times the volume's average will be multiplied.", group="DHP VOLUME SCALPING")
  56. // Functions
  57. bb(src, len, mult) =>
  58. float basis = ta.ema(src, len)
  59. float dev = mult * ta.stdev(src, len)
  60. [basis, basis + dev, basis - dev]
  61. [_, upperBB, lowerBB] = bb(close, 25, 1)
  62. isLast(var1, var2) => ta.barssince(var1) < ta.barssince(var2)
  63. // Get components
  64. float fastTBO = ta.ema(close, enableCustomTBO ? fastLen : 20)
  65. float mediumTBO = ta.ema(close, enableCustomTBO ? mediumLen : 40)
  66. float medfastTBO = ta.sma(close, enableCustomTBO ? medfastLen : 50)
  67. float slowTBO = ta.sma(close, enableCustomTBO ? slowLen : 150)
  68. float rsi = ta.rsi(close, rsiLen)
  69. bool rsiShort = enableRSI and shortBandGL == "Greater Than" ? (rsi > shortRsiBand) : (rsi < shortRsiBand)
  70. bool rsiLong = enableRSI and longBandGL == "Less Than" ? (rsi < longRsiBand) : (rsi > longRsiBand)
  71. float vol = volume
  72. float volMA = ta.sma(vol, average) * multipleX
  73. bool openLong = ta.crossover(fastTBO, mediumTBO) and rsiLong, lastLong = ta.barssince(openLong), long = ta.crossover(fastTBO, mediumTBO)
  74. bool openShort = ta.crossunder(fastTBO, mediumTBO) and rsiShort, lastShort = ta.barssince(openShort), short = ta.crossunder(fastTBO, mediumTBO)
  75. bool closeLong = fastTBO > slowTBO and mediumTBO > medfastTBO and medfastTBO > slowTBO and ta.crossunder(close, mediumTBO)
  76. bool closeShort = fastTBO < slowTBO and mediumTBO < medfastTBO and medfastTBO < slowTBO and ta.crossover(close, mediumTBO)
  77. float longTP = enableTP ? (lastLong < lastShort ? close[lastLong] * (1 + longTPperc / 100) : na) : na, longTpHit = ta.crossover(close, longTP)
  78. float shortTP = enableTP ? (lastLong > lastShort ? close[lastShort] * (1 - shortTPperc / 100) : na) : na, shortTpHit = ta.crossunder(close, shortTP)
  79. bool crossUp = ta.crossover(mediumTBO, medfastTBO)
  80. bool crossDown = ta.crossunder(mediumTBO, medfastTBO)
  81. bool staticLongPump = static and close > fastTBO and vol > volThreshold
  82. bool staticShortPump = static and close < fastTBO and vol > volThreshold
  83. bool maLongPump = maMultiple and close > fastTBO and vol > volMA
  84. bool maShortPump = maMultiple and close < fastTBO and vol > volMA
  85. float resistance = 0.0, resistance := ta.crossunder(close, upperBB) ? high : resistance[1]
  86. float support = 0.0, support := ta.crossover(close, lowerBB) ? low : support[1]
  87. bool breakout = close > fastTBO and open > fastTBO and mediumTBO > slowTBO and ta.highest(50) > ta.highest(50)[1]
  88. bool breakdown = close < fastTBO and open < fastTBO and mediumTBO < slowTBO and ta.lowest(50) < ta.lowest(50)[1]
  89. bool breakoutZone = isLast(long, short) and isLast(crossUp, crossDown)
  90. bool breakdownZone = isLast(short, long) and isLast(crossDown, crossUp)
  91. int countBreakout = 0, countBreakout := breakout and breakoutZone ? countBreakout[1] + 1 : long or breakdownZone ? 0 : countBreakout[1]
  92. int countBreakdown = 0, countBreakdown := breakdown and breakdownZone ? countBreakdown[1] + 1 : short or breakoutZone ? 0 : countBreakdown[1]
  93. // Colors
  94. green = #2FD282, lightGreen = #86C8B9
  95. red = color.red
  96. blue = color.blue
  97. orange = color.orange
  98. pink = #E34DED, lightPink = #F283B8
  99. yellow = color.yellow
  100. white = color.white
  101. // Plots
  102. p1 = plot(fastTBO, "TBO Fast", fastTBO > mediumTBO ? lightGreen : lightPink, 3)
  103. p2 = plot(mediumTBO, "TBO Medium", mediumTBO > slowTBO ? color.new(#42BDA8, 97.5) : color.new(lightPink, 97.5))
  104. p3 = plot(medfastTBO, "TBO Med Fast", medfastTBO > slowTBO ? color.new(#42BDA8, 97.5) : color.new(lightPink, 97.5))
  105. p4 = plot(slowTBO, "TBO Slow", fastTBO > slowTBO ? color.new(#42BDA8, 97.5) : color.new(lightPink, 97.5))
  106. plot(resistance, "Resistance", close <= resistance ? #CC4242 : #3D8C40, 1, plot.style_circles)
  107. plot(support, "Support", close > support ? #3D8C40 : #CC4242, 1, plot.style_circles)
  108. plotshape(breakout and breakoutZone and countBreakout <= 3, "⌂ Breakout", shape.labelup, location.belowbar, white, size=size.tiny)
  109. plotshape(breakdown and breakdownZone and countBreakdown <= 3, "○ Breakdown", shape.circle, location.abovebar, yellow, size=size.tiny)
  110. plotshape(openLong, "▲ Open Long", shape.triangleup, location.belowbar, green, size=size.tiny)
  111. plot(longTP, "Long TP", color.blue, 1, plot.style_circles)
  112. plotshape(crossUp, "✖ Cross Up", shape.xcross, location.abovebar, green, size=size.tiny)
  113. plotshape(crossDown, "✖ Cross Down", shape.xcross, location.belowbar, red, size=size.tiny)
  114. plotshape(closeLong, "◆ Close Long", shape.diamond, location.abovebar, blue, size=size.tiny)
  115. plotshape(openShort, "▼ Open Short", shape.triangledown, location.abovebar, pink, size=size.tiny)
  116. plot(shortTP, "Short TP", color.blue, 1, plot.style_circles)
  117. plotshape(closeShort, "◆ Close Short", shape.diamond, location.belowbar, orange, size=size.tiny)
  118. plotshape(staticShortPump, "Static Short Pump", shape.flag, location.belowbar, white, size=size.tiny)
  119. plotshape(staticLongPump, "Static Long Pump", shape.flag, location.abovebar, white, size=size.tiny)
  120. plotshape(maShortPump, "MA Short Pump", shape.flag, location.belowbar, yellow, size=size.tiny)
  121. plotshape(maLongPump, "MA Long Pump", shape.flag, location.abovebar, yellow, size=size.tiny)
  122. fill(p3, p4, medfastTBO > slowTBO ? color.new(#42BDA8, 75) : color.new(lightPink, 75), "Long Trend")
  123. fill(p2, p3, mediumTBO > medfastTBO ? color.new(#42BDA8, 80) : color.new(lightPink, 80), "Mid Trend")
  124. fill(p1, p2, fastTBO > mediumTBO ? color.new(#42BDA8, 85) : color.new(lightPink, 85), "Short Trend")
  125. // Alerts
  126. alertcondition(breakout and breakoutZone and countBreakout <= 3, "⌂ Breakout", "⌂ Breakout")
  127. alertcondition(openLong, "▲ Open Long", "▲ Open Long")
  128. alertcondition(openShort, "▼ Open Short", "▼ Open Short")
  129. alertcondition(closeLong, "◆ Close Long", "◆ Close Long")
  130. alertcondition(closeShort, "◆ Close Short", "◆ Close Short")
  131. alertcondition(breakdown and breakdownZone and countBreakdown <= 3, "○ Breakdown", "○ Breakdown")
  132. alertcondition(crossDown, "✖ Cross Down", "✖ Cross Down")
  133. alertcondition(crossUp, "✖ Cross Up", "✖ Cross Up")
  134. alertcondition(longTpHit or shortTpHit, "Long or Short TP Hit", "Long or Short TP Hit")
  135. alertcondition(longTpHit, "Long TP", "Long TP")
  136. alertcondition(maLongPump, "MA Long Pump", "MA Long Pump")
  137. alertcondition(maShortPump, "MA Short Pump", "MA Short Pump")
  138. alertcondition(shortTpHit, "Short TP", "Short TP")
  139. alertcondition(staticLongPump, "Static Long Pump", "Static Long Pump")
  140. alertcondition(staticShortPump, "Static Short Pump", "Static Short Pump")
Add Comment
Please, Sign In to add comment