Advertisement
Al0rse

Multi Alert MACD Divegences [Alorse]

Oct 30th, 2021
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.13 KB | None | 0 0
  1. //@version=5
  2. indicator(title='Multi Alert MACD Divegences [Alorse]', shorttitle='Multi Alert MACD Divegences [Alorse]', overlay=true)
  3.  
  4. _inRange(cond, rangeUpper, rangeLower) =>
  5. bars = ta.barssince(cond == true)
  6. rangeLower <= bars and bars <= rangeUpper
  7.  
  8. screenerFunc(_ticker, lbR, lbL, rangeUpper, rangeLower) =>
  9. [cl, lo, hi] = request.security(_ticker, timeframe.period, [close, low, high])
  10. macd = ta.ema(cl, 12) - ta.ema(cl, 26)
  11. dataA = ta.ema(cl, 150)
  12. dataB = ta.ema(cl, 600)
  13. // Regular Bullish
  14. trendBull = dataA > dataB and macd[lbR] < 0
  15. plFound = na(ta.pivotlow(macd, lbL, lbR)) ? false : true
  16. oscHL = macd[lbR] > ta.valuewhen(plFound, macd[lbR], 1) and _inRange(plFound[1], rangeUpper, rangeLower)
  17. priceLL = lo[lbR] < ta.valuewhen(plFound, lo[lbR], 1)
  18. bullCond = priceLL and oscHL and plFound
  19. // Regular Bearish
  20. trendBear = dataA < dataB and macd[lbR] > 0
  21. phFound = na(ta.pivothigh(macd, lbL, lbR)) ? false : true
  22. oscLH = macd[lbR] < ta.valuewhen(phFound, macd[lbR], 1) and _inRange(phFound[1], rangeUpper, rangeLower)
  23. priceHH = hi[lbR] > ta.valuewhen(phFound, hi[lbR], 1)
  24. bearCond = priceHH and oscLH and phFound
  25.  
  26. entrylong = bullCond and trendBull
  27. entryShort = bearCond and trendBear
  28. cleanTicker = str.replace_all(_ticker, 'BINANCE:', '')
  29. if entrylong
  30. alert('{"text": "🟢 ' + cleanTicker + ': Divergencia alcista en ' + timeframe.period + ' minutos"}', alert.freq_once_per_bar_close)
  31. if entryShort
  32. alert('{"text": "🔴 ' + cleanTicker + ': Divergencia bajista en ' + timeframe.period + ' minutos"}', alert.freq_once_per_bar_close)
  33.  
  34. [macd, entrylong, entryShort]
  35.  
  36.  
  37. //Divergences
  38. lbR = input.int(title='Pivot Lookback   Right', defval=2, group='Divergences', inline='pivot')
  39. lbL = input.int(title='Left', defval=2, group='Divergences', inline='pivot')
  40. rangeUpper = input.int(title='Lookback Range   Max', defval=60, group='Divergences', inline='range')
  41. rangeLower = input.int(title='Min', defval=6, group='Divergences', inline='range')
  42.  
  43. // Symbols
  44. // There is a limit of 40 security calls so only 40 symbols at the same time is possible
  45.  
  46. e01 = input.bool(title='', defval=true, group='Symbol 1', inline='s01')
  47. s01 = input.symbol('BTCUSDT', title='', group='Symbol 1', inline='s01')
  48.  
  49. e02 = input.bool(title='', defval=true, group='Symbol 2', inline='s02')
  50. s02 = input.symbol('ETHUSDT', title='', group='Symbol 2', inline='s02')
  51.  
  52. e03 = input.bool(title='', defval=true, group='Symbol 3', inline='s03')
  53. s03 = input.symbol('BNBUSDT', title='', group='Symbol 3', inline='s03')
  54.  
  55. e04 = input.bool(title='', defval=true, group='Symbol 4', inline='s04')
  56. s04 = input.symbol('ADAUSDT', title='', group='Symbol 4', inline='s04')
  57.  
  58. e05 = input.bool(title='', defval=true, group='Symbol 5', inline='s05')
  59. s05 = input.symbol('XRPUSDT', title='', group='Symbol 5', inline='s05')
  60.  
  61. e06 = input.bool(title='', defval=true, group='Symbol 6', inline='s06')
  62. s06 = input.symbol('SOLUSDT', title='', group='Symbol 6', inline='s06')
  63.  
  64. e07 = input.bool(title='', defval=true, group='Symbol 7', inline='s07')
  65. s07 = input.symbol('DOTUSDT', title='', group='Symbol 7', inline='s07')
  66.  
  67. e08 = input.bool(title='', defval=true, group='Symbol 8', inline='s08')
  68. s08 = input.symbol('DOGEUSDT', title='', group='Symbol 8', inline='s08')
  69.  
  70. e09 = input.bool(title='', defval=true, group='Symbol 9', inline='s09')
  71. s09 = input.symbol('UNIUSDT', title='', group='Symbol 9', inline='s09')
  72.  
  73. e10 = input.bool(title='', defval=true, group='Symbol 10', inline='s10')
  74. s10 = input.symbol('LUNAUSDT', title='', group='Symbol 10', inline='s10')
  75.  
  76. e11 = input.bool(title='', defval=true, group='Symbol 11', inline='s11')
  77. s11 = input.symbol('AVAXUSDT', title='', group='Symbol 11', inline='s11')
  78.  
  79. e12 = input.bool(title='', defval=true, group='Symbol 12', inline='s12')
  80. s12 = input.symbol('LTCUSDT', title='', group='Symbol 12', inline='s12')
  81.  
  82. e13 = input.bool(title='', defval=true, group='Symbol 13', inline='s13')
  83. s13 = input.symbol('SHIBUSDT', title='', group='Symbol 13', inline='s13')
  84.  
  85. e14 = input.bool(title='', defval=true, group='Symbol 14', inline='s14')
  86. s14 = input.symbol('LINKUSDT', title='', group='Symbol 14', inline='s14')
  87.  
  88. e15 = input.bool(title='', defval=true, group='Symbol 15', inline='s15')
  89. s15 = input.symbol('BCHUSDT', title='', group='Symbol 15', inline='s15')
  90.  
  91. e16 = input.bool(title='', defval=true, group='Symbol 16', inline='s16')
  92. s16 = input.symbol('ALGOUSDT', title='', group='Symbol 16', inline='s16')
  93.  
  94. e17 = input.bool(title='', defval=true, group='Symbol 17', inline='s17')
  95. s17 = input.symbol('XLMUSDT', title='', group='Symbol 17', inline='s17')
  96.  
  97. e18 = input.bool(title='', defval=true, group='Symbol 18', inline='s18')
  98. s18 = input.symbol('MATICUSDT', title='', group='Symbol 18', inline='s18')
  99.  
  100. e19 = input.bool(title='', defval=true, group='Symbol 19', inline='s19')
  101. s19 = input.symbol('AXSUSDT', title='', group='Symbol 19', inline='s19')
  102.  
  103. e20 = input.bool(title='', defval=true, group='Symbol 20', inline='s20')
  104. s20 = input.symbol('FILUSDT', title='', group='Symbol 20', inline='s20')
  105.  
  106. e21 = input.bool(title='', defval=true, group='Symbol 21', inline='s21')
  107. s21 = input.symbol('ATOMUSDT', title='', group='Symbol 21', inline='s21')
  108.  
  109. e22 = input.bool(title='', defval=true, group='Symbol 22', inline='s22')
  110. s22 = input.symbol('VETUSDT', title='', group='Symbol 22', inline='s22')
  111.  
  112. e23 = input.bool(title='', defval=true, group='Symbol 23', inline='s23')
  113. s23 = input.symbol('ICPUSDT', title='', group='Symbol 23', inline='s23')
  114.  
  115. e24 = input.bool(title='', defval=true, group='Symbol 24', inline='s24')
  116. s24 = input.symbol('TRXUSDT', title='', group='Symbol 24', inline='s24')
  117.  
  118. e25 = input.bool(title='', defval=true, group='Symbol 25', inline='s25')
  119. s25 = input.symbol('ETCUSDT', title='', group='Symbol 25', inline='s25')
  120.  
  121. e26 = input.bool(title='', defval=true, group='Symbol 26', inline='s26')
  122. s26 = input.symbol('XTZUSDT', title='', group='Symbol 26', inline='s26')
  123.  
  124. e27 = input.bool(title='', defval=true, group='Symbol 27', inline='s27')
  125. s27 = input.symbol('THETAUSDT', title='', group='Symbol 27', inline='s27')
  126.  
  127. e28 = input.bool(title='', defval=true, group='Symbol 28', inline='s28')
  128. s28 = input.symbol('HBARUSDT', title='', group='Symbol 28', inline='s28')
  129.  
  130. e29 = input.bool(title='', defval=true, group='Symbol 29', inline='s29')
  131. s29 = input.symbol('FTMUSDT', title='', group='Symbol 29', inline='s29')
  132.  
  133. e30 = input.bool(title='', defval=true, group='Symbol 30', inline='s30')
  134. s30 = input.symbol('XMRUSDT', title='', group='Symbol 30', inline='s30')
  135.  
  136. e31 = input.bool(title='', defval=true, group='Symbol 31', inline='s31')
  137. s31 = input.symbol('EGLDUSDT', title='', group='Symbol 31', inline='s31')
  138.  
  139. e32 = input.bool(title='', defval=true, group='Symbol 32', inline='s32')
  140. s32 = input.symbol('EOSUSDT', title='', group='Symbol 32', inline='s32')
  141.  
  142. e33 = input.bool(title='', defval=true, group='Symbol 33', inline='s33')
  143. s33 = input.symbol('KLAYUSDT', title='', group='Symbol 33', inline='s33')
  144.  
  145. e34 = input.bool(title='', defval=true, group='Symbol 34', inline='s34')
  146. s34 = input.symbol('AAVEUSDT', title='', group='Symbol 34', inline='s34')
  147.  
  148. e35 = input.bool(title='', defval=true, group='Symbol 35', inline='s35')
  149. s35 = input.symbol('IOTAUSDT', title='', group='Symbol 35', inline='s35')
  150.  
  151. e36 = input.bool(title='', defval=true, group='Symbol 36', inline='s36')
  152. s36 = input.symbol('NEARUSDT', title='', group='Symbol 36', inline='s36')
  153.  
  154. e37 = input.bool(title='', defval=true, group='Symbol 37', inline='s37')
  155. s37 = input.symbol('WAVESUSDT', title='', group='Symbol 37', inline='s37')
  156.  
  157. e38 = input.bool(title='', defval=true, group='Symbol 38', inline='s38')
  158. s38 = input.symbol('GRTUSDT', title='', group='Symbol 38', inline='s38')
  159.  
  160. e39 = input.bool(title='', defval=true, group='Symbol 39', inline='s39')
  161. s39 = input.symbol('NEOUSDT', title='', group='Symbol 39', inline='s39')
  162.  
  163. e40 = input.bool(title='', defval=true, group='Symbol 40', inline='s40')
  164. s40 = input.symbol('KSMUSDT', title='', group='Symbol 40', inline='s40')
  165.  
  166. if e01
  167. [macd01, entrylong01, entryShort01] = screenerFunc(s01, lbR, lbL, rangeUpper, rangeLower)
  168.  
  169. if e02
  170. [macd02, entrylong02, entryShort02] = screenerFunc(s02, lbR, lbL, rangeUpper, rangeLower)
  171.  
  172. if e03
  173. [macd03, entrylong03, entryShort03] = screenerFunc(s03, lbR, lbL, rangeUpper, rangeLower)
  174.  
  175. if e04
  176. [macd04, entrylong04, entryShort04] = screenerFunc(s04, lbR, lbL, rangeUpper, rangeLower)
  177.  
  178. if e05
  179. [macd05, entrylong05, entryShort05] = screenerFunc(s05, lbR, lbL, rangeUpper, rangeLower)
  180.  
  181. if e06
  182. [macd06, entrylong06, entryShort06] = screenerFunc(s06, lbR, lbL, rangeUpper, rangeLower)
  183.  
  184. if e07
  185. [macd07, entrylong07, entryShort07] = screenerFunc(s07, lbR, lbL, rangeUpper, rangeLower)
  186.  
  187. if e08
  188. [macd08, entrylong08, entryShort08] = screenerFunc(s08, lbR, lbL, rangeUpper, rangeLower)
  189.  
  190. if e09
  191. [macd09, entrylong09, entryShort09] = screenerFunc(s09, lbR, lbL, rangeUpper, rangeLower)
  192.  
  193. if e10
  194. [macd10, entrylong10, entryShort10] = screenerFunc(s10, lbR, lbL, rangeUpper, rangeLower)
  195.  
  196. if e11
  197. [macd11, entrylong11, entryShort11] = screenerFunc(s11, lbR, lbL, rangeUpper, rangeLower)
  198.  
  199. if e12
  200. [macd12, entrylong12, entryShort12] = screenerFunc(s12, lbR, lbL, rangeUpper, rangeLower)
  201.  
  202. if e13
  203. [macd13, entrylong13, entryShort13] = screenerFunc(s13, lbR, lbL, rangeUpper, rangeLower)
  204.  
  205. if e14
  206. [macd14, entrylong14, entryShort14] = screenerFunc(s14, lbR, lbL, rangeUpper, rangeLower)
  207.  
  208. if e15
  209. [macd15, entrylong15, entryShort15] = screenerFunc(s15, lbR, lbL, rangeUpper, rangeLower)
  210.  
  211. if e16
  212. [macd16, entrylong16, entryShort16] = screenerFunc(s16, lbR, lbL, rangeUpper, rangeLower)
  213.  
  214. if e17
  215. [macd17, entrylong17, entryShort17] = screenerFunc(s17, lbR, lbL, rangeUpper, rangeLower)
  216.  
  217. if e18
  218. [macd18, entrylong18, entryShort18] = screenerFunc(s18, lbR, lbL, rangeUpper, rangeLower)
  219.  
  220. if e19
  221. [macd19, entrylong19, entryShort19] = screenerFunc(s19, lbR, lbL, rangeUpper, rangeLower)
  222.  
  223. if e20
  224. [macd20, entrylong20, entryShort20] = screenerFunc(s20, lbR, lbL, rangeUpper, rangeLower)
  225.  
  226. if e21
  227. [macd21, entrylong21, entryShort21] = screenerFunc(s21, lbR, lbL, rangeUpper, rangeLower)
  228.  
  229. if e22
  230. [macd22, entrylong22, entryShort22] = screenerFunc(s22, lbR, lbL, rangeUpper, rangeLower)
  231.  
  232. if e23
  233. [macd23, entrylong23, entryShort23] = screenerFunc(s23, lbR, lbL, rangeUpper, rangeLower)
  234.  
  235. if e24
  236. [macd24, entrylong24, entryShort24] = screenerFunc(s24, lbR, lbL, rangeUpper, rangeLower)
  237.  
  238. if e25
  239. [macd25, entrylong25, entryShort25] = screenerFunc(s25, lbR, lbL, rangeUpper, rangeLower)
  240.  
  241. if e26
  242. [macd26, entrylong26, entryShort26] = screenerFunc(s26, lbR, lbL, rangeUpper, rangeLower)
  243.  
  244. if e27
  245. [macd27, entrylong27, entryShort27] = screenerFunc(s27, lbR, lbL, rangeUpper, rangeLower)
  246.  
  247. if e28
  248. [macd28, entrylong28, entryShort28] = screenerFunc(s28, lbR, lbL, rangeUpper, rangeLower)
  249.  
  250. if e29
  251. [macd29, entrylong29, entryShort29] = screenerFunc(s29, lbR, lbL, rangeUpper, rangeLower)
  252.  
  253. if e30
  254. [macd30, entrylong30, entryShort30] = screenerFunc(s30, lbR, lbL, rangeUpper, rangeLower)
  255.  
  256. if e31
  257. [macd31, entrylong31, entryShort31] = screenerFunc(s31, lbR, lbL, rangeUpper, rangeLower)
  258.  
  259. if e32
  260. [macd32, entrylong32, entryShort32] = screenerFunc(s32, lbR, lbL, rangeUpper, rangeLower)
  261.  
  262. if e33
  263. [macd33, entrylong33, entryShort33] = screenerFunc(s33, lbR, lbL, rangeUpper, rangeLower)
  264.  
  265. if e34
  266. [macd34, entrylong34, entryShort34] = screenerFunc(s34, lbR, lbL, rangeUpper, rangeLower)
  267.  
  268. if e35
  269. [macd35, entrylong35, entryShort35] = screenerFunc(s35, lbR, lbL, rangeUpper, rangeLower)
  270.  
  271. if e36
  272. [macd36, entrylong36, entryShort36] = screenerFunc(s36, lbR, lbL, rangeUpper, rangeLower)
  273.  
  274. if e37
  275. [macd37, entrylong37, entryShort37] = screenerFunc(s37, lbR, lbL, rangeUpper, rangeLower)
  276.  
  277. if e38
  278. [macd38, entrylong38, entryShort38] = screenerFunc(s38, lbR, lbL, rangeUpper, rangeLower)
  279.  
  280. if e39
  281. [macd39, entrylong39, entryShort39] = screenerFunc(s39, lbR, lbL, rangeUpper, rangeLower)
  282.  
  283. if e40
  284. [macd40, entrylong40, entryShort40] = screenerFunc(s40, lbR, lbL, rangeUpper, rangeLower)
  285.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement