Advertisement
Al0rse

Multi Supertrend [Alorse] 1.2

Nov 3rd, 2021 (edited)
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.08 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. // © alorse
  3.  
  4. //@version=5
  5. indicator("Multi Supertrend [Alorse]", overlay=true)
  6.  
  7. atrPeriod = input.int(10, "ATR Length")
  8. factor = input.float(3.0, "Factor", step = 0.01)
  9.  
  10. pine_rma(src, length) =>
  11. alpha = 1/length
  12. sum = 0.0
  13. sum := na(sum[1]) ? ta.sma(src, length) : alpha * src + (1 - alpha) * nz(sum[1])
  14.  
  15. //the same on pine
  16. pine_atr(length, hi, lo, cl) =>
  17. trueRange = na(hi[1])? hi-lo : math.max(math.max(hi - lo, math.abs(hi - cl[1])), math.abs(lo - cl[1]))
  18. //true range can be also calculated with ta.tr(true)
  19. //ta.rma(trueRange, length)
  20. pine_rma(trueRange, length)
  21.  
  22. // Timeframe
  23. timeframeSetUp(number) =>
  24. switch number
  25. '60' => '1H'
  26. '120' => '2h'
  27. '180' => '3H'
  28. '240' => '4H'
  29. 'D' => '1D'
  30. => number + ' minutos'
  31.  
  32. screenerFunc(_ticker, atrP, fac) =>
  33. [cl, hl, lo, hi] = request.security(_ticker, timeframe.period, [close, hl2, low, high])
  34. // atr = ta.atr(atrP)
  35. atr = pine_atr(atrP, hi, lo, cl)
  36. up = hl - fac * atr
  37. up1 = nz(up[1], up)
  38. up := cl[1] > up1 ? math.max(up, up1) : up
  39. dn = hl + fac * atr
  40. dn1 = nz(dn[1], dn)
  41. dn := cl[1] < dn1 ? math.min(dn, dn1) : dn
  42. trend = 1
  43. trend := nz(trend[1], trend)
  44. trend := trend == -1 and cl > dn1 ? 1 : trend == 1 and cl < up1 ? -1 : trend
  45.  
  46. inHours = timeframeSetUp(timeframe.period)
  47. cleanTicker = str.replace_all(_ticker, 'BINGBON:', '')
  48.  
  49. if trend == 1 and trend[1] == -1
  50. alert('{"text": "🟢 COMPRA EN ' + cleanTicker + ' - ' + inHours + '"}', alert.freq_once_per_bar_close)
  51. if syminfo.tickerid == _ticker
  52. label.new(bar_index, lo, "Buy", color=color.green, style=label.style_label_up, textcolor=color.white, size=size.small)
  53. if trend == -1 and trend[1] == 1
  54. alert('{"text": "🔴 VENTA EN ' + cleanTicker + ' - ' + inHours + '"}', alert.freq_once_per_bar_close)
  55. if syminfo.tickerid == _ticker
  56. label.new(bar_index, hi, "Sell", color=color.red, style=label.style_label_down, textcolor=color.white, size=size.small)
  57.  
  58.  
  59. // Symbols
  60. // There is a limit of 40 security calls so only 40 symbols at the same time is possible
  61.  
  62. e01 = input.bool(title='', defval=true, group='Symbol 1', inline='s01')
  63. s01 = input.symbol('BTCUSDT', title='', group='Symbol 1', inline='s01')
  64.  
  65. e02 = input.bool(title='', defval=true, group='Symbol 2', inline='s02')
  66. s02 = input.symbol('ETHUSDT', title='', group='Symbol 2', inline='s02')
  67.  
  68. e03 = input.bool(title='', defval=true, group='Symbol 3', inline='s03')
  69. s03 = input.symbol('BNBUSDT', title='', group='Symbol 3', inline='s03')
  70.  
  71. e04 = input.bool(title='', defval=true, group='Symbol 4', inline='s04')
  72. s04 = input.symbol('ADAUSDT', title='', group='Symbol 4', inline='s04')
  73.  
  74. e05 = input.bool(title='', defval=true, group='Symbol 5', inline='s05')
  75. s05 = input.symbol('XRPUSDT', title='', group='Symbol 5', inline='s05')
  76.  
  77. e06 = input.bool(title='', defval=true, group='Symbol 6', inline='s06')
  78. s06 = input.symbol('SOLUSDT', title='', group='Symbol 6', inline='s06')
  79.  
  80. e07 = input.bool(title='', defval=true, group='Symbol 7', inline='s07')
  81. s07 = input.symbol('DOTUSDT', title='', group='Symbol 7', inline='s07')
  82.  
  83. e08 = input.bool(title='', defval=true, group='Symbol 8', inline='s08')
  84. s08 = input.symbol('DOGEUSDT', title='', group='Symbol 8', inline='s08')
  85.  
  86. e09 = input.bool(title='', defval=true, group='Symbol 9', inline='s09')
  87. s09 = input.symbol('UNIUSDT', title='', group='Symbol 9', inline='s09')
  88.  
  89. e10 = input.bool(title='', defval=true, group='Symbol 10', inline='s10')
  90. s10 = input.symbol('LUNAUSDT', title='', group='Symbol 10', inline='s10')
  91.  
  92. e11 = input.bool(title='', defval=true, group='Symbol 11', inline='s11')
  93. s11 = input.symbol('AVAXUSDT', title='', group='Symbol 11', inline='s11')
  94.  
  95. e12 = input.bool(title='', defval=true, group='Symbol 12', inline='s12')
  96. s12 = input.symbol('LTCUSDT', title='', group='Symbol 12', inline='s12')
  97.  
  98. e13 = input.bool(title='', defval=true, group='Symbol 13', inline='s13')
  99. s13 = input.symbol('SHIBUSDT', title='', group='Symbol 13', inline='s13')
  100.  
  101. e14 = input.bool(title='', defval=true, group='Symbol 14', inline='s14')
  102. s14 = input.symbol('LINKUSDT', title='', group='Symbol 14', inline='s14')
  103.  
  104. e15 = input.bool(title='', defval=true, group='Symbol 15', inline='s15')
  105. s15 = input.symbol('BCHUSDT', title='', group='Symbol 15', inline='s15')
  106.  
  107. e16 = input.bool(title='', defval=true, group='Symbol 16', inline='s16')
  108. s16 = input.symbol('ALGOUSDT', title='', group='Symbol 16', inline='s16')
  109.  
  110. e17 = input.bool(title='', defval=true, group='Symbol 17', inline='s17')
  111. s17 = input.symbol('XLMUSDT', title='', group='Symbol 17', inline='s17')
  112.  
  113. e18 = input.bool(title='', defval=true, group='Symbol 18', inline='s18')
  114. s18 = input.symbol('MATICUSDT', title='', group='Symbol 18', inline='s18')
  115.  
  116. e19 = input.bool(title='', defval=true, group='Symbol 19', inline='s19')
  117. s19 = input.symbol('AXSUSDT', title='', group='Symbol 19', inline='s19')
  118.  
  119. e20 = input.bool(title='', defval=true, group='Symbol 20', inline='s20')
  120. s20 = input.symbol('FILUSDT', title='', group='Symbol 20', inline='s20')
  121.  
  122. e21 = input.bool(title='', defval=true, group='Symbol 21', inline='s21')
  123. s21 = input.symbol('ATOMUSDT', title='', group='Symbol 21', inline='s21')
  124.  
  125. e22 = input.bool(title='', defval=true, group='Symbol 22', inline='s22')
  126. s22 = input.symbol('VETUSDT', title='', group='Symbol 22', inline='s22')
  127.  
  128. e23 = input.bool(title='', defval=true, group='Symbol 23', inline='s23')
  129. s23 = input.symbol('ICPUSDT', title='', group='Symbol 23', inline='s23')
  130.  
  131. e24 = input.bool(title='', defval=true, group='Symbol 24', inline='s24')
  132. s24 = input.symbol('TRXUSDT', title='', group='Symbol 24', inline='s24')
  133.  
  134. e25 = input.bool(title='', defval=true, group='Symbol 25', inline='s25')
  135. s25 = input.symbol('ETCUSDT', title='', group='Symbol 25', inline='s25')
  136.  
  137. e26 = input.bool(title='', defval=true, group='Symbol 26', inline='s26')
  138. s26 = input.symbol('XTZUSDT', title='', group='Symbol 26', inline='s26')
  139.  
  140. e27 = input.bool(title='', defval=true, group='Symbol 27', inline='s27')
  141. s27 = input.symbol('THETAUSDT', title='', group='Symbol 27', inline='s27')
  142.  
  143. e28 = input.bool(title='', defval=true, group='Symbol 28', inline='s28')
  144. s28 = input.symbol('HBARUSDT', title='', group='Symbol 28', inline='s28')
  145.  
  146. e29 = input.bool(title='', defval=true, group='Symbol 29', inline='s29')
  147. s29 = input.symbol('FTMUSDT', title='', group='Symbol 29', inline='s29')
  148.  
  149. e30 = input.bool(title='', defval=true, group='Symbol 30', inline='s30')
  150. s30 = input.symbol('XMRUSDT', title='', group='Symbol 30', inline='s30')
  151.  
  152. e31 = input.bool(title='', defval=true, group='Symbol 31', inline='s31')
  153. s31 = input.symbol('EGLDUSDT', title='', group='Symbol 31', inline='s31')
  154.  
  155. e32 = input.bool(title='', defval=true, group='Symbol 32', inline='s32')
  156. s32 = input.symbol('EOSUSDT', title='', group='Symbol 32', inline='s32')
  157.  
  158. e33 = input.bool(title='', defval=true, group='Symbol 33', inline='s33')
  159. s33 = input.symbol('KLAYUSDT', title='', group='Symbol 33', inline='s33')
  160.  
  161. e34 = input.bool(title='', defval=true, group='Symbol 34', inline='s34')
  162. s34 = input.symbol('AAVEUSDT', title='', group='Symbol 34', inline='s34')
  163.  
  164. e35 = input.bool(title='', defval=true, group='Symbol 35', inline='s35')
  165. s35 = input.symbol('IOTAUSDT', title='', group='Symbol 35', inline='s35')
  166.  
  167. e36 = input.bool(title='', defval=true, group='Symbol 36', inline='s36')
  168. s36 = input.symbol('NEARUSDT', title='', group='Symbol 36', inline='s36')
  169.  
  170. e37 = input.bool(title='', defval=true, group='Symbol 37', inline='s37')
  171. s37 = input.symbol('WAVESUSDT', title='', group='Symbol 37', inline='s37')
  172.  
  173. e38 = input.bool(title='', defval=true, group='Symbol 38', inline='s38')
  174. s38 = input.symbol('GRTUSDT', title='', group='Symbol 38', inline='s38')
  175.  
  176. e39 = input.bool(title='', defval=true, group='Symbol 39', inline='s39')
  177. s39 = input.symbol('NEOUSDT', title='', group='Symbol 39', inline='s39')
  178.  
  179. e40 = input.bool(title='', defval=true, group='Symbol 40', inline='s40')
  180. s40 = input.symbol('KSMUSDT', title='', group='Symbol 40', inline='s40')
  181.  
  182. if e01
  183. screenerFunc(s01, atrPeriod, factor)
  184. if e02
  185. screenerFunc(s02, atrPeriod, factor)
  186. if e03
  187. screenerFunc(s03, atrPeriod, factor)
  188. if e04
  189. screenerFunc(s04, atrPeriod, factor)
  190. if e05
  191. screenerFunc(s05, atrPeriod, factor)
  192. if e06
  193. screenerFunc(s06, atrPeriod, factor)
  194. if e07
  195. screenerFunc(s07, atrPeriod, factor)
  196. if e08
  197. screenerFunc(s08, atrPeriod, factor)
  198. if e09
  199. screenerFunc(s09, atrPeriod, factor)
  200. if e10
  201. screenerFunc(s10, atrPeriod, factor)
  202. if e11
  203. screenerFunc(s11, atrPeriod, factor)
  204. if e12
  205. screenerFunc(s12, atrPeriod, factor)
  206. if e13
  207. screenerFunc(s13, atrPeriod, factor)
  208. if e14
  209. screenerFunc(s14, atrPeriod, factor)
  210. if e15
  211. screenerFunc(s15, atrPeriod, factor)
  212. if e16
  213. screenerFunc(s16, atrPeriod, factor)
  214. if e17
  215. screenerFunc(s17, atrPeriod, factor)
  216. if e18
  217. screenerFunc(s18, atrPeriod, factor)
  218. if e19
  219. screenerFunc(s19, atrPeriod, factor)
  220. if e20
  221. screenerFunc(s20, atrPeriod, factor)
  222. if e21
  223. screenerFunc(s21, atrPeriod, factor)
  224. if e22
  225. screenerFunc(s22, atrPeriod, factor)
  226. if e23
  227. screenerFunc(s23, atrPeriod, factor)
  228. if e24
  229. screenerFunc(s24, atrPeriod, factor)
  230. if e25
  231. screenerFunc(s25, atrPeriod, factor)
  232. if e26
  233. screenerFunc(s26, atrPeriod, factor)
  234. if e27
  235. screenerFunc(s27, atrPeriod, factor)
  236. if e28
  237. screenerFunc(s28, atrPeriod, factor)
  238. if e29
  239. screenerFunc(s29, atrPeriod, factor)
  240. if e30
  241. screenerFunc(s30, atrPeriod, factor)
  242. if e31
  243. screenerFunc(s31, atrPeriod, factor)
  244. if e32
  245. screenerFunc(s32, atrPeriod, factor)
  246. if e33
  247. screenerFunc(s33, atrPeriod, factor)
  248. if e34
  249. screenerFunc(s34, atrPeriod, factor)
  250. if e35
  251. screenerFunc(s35, atrPeriod, factor)
  252. if e36
  253. screenerFunc(s36, atrPeriod, factor)
  254. if e37
  255. screenerFunc(s37, atrPeriod, factor)
  256. if e38
  257. screenerFunc(s38, atrPeriod, factor)
  258. if e39
  259. screenerFunc(s39, atrPeriod, factor)
  260. if e40
  261. screenerFunc(s40, atrPeriod, factor)
  262.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement