Advertisement
Nick42_for_win

FREE ALGOs [EzAlgo SR]

Dec 19th, 2022 (edited)
13,300
4
Never
15
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.34 KB | None | 4 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 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 [EzAlgo SR]", overlay=true)
  34.  
  35. //------------------- EzAlgo SR | https://www.ezalgo.co ----------------------//
  36. // Get user input
  37. enableSR = input(true, "SR On/Off", group="SR")
  38. colorSup = input(#00DBFF, "Support Color", group="SR")
  39. colorRes = input(#E91E63, "Resistance Color", group="SR")
  40. strengthSR = input.int(2, "S/R Strength", 1, group="SR")
  41. lineStyle = input.string("Dotted", "Line Style", ["Solid", "Dotted", "Dashed"], group="SR")
  42. lineWidth = input.int(2, "S/R Line Width", 1, group="SR")
  43. useZones = input(true, "Zones On/Off", group="SR")
  44. useHLZones = input(true, "High Low Zones On/Off", group="SR")
  45. zoneWidth = input.int(2, "Zone Width %", 0, tooltip="it's calculated using % of the distance between highest/lowest in last 300 bars", group="SR")
  46. expandSR = input(true, "Expand SR")
  47. // Functions
  48. percWidth(len, perc) => (ta.highest(len) - ta.lowest(len)) * perc / 100
  49. // Get components
  50. rb = 10
  51. prd = 284
  52. ChannelW = 10
  53. label_loc = 55
  54. style = lineStyle == "Solid" ? line.style_solid : lineStyle == "Dotted" ? line.style_dotted : line.style_dashed
  55. ph = ta.pivothigh(rb, rb)
  56. pl = ta.pivotlow (rb, rb)
  57. sr_levels = array.new_float(21, na)
  58. prdhighest = ta.highest(prd)
  59. prdlowest = ta.lowest(prd)
  60. cwidth = percWidth(prd, ChannelW)
  61. zonePerc = percWidth(300, zoneWidth)
  62. aas = array.new_bool(41, true)
  63. u1 = 0.0, u1 := nz(u1[1])
  64. d1 = 0.0, d1 := nz(d1[1])
  65. highestph = 0.0, highestph := highestph[1]
  66. lowestpl = 0.0, lowestpl := lowestpl[1]
  67. var sr_levs = array.new_float(21, na)
  68. label hlabel = na, label.delete(hlabel[1])
  69. label llabel = na, label.delete(llabel[1])
  70. var sr_lines = array.new_line(21, na)
  71. var sr_linesH = array.new_line(21, na)
  72. var sr_linesL = array.new_line(21, na)
  73. var sr_linesF = array.new_linefill(21, na)
  74. var sr_labels = array.new_label(21, na)
  75. if ph or pl
  76. for x = 0 to array.size(sr_levels) - 1
  77. array.set(sr_levels, x, na)
  78. highestph := prdlowest
  79. lowestpl := prdhighest
  80. countpp = 0
  81. for x = 0 to prd
  82. if na(close[x])
  83. break
  84. if not na(ph[x]) or not na(pl[x])
  85. highestph := math.max(highestph, nz(ph[x], prdlowest), nz(pl[x], prdlowest))
  86. lowestpl := math.min(lowestpl, nz(ph[x], prdhighest), nz(pl[x], prdhighest))
  87. countpp += 1
  88. if countpp > 40
  89. break
  90. if array.get(aas, countpp)
  91. upl = (ph[x] ? high[x + rb] : low[x + rb]) + cwidth
  92. dnl = (ph[x] ? high[x + rb] : low[x + rb]) - cwidth
  93. u1 := countpp == 1 ? upl : u1
  94. d1 := countpp == 1 ? dnl : d1
  95. tmp = array.new_bool(41, true)
  96. cnt = 0
  97. tpoint = 0
  98. for xx = 0 to prd
  99. if na(close[xx])
  100. break
  101. if not na(ph[xx]) or not na(pl[xx])
  102. chg = false
  103. cnt += 1
  104. if cnt > 40
  105. break
  106. if array.get(aas, cnt)
  107. if not na(ph[xx])
  108. if high[xx + rb] <= upl and high[xx + rb] >= dnl
  109. tpoint += 1
  110. chg := true
  111. if not na(pl[xx])
  112. if low[xx + rb] <= upl and low[xx + rb] >= dnl
  113. tpoint += 1
  114. chg := true
  115. if chg and cnt < 41
  116. array.set(tmp, cnt, false)
  117. if tpoint >= strengthSR
  118. for g = 0 to 40 by 1
  119. if not array.get(tmp, g)
  120. array.set(aas, g, false)
  121. if ph[x] and countpp < 21
  122. array.set(sr_levels, countpp, high[x + rb])
  123. if pl[x] and countpp < 21
  124. array.set(sr_levels, countpp, low[x + rb])
  125. // Plot
  126. var line highest_ = na, line.delete(highest_)
  127. var line lowest_ = na, line.delete(lowest_)
  128. var line highest_fill1 = na, line.delete(highest_fill1)
  129. var line highest_fill2 = na, line.delete(highest_fill2)
  130. var line lowest_fill1 = na, line.delete(lowest_fill1)
  131. var line lowest_fill2 = na, line.delete(lowest_fill2)
  132. hi_col = close >= highestph ? colorSup : colorRes
  133. lo_col = close >= lowestpl ? colorSup : colorRes
  134. if enableSR
  135. highest_ := line.new(bar_index - 311, highestph, bar_index, highestph, xloc.bar_index, expandSR ? extend.both : extend.right, hi_col, style, lineWidth)
  136. lowest_ := line.new(bar_index - 311, lowestpl , bar_index, lowestpl , xloc.bar_index, expandSR ? extend.both : extend.right, lo_col, style, lineWidth)
  137. if useHLZones
  138. highest_fill1 := line.new(bar_index - 311, highestph + zonePerc, bar_index, highestph + zonePerc, xloc.bar_index, expandSR ? extend.both : extend.right, na)
  139. highest_fill2 := line.new(bar_index - 311, highestph - zonePerc, bar_index, highestph - zonePerc, xloc.bar_index, expandSR ? extend.both : extend.right, na)
  140. lowest_fill1 := line.new(bar_index - 311, lowestpl + zonePerc , bar_index, lowestpl + zonePerc , xloc.bar_index, expandSR ? extend.both : extend.right, na)
  141. lowest_fill2 := line.new(bar_index - 311, lowestpl - zonePerc , bar_index, lowestpl - zonePerc , xloc.bar_index, expandSR ? extend.both : extend.right, na)
  142. linefill.new(highest_fill1, highest_fill2, color.new(hi_col, 80))
  143. linefill.new(lowest_fill1 , lowest_fill2 , color.new(lo_col, 80))
  144. if ph or pl
  145. for x = 0 to array.size(sr_lines) - 1
  146. array.set(sr_levs, x, array.get(sr_levels, x))
  147. for x = 0 to array.size(sr_lines) - 1
  148. line.delete(array.get(sr_lines, x))
  149. line.delete(array.get(sr_linesH, x))
  150. line.delete(array.get(sr_linesL, x))
  151. linefill.delete(array.get(sr_linesF, x))
  152. if array.get(sr_levs, x) and enableSR
  153. line_col = close >= array.get(sr_levs, x) ? colorSup : colorRes
  154. array.set(sr_lines, x, line.new(bar_index - 355, array.get(sr_levs, x), bar_index, array.get(sr_levs, x), xloc.bar_index, expandSR ? extend.both : extend.right, line_col, style, lineWidth))
  155. if useZones
  156. array.set(sr_linesH, x, line.new(bar_index - 355, array.get(sr_levs, x) + zonePerc, bar_index, array.get(sr_levs, x) + zonePerc, xloc.bar_index, expandSR ? extend.both : extend.right, na))
  157. array.set(sr_linesL, x, line.new(bar_index - 355, array.get(sr_levs, x) - zonePerc, bar_index, array.get(sr_levs, x) - zonePerc, xloc.bar_index, expandSR ? extend.both : extend.right, na))
  158. array.set(sr_linesF, x, linefill.new(array.get(sr_linesH, x), array.get(sr_linesL, x), color.new(line_col, 80)))
  159. for x = 0 to array.size(sr_labels) - 1
  160. label.delete(array.get(sr_labels, x))
  161. if array.get(sr_levs, x) and enableSR
  162. lab_loc = close >= array.get(sr_levs, x) ? label.style_label_up : label.style_label_down
  163. lab_col = close >= array.get(sr_levs, x) ? colorSup : colorRes
  164. array.set(sr_labels, x, label.new(bar_index + label_loc, array.get(sr_levs, x), str.tostring(math.round_to_mintick(array.get(sr_levs, x))), color=lab_col , textcolor=#000000, style=lab_loc))
  165. hlabel := enableSR ? label.new(bar_index + label_loc + math.round(math.sign(label_loc)) * 20, highestph, "High Level : " + str.tostring(highestph), color=hi_col, textcolor=#000000, style=label.style_label_down) : na
  166. llabel := enableSR ? label.new(bar_index + label_loc + math.round(math.sign(label_loc)) * 20, lowestpl , "Low Level : " + str.tostring(lowestpl) , color=lo_col, textcolor=#000000, style=label.style_label_up ) : na
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement