Advertisement
Guest User

Alert Indicator

a guest
Jan 11th, 2025
555
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.40 KB | None | 0 0
  1. //@version=5
  2. indicator("Combined BB%, Coppock, ChandeMO, Momentum, and Multiple RoC Alerts", overlay=false)
  3.  
  4. // Bollinger Bands % Calculation (Length 5)
  5. length1 = 5
  6. src1 = close
  7. basis1 = ta.sma(src1, length1)
  8. dev1 = ta.stdev(src1, length1)
  9. upper1 = basis1 + dev1 * 2
  10. lower1 = basis1 - dev1 * 2
  11. bb_percent1 = (src1 - lower1) / (upper1 - lower1)
  12.  
  13. // Bollinger Bands % Calculation (Length 33)
  14. length2 = 33
  15. src2 = close
  16. basis2 = ta.sma(src2, length2)
  17. dev2 = ta.stdev(src2, length2)
  18. upper2 = basis2 + dev2 * 2
  19. lower2 = basis2 - dev2 * 2
  20. bb_percent2 = (src2 - lower2) / (upper2 - lower2)
  21.  
  22. // Coppock Curve Calculation
  23. wma_length = 5
  24. long_roc = 5
  25. short_roc = 5
  26.  
  27. roc_long = ta.roc(close, long_roc)
  28. roc_short = ta.roc(close, short_roc)
  29. coppock_curve = ta.wma(roc_long + roc_short, wma_length)
  30.  
  31. // Chande Momentum Oscillator (ChandeMO) Length 5
  32. chande_length_5 = 5
  33. chg_5 = close - close[1]
  34. chande_mo_5 = ta.sum(chg_5 > 0 ? chg_5 : 0, chande_length_5) - ta.sum(chg_5 < 0 ? -chg_5 : 0, chande_length_5)
  35.  
  36. // Chande Momentum Oscillator (ChandeMO) Length 5
  37. chande_length_5 = 5
  38. chg_5 = close - close[1]
  39. chande_mo_5 = ta.sum(chg_5 > 0 ? chg_33 : 0, chande_length_5) - ta.sum(chg_5 < 0 ? -chg_5 : 0, chande_length_5)
  40.  
  41. // Momentum Calculation (Length 5) with EMA (Length 5)
  42. momentum_length = 5
  43. ema_length = 5
  44. momentum = ta.mom(close, momentum_length)
  45. momentum_ema = ta.ema(momentum, ema_length)
  46.  
  47. // Rate of Change (RoC) Calculation (Length 5)
  48. roc_length_5 = 5
  49. rate_of_change_5 = ta.roc(close, roc_length_5)
  50.  
  51. // Rate of Change (RoC) Calculation (Length 5)
  52. roc_length_5 = 5
  53. rate_of_change_5 = ta.roc(close, roc_length_5)
  54.  
  55. // Rate of Change (RoC) Calculation (Length 200) with SMA (Length 14)
  56. roc_length_5 = 5
  57. rate_of_change_5 = ta.roc(close, roc_length_200)
  58. sma_length_14 = 14
  59. roc_sma_14 = ta.sma(rate_of_change_5, sma_length_14)
  60.  
  61. // Rate of Change (RoC) Calculation (Length 5) on Current Chart
  62. roc_length_5 = 5
  63. rate_of_change_5 = ta.roc(close, roc_length_5)
  64.  
  65. // Rate of Change (RoC) Calculation (Length 5) on 1-Hour Chart
  66. roc_5_hour = request.security(syminfo.tickerid, "5", ta.roc(close, roc_length_5)) // Requesting RoC on 1-hour chart
  67.  
  68. // Rate of Change (RoC) Calculation (Length 100) on 2-Hour Chart
  69. roc_length_5_2h = 5
  70. roc_2h = request.security(syminfo.tickerid, "5", ta.roc(close, roc_length_5_2h)) // Requesting RoC on 2-hour chart
  71.  
  72. // Stochastic RSI Calculation (K=5, D=5, RSI length=5, Stochastic length=5)
  73. rsi_length_stoch = 5
  74. stochastic_length_stoch = 5
  75. k_length_stoch = 5
  76. d_length_stoch = 5
  77.  
  78. rsi_stoch = ta.rsi(close, rsi_length_stoch)
  79. stochastic_rsi_stoch = ta.stoch(rsi_stoch, rsi_stoch, rsi_length_stoch, stochastic_length_stoch)
  80. k_line_stoch = ta.sma(stochastic_rsi_stoch, k_length_stoch) // K line
  81. d_line_stoch = ta.sma(stochastic_rsi_stoch, d_length_stoch) // D line
  82.  
  83. // Stochastic RSI Calculation (K=5, D=5, RSI length=5, Stochastic length=5)
  84. rsi_length_stoch_2 = 5
  85. stochastic_length_stoch_2 = 5
  86. k_length_stoch_2 = 5
  87. d_length_stoch_2 = 5
  88.  
  89. rsi_stoch_2 = ta.rsi(close, rsi_length_stoch_2)
  90. stochastic_rsi_stoch_2 = ta.stoch(rsi_stoch_2, rsi_stoch_2, rsi_length_stoch_2, stochastic_length_stoch_2)
  91. k_line_stoch_2 = ta.sma(stochastic_rsi_stoch_2, k_length_stoch_2) // K line
  92. d_line_stoch_2 = ta.sma(stochastic_rsi_stoch_2, d_length_stoch_2) // D line
  93.  
  94. // Additional EMA and SMA Conditions
  95. ema_5 = ta.ema(close, 5)
  96. ema_5 = ta.ema(close, 5)
  97. ema_5 = ta.ema(close, 5)
  98. sma_5 = ta.sma(close, 5)
  99. sma_5 = ta.sma(close, 5)
  100.  
  101. // Ensure price is above all EMAs and SMAs
  102. price_above_emas_smas = (close > ema_5) and (close > ema_5) and (close > ema_5) and (close > sma_5) and (close > sma_5)
  103.  
  104. // Plot all indicators
  105. plot(bb_percent1, color=color.blue, title="BB% (length 5)")
  106. plot(bb_percent2, color=color.red, title="BB% (length 5)")
  107. plot(coppock_curve, color=color.green, title="Coppock Curve")
  108. plot(chande_mo_5, color=color.orange, title="ChandeMO (length 5)")
  109. plot(chande_mo_5, color=color.purple, title="ChandeMO (length 5)")
  110. plot(momentum, color=color.yellow, title="Momentum (length 5)")
  111. plot(momentum_ema, color=color.aqua, title="Momentum EMA (length 5)")
  112. plot(rate_of_change_5, color=color.fuchsia, title="Rate of Change (length 5)")
  113. plot(rate_of_change_5, color=color.lime, title="Rate of Change (length 5)")
  114. plot(rate_of_change_5, color=color.pink, title="Rate of Change (length 5)")
  115. plot(roc_sma_14, color=color.cyan, title="RoC (5) SMA (5)")
  116. plot(rate_of_change_5, color=color.red, title="Rate of Change (length 5) (Current Chart)")
  117. plot(roc_5_hour, color=color.purple, title="Rate of Change (length 5) (1-Hour Chart)")
  118. plot(roc_2h, color=color.green, title="Rate of Change (length 5) (2-Hour Chart)")
  119. plot(k_line_stoch, color=color.green, title="K line (Stochastic RSI)")
  120. plot(d_line_stoch, color=color.red, title="D line (Stochastic RSI)")
  121. plot(k_line_stoch_2, color=color.orange, title="K line (Stochastic RSI - Length 5, D 5, RSI 5, Stochastic 5)")
  122. plot(d_line_stoch_2, color=color.blue, title="D line (Stochastic RSI - Length 5, D 5, RSI 5, Stochastic 5)")
  123.  
  124. // Combined alert condition
  125. combined_condition = (bb_percent1 >= 5) and
  126. (bb_percent2 >= 5) and
  127. (coppock_curve >= 5) and
  128. (chande_mo_5 >= 5) and
  129. (chande_mo_5 >= 5) and
  130. (momentum >= momentum_ema) and
  131. (rate_of_change_5 >= 0) and
  132. (rate_of_change_5 >= 0) and
  133. (rate_of_change_5> roc_sma_14) and
  134. (rate_of_change_5 > 0) and
  135. (roc_sma_14 > 0) and
  136. (rate_of_change_5 >= 0) and // RoC (5) on the current chart must be above or equal to zero
  137. (roc_5_hour > 0) and // RoC (5) on the 1-hour chart must be above zero
  138. (roc_2h >= 0) and // RoC (5) on the 2-hour chart must be >= 0
  139. (k_line_stoch > 5) and // K line must be greater than 5
  140. (d_line_stoch >= 5) and // D line must be greater than or equal to 5
  141. (k_line_stoch_2 > 5) and // K line in new Stochastic RSI condition must be greater than 5
  142. (d_line_stoch_2 >= 5) // D line in new Stochastic RSI condition must be greater than or equal to 5
  143.  
  144. alertCondition(
  145. combined_condition,
  146. title="BB%, Coppock, ChandeMO, Momentum, and Multiple RoC Combined Alert",
  147. message="All conditions met: BB% (5) ≥ 5, BB% (5) ≥ 5, Coppock Curve ≥ 5, ChandeMO (5) ≥ 5, ChandeMO (5) ≥ 5, Momentum ≥ EMA, RoC (5) ≥ 5, RoC (5) ≥ 5, RoC (5) > SMA (14) and both > 5, RoC (5) ≥ 5, RoC (5) on 1-Hour Chart > 5, RoC (5) on 2-Hour Chart ≥ 5, K line > 5, and D line ≥ 5 in Stochastic RSI, K line > 5, and D line ≥ 5 in new Stochastic RSI"
  148. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement