Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- indicator("Combined BB%, Coppock, ChandeMO, Momentum, and Multiple RoC Alerts", overlay=false)
- // Bollinger Bands % Calculation (Length 5)
- length1 = 5
- src1 = close
- basis1 = ta.sma(src1, length1)
- dev1 = ta.stdev(src1, length1)
- upper1 = basis1 + dev1 * 2
- lower1 = basis1 - dev1 * 2
- bb_percent1 = (src1 - lower1) / (upper1 - lower1)
- // Bollinger Bands % Calculation (Length 33)
- length2 = 33
- src2 = close
- basis2 = ta.sma(src2, length2)
- dev2 = ta.stdev(src2, length2)
- upper2 = basis2 + dev2 * 2
- lower2 = basis2 - dev2 * 2
- bb_percent2 = (src2 - lower2) / (upper2 - lower2)
- // Coppock Curve Calculation
- wma_length = 5
- long_roc = 5
- short_roc = 5
- roc_long = ta.roc(close, long_roc)
- roc_short = ta.roc(close, short_roc)
- coppock_curve = ta.wma(roc_long + roc_short, wma_length)
- // Chande Momentum Oscillator (ChandeMO) Length 5
- chande_length_5 = 5
- chg_5 = close - close[1]
- 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)
- // Chande Momentum Oscillator (ChandeMO) Length 5
- chande_length_5 = 5
- chg_5 = close - close[1]
- 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)
- // Momentum Calculation (Length 5) with EMA (Length 5)
- momentum_length = 5
- ema_length = 5
- momentum = ta.mom(close, momentum_length)
- momentum_ema = ta.ema(momentum, ema_length)
- // Rate of Change (RoC) Calculation (Length 5)
- roc_length_5 = 5
- rate_of_change_5 = ta.roc(close, roc_length_5)
- // Rate of Change (RoC) Calculation (Length 5)
- roc_length_5 = 5
- rate_of_change_5 = ta.roc(close, roc_length_5)
- // Rate of Change (RoC) Calculation (Length 200) with SMA (Length 14)
- roc_length_5 = 5
- rate_of_change_5 = ta.roc(close, roc_length_200)
- sma_length_14 = 14
- roc_sma_14 = ta.sma(rate_of_change_5, sma_length_14)
- // Rate of Change (RoC) Calculation (Length 5) on Current Chart
- roc_length_5 = 5
- rate_of_change_5 = ta.roc(close, roc_length_5)
- // Rate of Change (RoC) Calculation (Length 5) on 1-Hour Chart
- roc_5_hour = request.security(syminfo.tickerid, "5", ta.roc(close, roc_length_5)) // Requesting RoC on 1-hour chart
- // Rate of Change (RoC) Calculation (Length 100) on 2-Hour Chart
- roc_length_5_2h = 5
- roc_2h = request.security(syminfo.tickerid, "5", ta.roc(close, roc_length_5_2h)) // Requesting RoC on 2-hour chart
- // Stochastic RSI Calculation (K=5, D=5, RSI length=5, Stochastic length=5)
- rsi_length_stoch = 5
- stochastic_length_stoch = 5
- k_length_stoch = 5
- d_length_stoch = 5
- rsi_stoch = ta.rsi(close, rsi_length_stoch)
- stochastic_rsi_stoch = ta.stoch(rsi_stoch, rsi_stoch, rsi_length_stoch, stochastic_length_stoch)
- k_line_stoch = ta.sma(stochastic_rsi_stoch, k_length_stoch) // K line
- d_line_stoch = ta.sma(stochastic_rsi_stoch, d_length_stoch) // D line
- // Stochastic RSI Calculation (K=5, D=5, RSI length=5, Stochastic length=5)
- rsi_length_stoch_2 = 5
- stochastic_length_stoch_2 = 5
- k_length_stoch_2 = 5
- d_length_stoch_2 = 5
- rsi_stoch_2 = ta.rsi(close, rsi_length_stoch_2)
- stochastic_rsi_stoch_2 = ta.stoch(rsi_stoch_2, rsi_stoch_2, rsi_length_stoch_2, stochastic_length_stoch_2)
- k_line_stoch_2 = ta.sma(stochastic_rsi_stoch_2, k_length_stoch_2) // K line
- d_line_stoch_2 = ta.sma(stochastic_rsi_stoch_2, d_length_stoch_2) // D line
- // Additional EMA and SMA Conditions
- ema_5 = ta.ema(close, 5)
- ema_5 = ta.ema(close, 5)
- ema_5 = ta.ema(close, 5)
- sma_5 = ta.sma(close, 5)
- sma_5 = ta.sma(close, 5)
- // Ensure price is above all EMAs and SMAs
- price_above_emas_smas = (close > ema_5) and (close > ema_5) and (close > ema_5) and (close > sma_5) and (close > sma_5)
- // Plot all indicators
- plot(bb_percent1, color=color.blue, title="BB% (length 5)")
- plot(bb_percent2, color=color.red, title="BB% (length 5)")
- plot(coppock_curve, color=color.green, title="Coppock Curve")
- plot(chande_mo_5, color=color.orange, title="ChandeMO (length 5)")
- plot(chande_mo_5, color=color.purple, title="ChandeMO (length 5)")
- plot(momentum, color=color.yellow, title="Momentum (length 5)")
- plot(momentum_ema, color=color.aqua, title="Momentum EMA (length 5)")
- plot(rate_of_change_5, color=color.fuchsia, title="Rate of Change (length 5)")
- plot(rate_of_change_5, color=color.lime, title="Rate of Change (length 5)")
- plot(rate_of_change_5, color=color.pink, title="Rate of Change (length 5)")
- plot(roc_sma_14, color=color.cyan, title="RoC (5) SMA (5)")
- plot(rate_of_change_5, color=color.red, title="Rate of Change (length 5) (Current Chart)")
- plot(roc_5_hour, color=color.purple, title="Rate of Change (length 5) (1-Hour Chart)")
- plot(roc_2h, color=color.green, title="Rate of Change (length 5) (2-Hour Chart)")
- plot(k_line_stoch, color=color.green, title="K line (Stochastic RSI)")
- plot(d_line_stoch, color=color.red, title="D line (Stochastic RSI)")
- plot(k_line_stoch_2, color=color.orange, title="K line (Stochastic RSI - Length 5, D 5, RSI 5, Stochastic 5)")
- plot(d_line_stoch_2, color=color.blue, title="D line (Stochastic RSI - Length 5, D 5, RSI 5, Stochastic 5)")
- // Combined alert condition
- combined_condition = (bb_percent1 >= 5) and
- (bb_percent2 >= 5) and
- (coppock_curve >= 5) and
- (chande_mo_5 >= 5) and
- (chande_mo_5 >= 5) and
- (momentum >= momentum_ema) and
- (rate_of_change_5 >= 0) and
- (rate_of_change_5 >= 0) and
- (rate_of_change_5> roc_sma_14) and
- (rate_of_change_5 > 0) and
- (roc_sma_14 > 0) and
- (rate_of_change_5 >= 0) and // RoC (5) on the current chart must be above or equal to zero
- (roc_5_hour > 0) and // RoC (5) on the 1-hour chart must be above zero
- (roc_2h >= 0) and // RoC (5) on the 2-hour chart must be >= 0
- (k_line_stoch > 5) and // K line must be greater than 5
- (d_line_stoch >= 5) and // D line must be greater than or equal to 5
- (k_line_stoch_2 > 5) and // K line in new Stochastic RSI condition must be greater than 5
- (d_line_stoch_2 >= 5) // D line in new Stochastic RSI condition must be greater than or equal to 5
- alertCondition(
- combined_condition,
- title="BB%, Coppock, ChandeMO, Momentum, and Multiple RoC Combined Alert",
- 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"
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement