Apr 30 AlphaTrend (PRO) Manage access Add to favorites Pine Script® // This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © AlphaTrend //@version=6 indicator(title = 'AlphaTrend (PRO)', 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") show_upper = input(true,"Blue",group = g_lowerPane,inline = "fm" ) upper_col = input.color(#5b9cf6,'',group = g_lowerPane,inline = "fm") show_lower = input(true,"Yellow",group = g_lowerPane,inline = "fm" ) lower_col = input.color(color.yellow,'',group = g_lowerPane,inline = "fm") 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 ms_trendlines_g = 'Trendlines' ms_show_trendlines = input(false, '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.rgb(48, 198, 183), 'color', group = ms_trendlines_g) ms_dnCss = input.color(color.red, '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 , "Bot White Dot", "Bot White Dot @ {{ticker}}") alertcondition( isBotYelDot , "Bot Yellow Dot", "Bot Yellow Dot @ {{ticker}}") alertcondition( isBotRedDot , "Bot Red Dot", "Bot 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