══════════════════════════════════════════════════ // FLIP LABELS // Shows direction, quality grade, and price. // ═══════════════════════════════════════════════════════════════ if i_labels and flip_up label.new(bar_index, st, text = "LONG [" + quality_grade + "]\n" + str.tostring(close, format.mintick), yloc = yloc.belowbar, style = label.style_label_up,color = color.new(i_bull, 8), textcolor = color.white, size = size.small) if i_labels and flip_down label.new(bar_index, st, text = "SHORT [" + quality_grade + "]\n" + str.tostring(close, format.mintick), yloc = yloc.abovebar,style = label.style_label_down, color = color.new(i_bear, 8), textcolor = color.white,size = size.small) // ═══════════════════════════════════════════════════════════════ // DASHBOARD // ═══════════════════════════════════════════════════════════════ if i_table and barstate.islast pos = i_pos == "Top Right" ? position.top_right : i_pos == "Top Left" ? position.top_left : i_pos == "Bottom Right" ? position.bottom_right : position.bottom_left int filled = int(math.round(s * 10)) string sbar = "" for i = 0 to 9 sbar += i < filled ? "█" : "░" dist = math.abs(close - st) / close * 100 er_label = er_smooth > 0.65 ? "TRENDING" : er_smooth > 0.40 ? "MIXED" : "CHOPPY" er_color = er_smooth > 0.65 ? tc : er_smooth > 0.40 ? color.orange : color.gray vol_label = vol_ratio > 1.20 ? "ELEVATED" : vol_ratio < 0.80 ? "COMPRESSED" : "NORMAL" vol_color = vol_ratio > 1.20 ? color.orange : vol_ratio < 0.80 ? color.aqua : color.silver q_color = not has_flipped ? color.gray : flip_quality >= 70 ? tc : flip_quality >= 50 ? color.orange : color.gray q_text = has_flipped ? str.tostring(flip_quality) + " / 100 [" + flip_grade + "]" : "no flip yet" t = table.new(pos, 2, 11,bgcolor = color.new(#080808, 5),border_color = color.new(tc, 52), border_width = 1,frame_color = color.new(tc, 22),frame_width = 2) table.cell(t, 0, 0, "SUPERTREND", text_color=color.white, text_size=size.small, bgcolor=color.new(tc, 42), text_halign=text.align_center) table.cell(t, 1, 0, "F:" + str.tostring(adaptive_factor, "#.##") + " C:" + str.tostring(adaptive_confirm),text_color=color.silver, text_size=size.small,bgcolor=color.new(tc, 42), text_halign=text.align_center) table.cell(t, 0, 1, "Direction", text_color=color.gray, text_size=size.small) table.cell(t, 1, 1, locked_bull ? "LONG" : "SHORT",text_color=tc, text_size=size.small, text_halign=text.align_center, bgcolor=color.new(tc, 85)) table.cell(t, 0, 2, "Age", text_color=color.gray, text_size=size.small) table.cell(t, 1, 2, str.tostring(age) + " bars",text_color=color.silver, text_size=size.small, text_halign=text.align_center) table.cell(t, 0, 3, "Conviction", text_color=color.gray, text_size=size.small) table.cell(t, 1, 3, sbar + " " + str.tostring(math.round(s * 100)) + "%", text_color=s > 0.5 ? tc : color.gray,text_size=size.tiny, text_halign=text.align_center) table.cell(t, 0, 4, "Efficiency", text_color=color.gray, text_size=size.small) table.cell(t, 1, 4, er_label + " " + str.tostring(er_smooth, "#.##"),text_color=er_color, text_size=size.small, text_halign=text.align_center) table.cell(t, 0, 5, "Vol Regime", text_color=color.gray, text_size=size.small) table.cell(t, 1, 5, vol_label + " " + str.tostring(vol_ratio, "#.##"),text_color=vol_color, text_size=size.small, text_halign=text.align_center) table.cell(t, 0, 6, "Adapt Factor",text_color=color.gray, text_size=size.small) table.cell(t, 1, 6, str.tostring(adaptive_factor, "#.##") + " (base " + str.tostring(i_factor, "#.#") + ")",text_color=color.silver, text_size=size.small, text_halign=text.align_center) table.cell(t, 0, 7, "Last Flip", text_color=color.gray, text_size=size.small) table.cell(t, 1, 7, q_text, text_color=q_color, text_size=size.small, text_halign=text.align_center) table.cell(t, 0, 8, "Distance", text_color=color.gray, text_size=size.small) table.cell(t, 1, 8, str.tostring(dist, "#.##") + "%", text_color=dist > 3.0 ? color.orange : color.silver, text_size=size.small, text_halign=text.align_center) table.cell(t, 0, 9, "Long Flips", text_color=color.gray, text_size=size.small) table.cell(t, 1, 9, str.tostring(bull_ct), text_color=i_bull, text_size=size.small, text_halign=text.align_center) table.cell(t, 0, 10, "Short Flips", text_color=color.gray, text_size=size.small) table.cell(t, 1, 10, str.tostring(bear_ct),text_color=i_bear, text_size=size.small, text_halign=text.align_center) // ═══════════════════════════════════════════════════════════════ // ALERTS // ═══════════════════════════════════════════════════════════════ alertcondition(flip_up, "Long Signal", "SuperTrend: LONG — {{ticker}} {{interval}} @ {{close}}") alertcondition(flip_down, "Short Signal", "SuperTrend: SHORT — {{ticker}} {{interval}} @ {{close}}") alertcondition(any_flip, "Any Flip", "SuperTrend: FLIP — {{ticker}} {{interval}} @ {{close}}")