// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © QuantAI-Trend //@version=6 indicator(title = 'AlphaTrend PRO v.2', overlay = false,max_labels_count = 500,max_lines_count = 500,max_boxes_count = 500,max_bars_back = 1000) g_switches = "Indicators" ms_activate = input(true,"Activate Dynamic Dots",group = g_switches) ad1_activate = input(true,"Activate Dynamic Reversion Bands",group = g_switches) linreg_activate = input(false,"Activate Channels",group = g_switches) ad3_activate = input(false,"Activate Multi-Timeframe Support/Resistance",group = g_switches) ad4_activate = input(true,"Activate OverBought/OverSold Banners",group = g_switches) ad6_activate = input(true,"Activate Areas of Interest",group = g_switches) g_lowerPane = "Lower Plots" ad1_plot_stoch = false//input(true,"Plot BCB Stoch",group = g_lowerPane,inline = "bcb") and ms_activate // ad5_plot_rsiBaseBanker = input(true,"Plot Flow Meter",group = g_lowerPane,inline = "fm") ad5_plot_bf = input(true,"Plot Banker Flow",group = g_lowerPane,inline = "fm1") // show_upper = input(true,"Blue",group = g_lowerPane,inline = "fm" ) upper_col = input.color(#5b9cf6,'',group = g_lowerPane,inline = "fm1") ad5_plot_if = input(false,"Plot Institutional Flow",group = g_lowerPane,inline = "fm2") // show_lower = input(true,"Yellow",group = g_lowerPane,inline = "fm" ) lower_col = input.color(color.yellow,'',group = g_lowerPane,inline = "fm2") //////////////////////////////// MP ad6_plot_stoch_bg = input(true,"Plot Momentum Pulse",group = g_lowerPane,inline = "fm3") // show_lower = input(true,"Yellow",group = g_lowerPane,inline = "fm" ) ad6_stoch_bullc = input.color(color.new(color.green,60),'',group = g_lowerPane,inline = "fm3") ad6_stoch_bearc = input.color(color.new(color.red,70),'',group = g_lowerPane,inline = "fm3") ad6_plot_stoch_sig = input(true,"Crosses",group = g_lowerPane,inline = "fm3") //////////////////////////// ADX ad7_plot_sr = input(true,"Plot S/R Factor",group = g_lowerPane) ////////////////// adx_g = "S/R Settings" adx_len = 14//input(14,"S/R Length",group = adx_g) adx_th1 = 11.7//input(11.7,"S/R Upper TH",group = adx_g,inline = "th1") adx_th2 = 7.5//input(7.5,"Lower TH",group = adx_g,inline = "th1") adx_plot_dm = input(true,"Plot S/R Bearish",group = adx_g,inline = "dm") and ad7_plot_sr adx_dm_bullc = input.color(color.new(color.gray,0),'',group = adx_g,inline = "dm") adx_dm_bearc = input.color(color.new(color.yellow,0),'',group = adx_g,inline = "dm") const string adx_dm_size = size.small adx_plot_dp = input(true,"Plot S/R Bullish",group = adx_g,inline = "dp") and ad7_plot_sr adx_dp_bullc = input.color(color.new(color.gray,0),'',group = adx_g,inline = "dp") adx_dp_bearc = input.color(color.new(color.yellow,0),'',group = adx_g,inline = "dp") const string adx_dp_size = size.small TrueRange = math.max(math.max(high - low, math.abs(high - nz(close[1]))), math.abs(low - nz(close[1]))) DirectionalMovementPlus = high - nz(high[1]) > nz(low[1]) - low ? math.max(high - nz(high[1]), 0) : 0 DirectionalMovementMinus = nz(low[1]) - low > high - nz(high[1]) ? math.max(nz(low[1]) - low, 0) : 0 SmoothedTrueRange = 0.0 SmoothedTrueRange := nz(SmoothedTrueRange[1]) - nz(SmoothedTrueRange[1]) / adx_len + TrueRange SmoothedDirectionalMovementPlus = 0.0 SmoothedDirectionalMovementPlus := nz(SmoothedDirectionalMovementPlus[1]) - nz(SmoothedDirectionalMovementPlus[1]) / adx_len + DirectionalMovementPlus SmoothedDirectionalMovementMinus = 0.0 SmoothedDirectionalMovementMinus := nz(SmoothedDirectionalMovementMinus[1]) - nz(SmoothedDirectionalMovementMinus[1]) / adx_len + DirectionalMovementMinus adx_DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100 adx_DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100 adx_DX = math.abs(adx_DIPlus - adx_DIMinus) / (adx_DIPlus + adx_DIMinus) * 100 ADX = ta.sma(adx_DX, adx_len) dMinusCol = adx_DIMinus < adx_th1 and adx_DIMinus > adx_th2? adx_dm_bullc : adx_DIMinus < adx_th1 and adx_DIMinus < adx_th2? adx_dm_bearc : na plotchar(adx_plot_dm? 25 : na, title="S/R Bearish Factor Line", char="●",location = location.absolute,color=dMinusCol,size=adx_dm_size,editable = false) dPlusCol = adx_DIPlus < adx_th1 and adx_DIPlus > adx_th2? adx_dp_bullc : adx_DIPlus < adx_th1 and adx_DIPlus < adx_th2? adx_dp_bearc : na plotchar(adx_plot_dp? -5 : na, title="D/R Bullish Factor Line", char="●",location = location.absolute,color=dPlusCol,size=adx_dp_size,editable = false) sr_bull_norm_alert = ta.crossunder(adx_DIPlus,adx_th1) sr_bull_extreme_alert = ta.crossunder(adx_DIPlus,adx_th2) sr_bear_norm_alert = ta.crossunder(adx_DIMinus,adx_th1) sr_bear_extreme_alert = ta.crossunder(adx_DIMinus,adx_th2) alertcondition( sr_bull_norm_alert , "S/R Factor Bullish Normal", "S/R Factor Bullish Normal @ {{ticker}}") alertcondition( sr_bull_extreme_alert , "S/R Factor Bullish Extreme", "S/R Factor Bullish Extreme @ {{ticker}}") alertcondition( sr_bear_norm_alert , "S/R Factor Bearish Normal", "S/R Factor Bearish Normal @ {{ticker}}") alertcondition( sr_bear_extreme_alert , "S/R Factor Bearish Extreme", "S/R Factor Bearish Extreme @ {{ticker}}") ///////////////////////// ms_q = 10 ms_r = 3 ms_s = 3 ms_nsig = 3 ms_matype = 'ema' // possible: ema, sma, wma, trima, hma, dema, tema, zlema ms_overbought = 75 ms_oversold = -75 ms_plot_circles = true trima(ms_src, ms_length) => ta.sma(ta.sma(ms_src, ms_length), ms_length) hma(ms_src, ms_length) => ta.wma(2 * ta.wma(ms_src, ms_length / 2) - ta.wma(ms_src, ms_length), math.round(math.sqrt(ms_length))) dema(ms_src, ms_length) => 2 * ta.ema(ms_src, ms_length) - ta.ema(ta.ema(ms_src, ms_length), ms_length) tema(ms_src, ms_length) => 3 * ta.ema(ms_src, ms_length) - 3 * ta.ema(ta.ema(ms_src, ms_length), ms_length) + ta.ema(ta.ema(ta.ema(ms_src, ms_length), ms_length), ms_length) zlema(ms_src, ms_length) => ta.ema(ms_src, ms_length) + ta.ema(ms_src, ms_length) - ta.ema(ta.ema(ms_src, ms_length), ms_length) ms_smi = 100 * ta.ema(ta.ema(close - 0.5 * (ta.highest(ms_q) + ta.lowest(ms_q)), ms_r), ms_s) / (0.5 * ta.ema(ta.ema(ta.highest(ms_q) - ta.lowest(ms_q), ms_r), ms_s)) ema_1 = ta.ema(ms_smi, ms_nsig) sma_1 = ta.sma(ms_smi, ms_nsig) wma_1 = ta.wma(ms_smi, ms_nsig) trima__1 = trima(ms_smi, ms_nsig) hma__1 = hma(ms_smi, ms_nsig) dema__1 = dema(ms_smi, ms_nsig) tema__1 = tema(ms_smi, ms_nsig) zlema__1 = zlema(ms_smi, ms_nsig) ema_2 = ta.ema(ms_smi, ms_nsig) ms_sig = ms_matype == 'ema' ? ema_1 : ms_matype == 'sma' ? sma_1 : ms_matype == 'wma' ? wma_1 : ms_matype == 'trima' ? trima__1 : ms_matype == 'hma' ? hma__1 : ms_matype == 'dema' ? dema__1 : ms_matype == 'tema' ? tema__1 : ms_matype == 'zlema' ? zlema__1 : ema_2 // Mom pulse // Cross conditions var mpTrend = 0 co = ta.crossover(ms_smi, ms_sig) cu = ta.crossunder(ms_smi, ms_sig) if co mpTrend := 1 if cu mpTrend := -1 col = mpTrend == 1 ? ad6_stoch_bullc : mpTrend == -1 ? ad6_stoch_bearc : na bgcolor(ad6_plot_stoch_bg and ad6_plot_stoch_sig? col : na,title = "Momentum Pulse Background") //////////// ms_trendlines_g = 'Trendlines' ms_show_trendlines = input(true, 'Show Trendlines', group = ms_trendlines_g) and ms_activate dot_size = str.lower(input.string("Auto","Dot Size",options=["Auto","Tiny","Small","Normal","Large","Huge"],group=ms_trendlines_g)) la_sz = input.string('normal', 'label Size', ['tiny', 'small', 'normal', 'large', 'huge'], group = ms_trendlines_g) ms_length = 14 ms_mult = 1 ms_calcMethod = 'Atr' ms_backpaint = input(true,"Backpaint", group = ms_trendlines_g) //Style ms_upCss = input.color(color.new(color.green,30), 'color', group = ms_trendlines_g) ms_dnCss = input.color(color.new(color.red,30), 'color', group = ms_trendlines_g) ms_showExt = input(true, 'Show Extended ms_lines', group = ms_trendlines_g) ms_lin_w = input.int(2, 'Trendline width', group = ms_trendlines_g) ms_fomo_white = input.color(color.white,'FOMO CANDLES',inline='col',group = ms_trendlines_g) ms_fomo_yel = input.color(color.yellow,'',inline='col',group = ms_trendlines_g) // Dots cSize = size.auto dotLvl3 = 89 dotLvl2 = 82 dotLvl1 = 74 isTopRedDot = false isTopYelDot = false isTopWhiteDot = false isBotRedDot = false isBotYelDot = false isBotWhiteDot = false if ms_activate and ms_plot_circles if ms_smi > dotLvl3 label.new(bar_index,high,"",yloc = yloc.abovebar,style = label.style_circle,color=color.red,force_overlay = true,size=dot_size) isTopRedDot := true if ms_smi > dotLvl2 and ms_smi < dotLvl3 label.new(bar_index,high,"",yloc = yloc.abovebar,style = label.style_circle,color=color.yellow,force_overlay = true,size=dot_size) isTopYelDot := true if ms_smi > dotLvl1 and ms_smi < dotLvl2 label.new(bar_index,high,"",yloc = yloc.abovebar,style = label.style_circle,color=color.white,force_overlay = true,size=dot_size) isTopWhiteDot := true if ms_smi < -dotLvl3 label.new(bar_index,low,"",yloc = yloc.belowbar,style = label.style_circle,color=color.red,force_overlay = true,size=dot_size) isBotRedDot := true if ms_smi < -dotLvl2 and ms_smi > -dotLvl3 label.new(bar_index,low,"",yloc = yloc.belowbar,style = label.style_circle,color=color.yellow,force_overlay = true,size=dot_size) isBotYelDot := true if ms_smi < -dotLvl1 and ms_smi > -dotLvl2 label.new(bar_index,low,"",yloc = yloc.belowbar,style = label.style_circle,color=color.white,force_overlay = true,size=dot_size) isBotWhiteDot := true alertcondition( isTopWhiteDot , "Top White Dot", "Top White Dot @ {{ticker}}") alertcondition( isTopYelDot , "Top Yellow Dot", "Top Yellow Dot @ {{ticker}}") alertcondition( isTopRedDot , "Top Red Dot", "Top Red Dot @ {{ticker}}") alertcondition( isBotWhiteDot , "Bottom White Dot", "Bottom White Dot @ {{ticker}}") alertcondition( isBotYelDot , "Bottom Yellow Dot", "Bottom Yellow Dot @ {{ticker}}") alertcondition( isBotRedDot , "Bottom Red Dot", "Bottom Red Dot @ {{ticker}}") var ms_upper = 0. var ms_lower = 0. var ms_slope_ph = 0. var ms_slope_pl = 0. var ms_offset = ms_backpaint ? ms_length : 0 n = bar_index ms_src = close ms_ph = ta.pivothigh(ms_length, ms_length) ms_pl = ta.pivotlow(ms_length, ms_length) ms_slope = switch ms_calcMethod 'Atr' => ta.atr(ms_length) / ms_length * ms_mult 'Stdev' => ta.stdev(ms_src, ms_length) / ms_length * ms_mult 'Linreg' => math.abs(ta.sma(ms_src * n, ms_length) - ta.sma(ms_src, ms_length) * ta.sma(n, ms_length)) / ta.variance(n, ms_length) / 2 * ms_mult ms_slope_ph := bool(ms_ph) ? ms_slope : ms_slope_ph ms_slope_pl := bool(ms_pl) ? ms_slope : ms_slope_pl ms_upper := bool(ms_ph) ? ms_ph : ms_upper - ms_slope_ph ms_lower := bool(ms_pl) ? ms_pl : ms_lower + ms_slope_pl var upos = 0 var dnos = 0 upos := bool(ms_ph) ? 0 : close > ms_upper - ms_slope_ph * ms_length ? 1 : upos dnos := bool(ms_pl) ? 0 : close < ms_lower + ms_slope_pl * ms_length ? 1 : dnos var uptl = line.new(na, na, na, na, color = ms_upCss, style = line.style_solid, extend = extend.right, width = ms_lin_w, force_overlay = true) var dntl = line.new(na, na, na, na, color = ms_dnCss, style = line.style_solid, extend = extend.right, width = ms_lin_w, force_overlay = true) if ms_show_trendlines if bool(ms_ph) and ms_showExt uptl.set_xy1(n - ms_offset, ms_backpaint ? ms_ph : ms_upper - ms_slope_ph * ms_length) uptl.set_xy2(n - ms_offset + 1, ms_backpaint ? ms_ph - ms_slope : ms_upper - ms_slope_ph * (ms_length + 1)) if bool(ms_pl) and ms_showExt dntl.set_xy1(n - ms_offset, ms_backpaint ? ms_pl : ms_lower + ms_slope_pl * ms_length) dntl.set_xy2(n - ms_offset + 1, ms_backpaint ? ms_pl + ms_slope : ms_lower + ms_slope_pl * (ms_length + 1)) plot(ms_show_trendlines ? ms_backpaint ? ms_upper : ms_upper - ms_slope_ph * ms_length : na, 'Upper', color = bool(ms_ph) ? na : ms_upCss, offset = -ms_offset, force_overlay = true,linewidth = 2,editable = false,display = display.pane) plot(ms_show_trendlines ? ms_backpaint ? ms_lower : ms_lower + ms_slope_pl * ms_length : na, 'Lower', color = bool(ms_pl) ? na : ms_dnCss, offset = -ms_offset, force_overlay = true,linewidth = 2,editable = false,display = display.pane) B_l = ta.atr(14) S_l = ta.atr(14) if ms_show_trendlines if upos > upos[1] label.new(bar_index, low - ( B_l * 4 ), text = 'B', style = label.style_label_up, textcolor = color.white, color = ms_upCss, size = la_sz, force_overlay = true) if dnos > dnos[1] label.new(bar_index, high + ( S_l * 4 ), text = 'B', style = label.style_label_down, textcolor = color.white, color = ms_dnCss, size = la_sz, force_overlay = true) alertcondition(upos > upos[1], 'Trendline Upward Breakout', 'Price broke the down trendline upward') alertcondition(dnos > dnos[1], 'Trendline Downward Breakout', 'Price broke the up trendline downward') timeframe_option = 'D' ms_line_color = input.color(#ba68c8, 'Line color', group = 'OPENING PRICE LINE') ms_line_thickness = 2 ms_line_style = input.string('Solid', 'Line Style', options = ['Solid', 'Dotted', 'Dashed'], group = 'OPENING PRICE LINE') ms_line_style_enum = ms_line_style == 'Solid' ? line.style_solid : ms_line_style == 'Dotted' ? line.style_dotted : line.style_dashed ms_show_labels = true ms_label_color = color.black ms_open1 = request.security(syminfo.tickerid, timeframe_option, open[2], lookahead = barmerge.lookahead_on) ms_open2 = request.security(syminfo.tickerid, timeframe_option, open[1], lookahead = barmerge.lookahead_on) ms_open3 = request.security(syminfo.tickerid, timeframe_option, open, lookahead = barmerge.lookahead_on) ms_open1_time = request.security(syminfo.tickerid, timeframe_option, time[2], lookahead = barmerge.lookahead_on) ms_open2_time = request.security(syminfo.tickerid, timeframe_option, time[1], lookahead = barmerge.lookahead_on) ms_open3_time = request.security(syminfo.tickerid, timeframe_option, time, lookahead = barmerge.lookahead_on) var array ms_lines = array.new_line(0) var array