# ==========================================
# MTFL - Multi-Timeframe Framework Levels
# ==========================================
input time_zone = {Eastern, default Central, Mountain, Pacific};
input show_labels = yes;
input show_lines = yes;
input enforce_hierarchy = yes;
input show_macro_levels = yes;
input show_2002 = yes;
input show_2009 = yes;
input show_2020 = yes;
input show_2022 = yes;
input show_2025 = yes;
input show_on_levels = yes;
input show_candle_levels = yes;
input show_daily_levels = yes;
input show_weekly_levels = yes;
input show_monthly_levels = yes;
input show_quarterly_levels = yes;
input show_yearly_levels = yes;
input show_alltime_levels = yes;
# ==========================================
# HIERARCHY
# ==========================================
def curAgg = GetAggregationPeriod();
def ms_day = 86400000;
def ms_week = 604800000;
def ms_month = 2700000000.0;
def ms_quarter = 8100000000.0;
def ms_year = 32000000000.0;
def allow_daily = if !enforce_hierarchy or curAgg <= ms_day then 1 else 0;
def allow_weekly = if !enforce_hierarchy or curAgg <= ms_week then 1 else 0;
def allow_monthly = if !enforce_hierarchy or curAgg <= ms_month then 1 else 0;
def allow_quarterly = if !enforce_hierarchy or curAgg <= ms_quarter then 1 else 0;
def allow_yearly = if !enforce_hierarchy or curAgg <= ms_year then 1 else 0;
def allow_on = curAgg < ms_day;
def is_dup_d = (curAgg == ms_day) and show_daily_levels;
def is_dup_w = (curAgg == ms_week) and show_weekly_levels;
def is_dup_m = (curAgg >= 2592000000.0 and curAgg <= ms_month) and show_monthly_levels;
def is_dup_q = (curAgg >= 7000000000.0 and curAgg <= ms_quarter) and show_quarterly_levels;
def is_dup_y = (curAgg >= 30000000000.0) and show_yearly_levels;
def show_final_pc = show_candle_levels and
!is_dup_d and !is_dup_w and !is_dup_m and !is_dup_q and !is_dup_y;
# ==========================================
# LAST VALID BAR & BUBBLE ANCHOR
# ==========================================
def lastValidBar = HighestAll(if !IsNaN(close) then BarNumber() else Double.NaN);
def validBar = !IsNaN(close);
# ==========================================
# PERIOD CHANGE DETECTION
# ==========================================
def newDay = GetDay() != GetDay()[1];
def newWeek = GetWeek() != GetWeek()[1];
def newMonth = GetMonth() != GetMonth()[1];
def newQuarter = newMonth and (GetMonth() == 1 or GetMonth() == 4 or
GetMonth() == 7 or GetMonth() == 10);
def newYear = GetYear() != GetYear()[1];
rec dayCount = CompoundValue(1, if newDay then dayCount[1] + 1 else dayCount[1], 1);
rec weekCount = CompoundValue(1, if newWeek then weekCount[1] + 1 else weekCount[1], 1);
rec monthCount = CompoundValue(1, if newMonth then monthCount[1] + 1 else monthCount[1], 1);
rec quarterCount = CompoundValue(1, if newQuarter then quarterCount[1] + 1 else quarterCount[1], 1);
rec yearCount = CompoundValue(1, if newYear then yearCount[1] + 1 else yearCount[1], 1);
def totalDays = HighestAll(if BarNumber() == lastValidBar then dayCount else 0);
def totalWeeks = HighestAll(if BarNumber() == lastValidBar then weekCount else 0);
def totalMonths = HighestAll(if BarNumber() == lastValidBar then monthCount else 0);
def totalQuarters = HighestAll(if BarNumber() == lastValidBar then quarterCount else 0);
def totalYears = HighestAll(if BarNumber() == lastValidBar then yearCount else 0);
def inCurrentDay = validBar and dayCount == totalDays;
def inCurrentWeek = validBar and weekCount == totalWeeks;
def inCurrentMonth = validBar and monthCount == totalMonths;
def inCurrentQuarter = validBar and quarterCount == totalQuarters;
def inCurrentYear = validBar and yearCount == totalYears;
# ==========================================
# PREVIOUS CANDLE
# ==========================================
def pch = high[1];
def pcl = low[1];
def pcm = (pch + pcl) / 2;
plot PC_High = if show_final_pc and show_lines and inCurrentDay then pch else Double.NaN;
PC_High.SetDefaultColor(CreateColor(255, 0, 128));
PC_High.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PC_High.SetLineWeight(1);
PC_High.HideBubble();
plot PC_Low = if show_final_pc and show_lines and inCurrentDay then pcl else Double.NaN;
PC_Low.SetDefaultColor(CreateColor(255, 0, 128));
PC_Low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PC_Low.SetLineWeight(1);
PC_Low.HideBubble();
plot PC_Mid = if show_final_pc and show_lines and inCurrentDay then pcm else Double.NaN;
PC_Mid.SetDefaultColor(CreateColor(255, 0, 128));
PC_Mid.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PC_Mid.SetLineWeight(1);
PC_Mid.HideBubble();
# ==========================================
# DAILY LEVELS
# ==========================================
def runD_H = CompoundValue(1, if newDay then high else Max(runD_H[1], high), high);
def runD_L = CompoundValue(1, if newDay then low else Min(runD_L[1], low), low);
def p_day_h = CompoundValue(1, if newDay then runD_H[1] else p_day_h[1], high);
def p_day_l = CompoundValue(1, if newDay then runD_L[1] else p_day_l[1], low);
def p_day_m = (p_day_h + p_day_l) / 2;
def flat_pdh = HighestAll(if BarNumber() == lastValidBar then p_day_h else Double.NaN);
def flat_pdl = HighestAll(if BarNumber() == lastValidBar then p_day_l else Double.NaN);
def flat_pdm = HighestAll(if BarNumber() == lastValidBar then p_day_m else Double.NaN);
plot PD_High = if show_daily_levels and allow_daily and show_lines and dayCount >= totalDays - 1 and validBar then flat_pdh else Double.NaN;
PD_High.SetDefaultColor(Color.GRAY);
PD_High.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PD_High.HideBubble();
plot PD_Low = if show_daily_levels and allow_daily and show_lines and dayCount >= totalDays - 1 and validBar then flat_pdl else Double.NaN;
PD_Low.SetDefaultColor(Color.GRAY);
PD_Low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PD_Low.HideBubble();
plot PD_Mid = if show_daily_levels and allow_daily and show_lines and dayCount >= totalDays - 1 and validBar then flat_pdm else Double.NaN;
PD_Mid.SetDefaultColor(Color.GRAY);
PD_Mid.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PD_Mid.HideBubble();
# ==========================================
# WEEKLY LEVELS
# ==========================================
def runW_H = CompoundValue(1, if newWeek then high else Max(runW_H[1], high), high);
def runW_L = CompoundValue(1, if newWeek then low else Min(runW_L[1], low), low);
def p_wk_h = CompoundValue(1, if newWeek then runW_H[1] else p_wk_h[1], high);
def p_wk_l = CompoundValue(1, if newWeek then runW_L[1] else p_wk_l[1], low);
def p_wk_m = (p_wk_h + p_wk_l) / 2;
def flat_pwh = HighestAll(if BarNumber() == lastValidBar then p_wk_h else Double.NaN);
def flat_pwl = HighestAll(if BarNumber() == lastValidBar then p_wk_l else Double.NaN);
def flat_pwm = HighestAll(if BarNumber() == lastValidBar then p_wk_m else Double.NaN);
plot PW_High = if show_weekly_levels and allow_weekly and show_lines and weekCount >= totalWeeks - 1 and validBar then flat_pwh else Double.NaN;
PW_High.SetDefaultColor(Color.WHITE);
PW_High.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PW_High.HideBubble();
plot PW_Low = if show_weekly_levels and allow_weekly and show_lines and weekCount >= totalWeeks - 1 and validBar then flat_pwl else Double.NaN;
PW_Low.SetDefaultColor(Color.WHITE);
PW_Low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PW_Low.HideBubble();
plot PW_Mid = if show_weekly_levels and allow_weekly and show_lines and weekCount >= totalWeeks - 1 and validBar then flat_pwm else Double.NaN;
PW_Mid.SetDefaultColor(Color.WHITE);
PW_Mid.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PW_Mid.HideBubble();
# ==========================================
# MONTHLY LEVELS
# ==========================================
def runM_H = CompoundValue(1, if newMonth then high else Max(runM_H[1], high), high);
def runM_L = CompoundValue(1, if newMonth then low else Min(runM_L[1], low), low);
def p_mn_h = CompoundValue(1, if newMonth then runM_H[1] else p_mn_h[1], high);
def p_mn_l = CompoundValue(1, if newMonth then runM_L[1] else p_mn_l[1], low);
def p_mn_m = (p_mn_h + p_mn_l) / 2;
def flat_pmnh = HighestAll(if BarNumber() == lastValidBar then p_mn_h else Double.NaN);
def flat_pmnl = HighestAll(if BarNumber() == lastValidBar then p_mn_l else Double.NaN);
def flat_pmnm = HighestAll(if BarNumber() == lastValidBar then p_mn_m else Double.NaN);
plot PM_High = if show_monthly_levels and allow_monthly and show_lines and monthCount >= totalMonths - 1 and validBar then flat_pmnh else Double.NaN;
PM_High.SetDefaultColor(Color.DARK_RED);
PM_High.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PM_High.HideBubble();
plot PM_Low = if show_monthly_levels and allow_monthly and show_lines and monthCount >= totalMonths - 1 and validBar then flat_pmnl else Double.NaN;
PM_Low.SetDefaultColor(Color.DARK_RED);
PM_Low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PM_Low.HideBubble();
plot PM_Mid = if show_monthly_levels and allow_monthly and show_lines and monthCount >= totalMonths - 1 and validBar then flat_pmnm else Double.NaN;
PM_Mid.SetDefaultColor(Color.DARK_RED);
PM_Mid.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PM_Mid.HideBubble();
# ==========================================
# QUARTERLY LEVELS
# ==========================================
def runQ_H = CompoundValue(1, if newQuarter then high else Max(runQ_H[1], high), high);
def runQ_L = CompoundValue(1, if newQuarter then low else Min(runQ_L[1], low), low);
def prev_qt_h = CompoundValue(1, if newQuarter then runQ_H[1] else prev_qt_h[1], high);
def prev_qt_l = CompoundValue(1, if newQuarter then runQ_L[1] else prev_qt_l[1], low);
def prev_qt_m = (prev_qt_h + prev_qt_l) / 2;
def flat_pqh = HighestAll(if BarNumber() == lastValidBar then prev_qt_h else Double.NaN);
def flat_pql = HighestAll(if BarNumber() == lastValidBar then prev_qt_l else Double.NaN);
def flat_pqm = HighestAll(if BarNumber() == lastValidBar then prev_qt_m else Double.NaN);
plot PQ_High = if show_quarterly_levels and allow_quarterly and show_lines and quarterCount >= totalQuarters - 1 and validBar then flat_pqh else Double.NaN;
PQ_High.SetDefaultColor(CreateColor(170, 152, 169));
PQ_High.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PQ_High.HideBubble();
plot PQ_Low = if show_quarterly_levels and allow_quarterly and show_lines and quarterCount >= totalQuarters - 1 and validBar then flat_pql else Double.NaN;
PQ_Low.SetDefaultColor(CreateColor(170, 152, 169));
PQ_Low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PQ_Low.HideBubble();
plot PQ_Mid = if show_quarterly_levels and allow_quarterly and show_lines and quarterCount >= totalQuarters - 1 and validBar then flat_pqm else Double.NaN;
PQ_Mid.SetDefaultColor(CreateColor(170, 152, 169));
PQ_Mid.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PQ_Mid.HideBubble();
# ==========================================
# YEARLY LEVELS
# ==========================================
def runY_H = CompoundValue(1, if newYear then high else Max(runY_H[1], high), high);
def runY_L = CompoundValue(1, if newYear then low else Min(runY_L[1], low), low);
def prev_yr_h = CompoundValue(1, if newYear then runY_H[1] else prev_yr_h[1], high);
def prev_yr_l = CompoundValue(1, if newYear then runY_L[1] else prev_yr_l[1], low);
def prev_yr_m = (prev_yr_h + prev_yr_l) / 2;
def flat_pyh = HighestAll(if BarNumber() == lastValidBar then prev_yr_h else Double.NaN);
def flat_pyl = HighestAll(if BarNumber() == lastValidBar then prev_yr_l else Double.NaN);
def flat_pym = HighestAll(if BarNumber() == lastValidBar then prev_yr_m else Double.NaN);
plot PY_High = if show_yearly_levels and allow_yearly and show_lines and yearCount >= totalYears - 1 and validBar then flat_pyh else Double.NaN;
PY_High.SetDefaultColor(Color.YELLOW);
PY_High.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PY_High.HideBubble();
plot PY_Low = if show_yearly_levels and allow_yearly and show_lines and yearCount >= totalYears - 1 and validBar then flat_pyl else Double.NaN;
PY_Low.SetDefaultColor(Color.YELLOW);
PY_Low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PY_Low.HideBubble();
plot PY_Mid = if show_yearly_levels and allow_yearly and show_lines and yearCount >= totalYears - 1 and validBar then flat_pym else Double.NaN;
PY_Mid.SetDefaultColor(Color.YELLOW);
PY_Mid.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PY_Mid.HideBubble();
# ==========================================
# ALL-TIME HIGH / LOW
# ==========================================
def ath = HighestAll(if validBar then high else Double.NaN);
def atl = LowestAll(if validBar then low else Double.NaN);
def atm = (ath + atl) / 2;
plot ATH_Line = if show_alltime_levels and show_lines and inCurrentYear then ath else Double.NaN;
ATH_Line.SetDefaultColor(CreateColor(0, 255, 255));
ATH_Line.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ATH_Line.HideBubble();
plot ATL_Line = if show_alltime_levels and show_lines and inCurrentYear then atl else Double.NaN;
ATL_Line.SetDefaultColor(CreateColor(0, 255, 255));
ATL_Line.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ATL_Line.HideBubble();
plot ATM_Line = if show_alltime_levels and show_lines and inCurrentYear then atm else Double.NaN;
ATM_Line.SetDefaultColor(CreateColor(0, 255, 255));
ATM_Line.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ATM_Line.HideBubble();
# ==========================================
# MACRO LEGACY LEVELS
# ==========================================
def y2002_low = LowestAll(if GetYear() == 2002 then low else Double.NaN);
def y2009_low = LowestAll(if GetYear() == 2009 then low else Double.NaN);
def y2020_low = LowestAll(if GetYear() == 2020 then low else Double.NaN);
def y2022_low = LowestAll(if GetYear() == 2022 then low else Double.NaN);
def y2025_low = LowestAll(if GetYear() == 2025 then low else Double.NaN);
plot DotCom_Low = if show_macro_levels and show_2002 and show_lines and GetYear() >= 2002 and validBar then y2002_low else Double.NaN;
DotCom_Low.SetDefaultColor(CreateColor(152, 255, 152));
DotCom_Low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
DotCom_Low.SetLineWeight(2);
DotCom_Low.HideBubble();
plot GFC_Low = if show_macro_levels and show_2009 and show_lines and GetYear() >= 2009 and validBar then y2009_low else Double.NaN;
GFC_Low.SetDefaultColor(CreateColor(152, 255, 152));
GFC_Low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
GFC_Low.SetLineWeight(2);
GFC_Low.HideBubble();
plot Covid_Low = if show_macro_levels and show_2020 and show_lines and GetYear() >= 2020 and validBar then y2020_low else Double.NaN;
Covid_Low.SetDefaultColor(CreateColor(152, 255, 152));
Covid_Low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Covid_Low.SetLineWeight(2);
Covid_Low.HideBubble();
plot Inflation_Low = if show_macro_levels and show_2022 and show_lines and GetYear() >= 2022 and validBar then y2022_low else Double.NaN;
Inflation_Low.SetDefaultColor(CreateColor(152, 255, 152));
Inflation_Low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Inflation_Low.SetLineWeight(2);
Inflation_Low.HideBubble();
plot Tariff_Low = if show_macro_levels and show_2025 and show_lines and GetYear() >= 2025 and validBar then y2025_low else Double.NaN;
Tariff_Low.SetDefaultColor(CreateColor(152, 255, 152));
Tariff_Low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Tariff_Low.SetLineWeight(2);
Tariff_Low.HideBubble();
# ==========================================
# OVERNIGHT / PRE-MARKET
# ==========================================
def tz_offset = if time_zone == time_zone.Eastern then 0
else if time_zone == time_zone.Central then 100
else if time_zone == time_zone.Mountain then 200
else 300;
def inPreMarket = SecondsFromTime(400 - tz_offset) >= 0 and SecondsTillTime(930 - tz_offset) >= 0;
def inAfterHours = SecondsFromTime(1600 - tz_offset) >= 0;
def inOvernightWindow = inPreMarket or inAfterHours;
def onHigh;
def onLow;
if inOvernightWindow {
if !inOvernightWindow[1] {
onHigh = high;
onLow = low;
} else {
onHigh = Max(onHigh[1], high);
onLow = Min(onLow[1], low);
}
} else {
onHigh = onHigh[1];
onLow = onLow[1];
}
def finalONHigh;
def finalONLow;
if !inOvernightWindow and inOvernightWindow[1] {
finalONHigh = onHigh[1];
finalONLow = onLow[1];
} else {
finalONHigh = finalONHigh[1];
finalONLow = finalONLow[1];
}
plot ON_High = if show_on_levels and allow_on and show_lines and inCurrentDay then finalONHigh else Double.NaN;
ON_High.SetDefaultColor(Color.ORANGE);
ON_High.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ON_High.HideBubble();
plot ON_Low = if show_on_levels and allow_on and show_lines and inCurrentDay then finalONLow else Double.NaN;
ON_Low.SetDefaultColor(Color.ORANGE);
ON_Low.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ON_Low.HideBubble();
# ==========================================
# LABELS (STAGGERED TO PREVENT OVERLAP)
# ==========================================
def last_pch = HighestAll(if BarNumber() == lastValidBar then pch else Double.NaN);
def last_pcl = HighestAll(if BarNumber() == lastValidBar then pcl else Double.NaN);
def last_pcm = HighestAll(if BarNumber() == lastValidBar then pcm else Double.NaN);
def last_pdh = flat_pdh;
def last_pdl = flat_pdl;
def last_pdm = flat_pdm;
def last_pwh = flat_pwh;
def last_pwl = flat_pwl;
def last_pwm = flat_pwm;
def last_pmnh = flat_pmnh;
def last_pmnl = flat_pmnl;
def last_pmnm = flat_pmnm;
def last_pqh = flat_pqh;
def last_pql = flat_pql;
def last_pqm = flat_pqm;
def last_pyh = flat_pyh;
def last_pyl = flat_pyl;
def last_pym = flat_pym;
def last_ath = ath;
def last_atl = atl;
def last_atm = atm;
def last_2002 = y2002_low;
def last_2009 = y2009_low;
def last_2020 = y2020_low;
def last_2022 = y2022_low;
def last_2025 = y2025_low;
def last_onh = HighestAll(if BarNumber() == lastValidBar then finalONHigh else Double.NaN);
def last_onl = HighestAll(if BarNumber() == lastValidBar then finalONLow else Double.NaN);
def loc_pc = BarNumber() == lastValidBar;
def loc_on = BarNumber() == lastValidBar + 1;
def loc_d = BarNumber() == lastValidBar + 3;
def loc_w = BarNumber() == lastValidBar + 5;
def loc_m = BarNumber() == lastValidBar + 7;
def loc_q = BarNumber() == lastValidBar + 9;
def loc_y = BarNumber() == lastValidBar + 11;
AddChartBubble(show_labels and show_final_pc and loc_pc, last_pch, "PCH (" + AsText(last_pch, NumberFormat.TWO_DECIMAL_PLACES) + ")", CreateColor(255, 0, 128), yes);
AddChartBubble(show_labels and show_final_pc and loc_pc, last_pcl, "PCL (" + AsText(last_pcl, NumberFormat.TWO_DECIMAL_PLACES) + ")", CreateColor(255, 0, 128), no);
AddChartBubble(show_labels and show_final_pc and loc_pc, last_pcm, "PCM (" + AsText(last_pcm, NumberFormat.TWO_DECIMAL_PLACES) + ")", CreateColor(255, 0, 128), no);
AddChartBubble(show_labels and show_on_levels and allow_on and loc_on, last_onh, "ON High (" + AsText(last_onh, NumberFormat.TWO_DECIMAL_PLACES) + ")", Color.ORANGE, yes);
AddChartBubble(show_labels and show_on_levels and allow_on and loc_on, last_onl, "ON Low (" + AsText(last_onl, NumberFormat.TWO_DECIMAL_PLACES) + ")", Color.ORANGE, no);
AddChartBubble(show_labels and show_daily_levels and allow_daily and loc_d, last_pdh, "PDH (" + AsText(last_pdh, NumberFormat.TWO_DECIMAL_PLACES) + ")", Color.GRAY, yes);
AddChartBubble(show_labels and show_daily_levels and allow_daily and loc_d, last_pdl, "PDL (" + AsText(last_pdl, NumberFormat.TWO_DECIMAL_PLACES) + ")", Color.GRAY, no);
AddChartBubble(show_labels and show_daily_levels and allow_daily and loc_d, last_pdm, "PDM (" + AsText(last_pdm, NumberFormat.TWO_DECIMAL_PLACES) + ")", Color.GRAY, no);
AddChartBubble(show_labels and show_weekly_levels and allow_weekly and loc_w, last_pwh, "PWH (" + AsText(last_pwh, NumberFormat.TWO_DECIMAL_PLACES) + ")", Color.WHITE, yes);
AddChartBubble(show_labels and show_weekly_levels and allow_weekly and loc_w, last_pwl, "PWL (" + AsText(last_pwl, NumberFormat.TWO_DECIMAL_PLACES) + ")", Color.WHITE, no);
AddChartBubble(show_labels and show_weekly_levels and allow_weekly and loc_w, last_pwm, "PWM (" + AsText(last_pwm, NumberFormat.TWO_DECIMAL_PLACES) + ")", Color.WHITE, no);
AddChartBubble(show_labels and show_monthly_levels and allow_monthly and loc_m, last_pmnh, "PMH (" + AsText(last_pmnh, NumberFormat.TWO_DECIMAL_PLACES) + ")", Color.DARK_RED, yes);
AddChartBubble(show_labels and show_monthly_levels and allow_monthly and loc_m, last_pmnl, "PML (" + AsText(last_pmnl, NumberFormat.TWO_DECIMAL_PLACES) + ")", Color.DARK_RED, no);
AddChartBubble(show_labels and show_monthly_levels and allow_monthly and loc_m, last_pmnm, "PMM (" + AsText(last_pmnm, NumberFormat.TWO_DECIMAL_PLACES) + ")", Color.DARK_RED, no);
AddChartBubble(show_labels and show_quarterly_levels and allow_quarterly and loc_q, last_pqh, "PQH (" + AsText(last_pqh, NumberFormat.TWO_DECIMAL_PLACES) + ")", CreateColor(170, 152, 169), yes);
AddChartBubble(show_labels and show_quarterly_levels and allow_quarterly and loc_q, last_pql, "PQL (" + AsText(last_pql, NumberFormat.TWO_DECIMAL_PLACES) + ")", CreateColor(170, 152, 169), no);
AddChartBubble(show_labels and show_quarterly_levels and allow_quarterly and loc_q, last_pqm, "PQM (" + AsText(last_pqm, NumberFormat.TWO_DECIMAL_PLACES) + ")", CreateColor(170, 152, 169), no);
AddChartBubble(show_labels and show_yearly_levels and allow_yearly and loc_y, last_pyh, "PYH (" + AsText(last_pyh, NumberFormat.TWO_DECIMAL_PLACES) + ")", Color.YELLOW, yes);
AddChartBubble(show_labels and show_yearly_levels and allow_yearly and loc_y, last_pyl, "PYL (" + AsText(last_pyl, NumberFormat.TWO_DECIMAL_PLACES) + ")", Color.YELLOW, no);
AddChartBubble(show_labels and show_yearly_levels and allow_yearly and loc_y, last_pym, "PYM (" + AsText(last_pym, NumberFormat.TWO_DECIMAL_PLACES) + ")", Color.YELLOW, no);
AddChartBubble(show_labels and show_alltime_levels and loc_pc, last_ath, "ATH (" + AsText(last_ath, NumberFormat.TWO_DECIMAL_PLACES) + ")", CreateColor(0, 255, 255), yes);
AddChartBubble(show_labels and show_alltime_levels and loc_pc, last_atl, "ATL (" + AsText(last_atl, NumberFormat.TWO_DECIMAL_PLACES) + ")", CreateColor(0, 255, 255), no);
AddChartBubble(show_labels and show_alltime_levels and loc_pc, last_atm, "ATM (" + AsText(last_atm, NumberFormat.TWO_DECIMAL_PLACES) + ")", CreateColor(0, 255, 255), no);
AddChartBubble(show_labels and show_macro_levels and show_2002 and loc_pc, last_2002, "DotCom (" + AsText(last_2002, NumberFormat.TWO_DECIMAL_PLACES) + ")", CreateColor(152, 255, 152), no);
AddChartBubble(show_labels and show_macro_levels and show_2009 and loc_pc, last_2009, "GFC (" + AsText(last_2009, NumberFormat.TWO_DECIMAL_PLACES) + ")", CreateColor(152, 255, 152), no);
AddChartBubble(show_labels and show_macro_levels and show_2020 and loc_pc, last_2020, "Covid (" + AsText(last_2020, NumberFormat.TWO_DECIMAL_PLACES) + ")", CreateColor(152, 255, 152), no);
AddChartBubble(show_labels and show_macro_levels and show_2022 and loc_pc, last_2022, "Infl (" + AsText(last_2022, NumberFormat.TWO_DECIMAL_PLACES) + ")", CreateColor(152, 255, 152), no);
AddChartBubble(show_labels and show_macro_levels and show_2025 and loc_pc, last_2025, "Tariff (" + AsText(last_2025, NumberFormat.TWO_DECIMAL_PLACES) + ")", CreateColor(152, 255, 152), no);