Repaints Multi Time Frame MTF Squeeze PRO Labels for ThinkOrSwim

Repaints
Thats dumb lol but thank you for getting back to me quickly. I was trying to combine the code bahaha no bueno. This is definitely useful though thank you
 
Here is the script I wrote for MTF (Multi Time Frame) Squeeze Pro Labels. Just to be clear, this is NOT the same as my MTF Squeeze HISTOGRAM Labels. These labels change colors based on the presence/absence of a squeeze. If there's an original squeeze, the label's red, if there's a "Pre-Squeeze" the label's orange, if there's an "Extra-Squeeze" the label's yellow, and if there's no squeeze, the label's green. Per a recent comment under my MTF Squeeze HISTOGRAM Labels thread, I have revised this script (1/5/2022). This script is more succinct with the Global Colors. More importantly, you are now able to turn on/off any time frames that you do not wish to be displayed on your chart(s). Enjoy!
Code:
#MTF SQUEEZE PRO LABELS
#BY: CASEY BRETT WITH THE USE OF CODE FROM: TOS Indicators

##Global Variables
input length = 20;
def AlertLine = 1;
input nk = 1.5;
input nkHi = 2;
input nkLo = 1;
def nBB = 2;
input averageType = AverageType.EXPONENTIAL;
def displace = 0;
input trueRangeAverageType = AverageType.SIMPLE;


input MonthLabel = yes;
input WeekLabel = yes;
input FourDayLabel = yes;
input ThreeDayLabel = yes;
input TwoDayLabel = yes;
input DayLabel = yes;
input FourHourLabel = yes;
input TwoHourLabel = yes;
input HourLabel = yes;
input ThirtyMinLabel = yes;
input TwentyMinLabel = yes;
input FifteenMinLabel = yes;
input TenMinLabel = yes;
input FiveMinLabel = yes;
input FourMinLabel = yes;
input ThreeMinLabel = yes;
input TwoMinLabel = yes;
input OneMinLabel = yes;


DefineGlobalColor("Squeeze", Color.RED);
DefineGlobalColor("PreSqueeze", Color.ORANGE);
DefineGlobalColor("ExtraSqueeze", Color.YELLOW);
DefineGlobalColor("NO Squeeze", Color.DARK_GREEN);

## Month Aggregation Period Variables

def monthPrice;
def monthATR;
def monthSDev;
def monthDenom;
def monthDenomLo;
def monthDenomHi;
def monthBBSInd;
def monthBBSIndLo;
def monthBBSIndHi;
def monthSqueeze;
def monthPreSqueeze;
def monthExtraSqueeze;
def monthAggregationPeriod;
if GetAggregationPeriod() <= AggregationPeriod.MONTH {
    monthPrice = close(period = "Month");
    monthATR = Average(TrueRange(high (period = "Month"), close(period = "Month"), low(period = "Month")), length);
    monthSDev = StDev(monthPrice, length);
    monthDenom = (nk * monthATR);
    monthDenomLo = (nkLo * monthATR);
    monthDenomHi = (nkHi * monthATR);
    monthBBSInd = If (monthDenom <> 0, ((nBB * monthSDev) / monthDenom), 0);
    monthBBSIndLo = If (monthDenomLo <> 0, ((nBB * monthSDev) / monthDenomLo), 0);
    monthBBSIndHi = If (monthDenomHi <> 0, ((nBB * monthSDev) / monthDenomHi), 0);
    monthSqueeze = if monthBBSInd < AlertLine then 1 else 0;
    monthPreSqueeze = if monthBBSIndHi < AlertLine then 1 else 0;
    monthExtraSqueeze = if monthBBSIndLo < AlertLine then 1 else 0;
    monthAggregationPeriod = 1;
}
else {
    monthPrice = 0;
    monthATR = 0;
    monthSDev = 0;
    monthDenom = 0;
    monthDenomLo = 0;
    monthDenomHi = 0;
    monthBBSInd = 0;
    monthBBSIndLo = 0;
    monthBBSIndHi = 0;
    monthSqueeze = 0;
    monthPreSqueeze = 0;
    monthExtraSqueeze = 0;
    monthAggregationPeriod = 0;
}
AddLabel(MonthLabel and monthAggregationPeriod, "M", if monthSqueeze then GlobalColor("Squeeze") else if monthExtraSqueeze then GlobalColor("ExtraSqueeze") else if monthPreSqueeze then GlobalColor("PreSqueeze") else GlobalColor("No Squeeze"));

def weekPrice;
def weekATR;
def weekSDev;
def weekDenom;
def weekDenomLo;
def weekDenomHi;
def weekBBSInd;
def weekBBSIndLo;
def weekBBSIndHi;
def weekSqueeze;
def weekPreSqueeze;
def weekExtraSqueeze;
def WeekAggregationPeriod;
if GetAggregationPeriod() <= AggregationPeriod.WEEK {
    weekPrice = close(period = "week");
    weekATR = Average(TrueRange(high (period = "week"), close(period = "week"), low(period = "week")), length);
    weekSDev = StDev(weekPrice, length);
    weekDenom = (nk * weekATR);
    weekDenomLo = (nkLo * weekATR);
    weekDenomHi = (nkHi * weekATR);
    weekBBSInd = If (weekDenom <> 0, ((nBB * weekSDev) / weekDenom), 0);
    weekBBSIndLo = If (weekDenomLo <> 0, ((nBB * weekSDev) / weekDenomLo), 0);
    weekBBSIndHi = If (weekDenomHi <> 0, ((nBB * weekSDev) / weekDenomHi), 0);
    weekSqueeze = if weekBBSInd < AlertLine then 1 else 0;
    weekPreSqueeze = if weekBBSIndHi < AlertLine then 1 else 0;
    weekExtraSqueeze = if weekBBSIndLo < AlertLine then 1 else 0;
    WeekAggregationPeriod = 1;
}
else {
    weekPrice = 0;
    weekATR = 0;
    weekSDev = 0;
    weekDenom = 0;
    weekDenomLo = 0;
    weekDenomHi = 0;
    weekBBSInd = 0;
    weekBBSIndLo = 0;
    weekBBSIndHi = 0;
    weekSqueeze = 0;
    weekPreSqueeze = 0;
    weekExtraSqueeze = 0;
    WeekAggregationPeriod = 0;
}
AddLabel(WeekLabel and WeekAggregationPeriod, "W", if weekSqueeze then GlobalColor("Squeeze") else if weekExtraSqueeze then GlobalColor("ExtraSqueeze") else if weekPreSqueeze then GlobalColor("PreSqueeze") else GlobalColor("No Squeeze"));
# AddLabel(weekExtraSqueeze and weekAggregationPeriod, "W", globalColor("week Squeeze"));
# AddLabel(!weekSqueeze and weekAggregationPeriod,"W", globalColor("NO week Squeeze"));


def four_daysPrice;
def four_daysATR;
def four_daysSDev;
def four_daysDenom;
def four_daysDenomLo;
def four_daysDenomHi;
def four_daysBBSInd;
def four_daysBBSIndLo;
def four_daysBBSIndHi;
def four_daysSqueeze;
def four_daysPreSqueeze;
def four_daysExtraSqueeze;
def Four_DayMinAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.FOUR_DAYS {
    four_daysPrice = close(period = "4 Days");
    four_daysATR = Average(TrueRange(high (period = "4 Days"), close(period = "4 Days"), low(period = "4 Days")), length);
    four_daysSDev = StDev(four_daysPrice, length);
    four_daysDenom = (nk * four_daysATR);
    four_daysDenomLo = (nkLo * four_daysATR);
    four_daysDenomHi = (nkHi * four_daysATR);
    four_daysBBSInd = If (four_daysDenom <> 0, ((nBB * four_daysSDev) / four_daysDenom), 0);
    four_daysBBSIndLo = If (four_daysDenomLo <> 0, ((nBB * four_daysSDev) / four_daysDenomLo), 0);
    four_daysBBSIndHi = If (four_daysDenomHi <> 0, ((nBB * four_daysSDev) / four_daysDenomHi), 0);
    four_daysSqueeze = if four_daysBBSInd < AlertLine then 1 else 0;
    four_daysPreSqueeze = if four_daysBBSIndHi < AlertLine then 1 else 0;
    four_daysExtraSqueeze = if four_daysBBSIndLo < AlertLine then 1 else 0;
    Four_DayMinAggregationPeriod = 1;
}
else {
    four_daysPrice = 0;
    four_daysATR = 0;
    four_daysSDev = 0;
    four_daysDenom = 0;
    four_daysDenomLo = 0;
    four_daysDenomHi = 0;
    four_daysBBSInd = 0;
    four_daysBBSIndLo = 0;
    four_daysBBSIndHi = 0;
    four_daysSqueeze = 0;
    four_daysPreSqueeze = 0;
    four_daysExtraSqueeze = 0;
    Four_DayMinAggregationPeriod = 0;
}
AddLabel(FourDayLabel and Four_DayMinAggregationPeriod, "4D", if four_daysSqueeze then GlobalColor("Squeeze") else if four_daysExtraSqueeze then GlobalColor("ExtraSqueeze") else if four_daysPreSqueeze then GlobalColor("PreSqueeze") else GlobalColor("No Squeeze"));
# AddLabel(four_daysExtraSqueeze and four_daysAggregationPeriod, "W", globalColor("four_days Squeeze"));
# AddLabel(!four_daysSqueeze and four_daysAggregationPeriod,"W", globalColor("NO four_days Squeeze"));


def three_daysPrice;
def three_daysATR;
def three_daysSDev;
def three_daysDenom;
def three_daysDenomLo;
def three_daysDenomHi;
def three_daysBBSInd;
def three_daysBBSIndLo;
def three_daysBBSIndHi;
def three_daysSqueeze;
def three_daysPreSqueeze;
def three_daysExtraSqueeze;
def three_dayMinAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.THREE_DAYS {
    three_daysPrice = close(period = "3 Days");
    three_daysATR = Average(TrueRange(high (period = "3 Days"), close(period = "3 Days"), low(period = "3 Days")), length);
    three_daysSDev = StDev(three_daysPrice, length);
    three_daysDenom = (nk * three_daysATR);
    three_daysDenomLo = (nkLo * three_daysATR);
    three_daysDenomHi = (nkHi * three_daysATR);
    three_daysBBSInd = If (three_daysDenom <> 0, ((nBB * three_daysSDev) / three_daysDenom), 0);
    three_daysBBSIndLo = If (three_daysDenomLo <> 0, ((nBB * three_daysSDev) / three_daysDenomLo), 0);
    three_daysBBSIndHi = If (three_daysDenomHi <> 0, ((nBB * three_daysSDev) / three_daysDenomHi), 0);
    three_daysSqueeze = if three_daysBBSInd < AlertLine then 1 else 0;
    three_daysPreSqueeze = if three_daysBBSIndHi < AlertLine then 1 else 0;
    three_daysExtraSqueeze = if three_daysBBSIndLo < AlertLine then 1 else 0;
    three_dayMinAggregationPeriod = 1;
}
else {
    three_daysPrice = 0;
    three_daysATR = 0;
    three_daysSDev = 0;
    three_daysDenom = 0;
    three_daysDenomLo = 0;
    three_daysDenomHi = 0;
    three_daysBBSInd = 0;
    three_daysBBSIndLo = 0;
    three_daysBBSIndHi = 0;
    three_daysSqueeze = 0;
    three_daysPreSqueeze = 0;
    three_daysExtraSqueeze = 0;
    three_dayMinAggregationPeriod = 0;
}
AddLabel(ThreeDayLabel and three_dayMinAggregationPeriod, "3D", if three_daysSqueeze then GlobalColor("Squeeze") else if three_daysExtraSqueeze then GlobalColor("ExtraSqueeze") else if three_daysPreSqueeze then GlobalColor("PreSqueeze") else GlobalColor("No Squeeze"));


def two_daysPrice;
def two_daysATR;
def two_daysSDev;
def two_daysDenom;
def two_daysDenomLo;
def two_daysDenomHi;
def two_daysBBSInd;
def two_daysBBSIndLo;
def two_daysBBSIndHi;
def two_daysSqueeze;
def two_daysPreSqueeze;
def two_daysExtraSqueeze;
def two_dayMinAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.TWO_DAYS {
    two_daysPrice = close(period = "2 Days");
    two_daysATR = Average(TrueRange(high (period = "2 Days"), close(period = "2 Days"), low(period = "2 Days")), length);
    two_daysSDev = StDev(two_daysPrice, length);
    two_daysDenom = (nk * two_daysATR);
    two_daysDenomLo = (nkLo * two_daysATR);
    two_daysDenomHi = (nkHi * two_daysATR);
    two_daysBBSInd = If (two_daysDenom <> 0, ((nBB * two_daysSDev) / two_daysDenom), 0);
    two_daysBBSIndLo = If (two_daysDenomLo <> 0, ((nBB * two_daysSDev) / two_daysDenomLo), 0);
    two_daysBBSIndHi = If (two_daysDenomHi <> 0, ((nBB * two_daysSDev) / two_daysDenomHi), 0);
    two_daysSqueeze = if two_daysBBSInd < AlertLine then 1 else 0;
    two_daysPreSqueeze = if two_daysBBSIndHi < AlertLine then 1 else 0;
    two_daysExtraSqueeze = if two_daysBBSIndLo < AlertLine then 1 else 0;
    two_dayMinAggregationPeriod = 1;
}
else {
    two_daysPrice = 0;
    two_daysATR = 0;
    two_daysSDev = 0;
    two_daysDenom = 0;
    two_daysDenomLo = 0;
    two_daysDenomHi = 0;
    two_daysBBSInd = 0;
    two_daysBBSIndLo = 0;
    two_daysBBSIndHi = 0;
    two_daysSqueeze = 0;
    two_daysPreSqueeze = 0;
    two_daysExtraSqueeze = 0;
    two_dayMinAggregationPeriod = 0;
}
AddLabel(TwoDayLabel and two_dayMinAggregationPeriod, "2D", if two_daysSqueeze then GlobalColor("Squeeze") else if two_daysExtraSqueeze then GlobalColor("ExtraSqueeze") else if two_daysPreSqueeze then GlobalColor("PreSqueeze") else GlobalColor("No Squeeze"));

def dayPrice;
def dayATR;
def daySDev;
def dayDenom;
def dayDenomLo;
def dayDenomHi;
def dayBBSInd;
def dayBBSIndLo;
def dayBBSIndHi;
def daySqueeze;
def dayPreSqueeze;
def dayExtraSqueeze;
def dayMinAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.DAY {
    dayPrice = close(period = "Day");
    dayATR = Average(TrueRange(high (period = "Day"), close(period = "Day"), low(period = "Day")), length);
    daySDev = StDev(dayPrice, length);
    dayDenom = (nk * dayATR);
    dayDenomLo = (nkLo * dayATR);
    dayDenomHi = (nkHi * dayATR);
    dayBBSInd = If (dayDenom <> 0, ((nBB * daySDev) / dayDenom), 0);
    dayBBSIndLo = If (dayDenomLo <> 0, ((nBB * daySDev) / dayDenomLo), 0);
    dayBBSIndHi = If (dayDenomHi <> 0, ((nBB * daySDev) / dayDenomHi), 0);
    daySqueeze = if dayBBSInd < AlertLine then 1 else 0;
    dayPreSqueeze = if dayBBSIndHi < AlertLine then 1 else 0;
    dayExtraSqueeze = if dayBBSIndLo < AlertLine then 1 else 0;
    dayMinAggregationPeriod = 1;
}
else {
    dayPrice = 0;
    dayATR = 0;
    daySDev = 0;
    dayDenom = 0;
    dayDenomLo = 0;
    dayDenomHi = 0;
    dayBBSInd = 0;
    dayBBSIndLo = 0;
    dayBBSIndHi = 0;
    daySqueeze = 0;
    dayPreSqueeze = 0;
    dayExtraSqueeze = 0;
    dayMinAggregationPeriod = 0;
}
AddLabel(DayLabel and dayMinAggregationPeriod, "D", if daySqueeze then GlobalColor("Squeeze") else if dayExtraSqueeze then GlobalColor("ExtraSqueeze") else if dayPreSqueeze then GlobalColor("PreSqueeze") else GlobalColor("No Squeeze"));

def four_hoursPrice;
def four_hoursATR;
def four_hoursSDev;
def four_hoursDenom;
def four_hoursDenomLo;
def four_hoursDenomHi;
def four_hoursBBSInd;
def four_hoursBBSIndLo;
def four_hoursBBSIndHi;
def four_hoursSqueeze;
def four_hoursPreSqueeze;
def four_hoursExtraSqueeze;
def FourHourMinAggregationPeriod;
if GetAggregationPeriod() <= AggregationPeriod.FOUR_HOURS {
    four_hoursPrice = close(period = "4 Hours");
    four_hoursATR = Average(TrueRange(high (period = "4 Hours"), close(period = "4 Hours"), low(period = "4 Hours")), length);
    four_hoursSDev = StDev(four_hoursPrice, length);
    four_hoursDenom = (nk * four_hoursATR);
    four_hoursDenomLo = (nkLo * four_hoursATR);
    four_hoursDenomHi = (nkHi * four_hoursATR);
    four_hoursBBSInd = If (four_hoursDenom <> 0, ((nBB * four_hoursSDev) / four_hoursDenom), 0);
    four_hoursBBSIndLo = If (four_hoursDenomLo <> 0, ((nBB * four_hoursSDev) / four_hoursDenomLo), 0);
    four_hoursBBSIndHi = If (four_hoursDenomHi <> 0, ((nBB * four_hoursSDev) / four_hoursDenomHi), 0);
    four_hoursSqueeze = if four_hoursBBSInd < AlertLine then 1 else 0;
    four_hoursPreSqueeze = if four_hoursBBSIndHi < AlertLine then 1 else 0;
    four_hoursExtraSqueeze = if four_hoursBBSIndLo < AlertLine then 1 else 0;
    FourHourMinAggregationPeriod = 1;
}
else {
    four_hoursPrice = 0;
    four_hoursATR = 0;
    four_hoursSDev = 0;
    four_hoursDenom = 0;
    four_hoursDenomLo = 0;
    four_hoursDenomHi = 0;
    four_hoursBBSInd = 0;
    four_hoursBBSIndLo = 0;
    four_hoursBBSIndHi = 0;
    four_hoursSqueeze = 0;
    four_hoursPreSqueeze = 0;
    four_hoursExtraSqueeze = 0;
    FourHourMinAggregationPeriod = 0;
}
AddLabel(FourHourLabel and FourHourMinAggregationPeriod, "4h", if four_hoursSqueeze then GlobalColor("Squeeze") else if four_hoursPreSqueeze then GlobalColor("PreSqueeze") else if four_hoursExtraSqueeze then GlobalColor("ExtraSqueeze") else GlobalColor("No Squeeze"));

def two_hoursPrice;
def two_hoursATR;
def two_hoursSDev;
def two_hoursDenom;
def two_hoursDenomLo;
def two_hoursDenomHi;
def two_hoursBBSInd;
def two_hoursBBSIndLo;
def two_hoursBBSIndHi;
def two_hoursSqueeze;
def two_hoursPreSqueeze;
def two_hoursExtraSqueeze;
def two_hoursMinAggregationPeriod;
if GetAggregationPeriod() <= AggregationPeriod.TWO_HOURS {
    two_hoursPrice = close(period = "2 Hours");
    two_hoursATR = Average(TrueRange(high (period = "2 Hours"), close(period = "2 Hours"), low(period = "2 Hours")), length);
    two_hoursSDev = StDev(two_hoursPrice, length);
    two_hoursDenom = (nk * two_hoursATR);
    two_hoursDenomLo = (nkLo * two_hoursATR);
    two_hoursDenomHi = (nkHi * two_hoursATR);
    two_hoursBBSInd = If (two_hoursDenom <> 0, ((nBB * two_hoursSDev) / two_hoursDenom), 0);
    two_hoursBBSIndLo = If (two_hoursDenomLo <> 0, ((nBB * two_hoursSDev) / two_hoursDenomLo), 0);
    two_hoursBBSIndHi = If (two_hoursDenomHi <> 0, ((nBB * two_hoursSDev) / two_hoursDenomHi), 0);
    two_hoursSqueeze = if two_hoursBBSInd < AlertLine then 1 else 0;
    two_hoursPreSqueeze = if two_hoursBBSIndHi < AlertLine then 1 else 0;
    two_hoursExtraSqueeze = if two_hoursBBSIndLo < AlertLine then 1 else 0;
    two_hoursMinAggregationPeriod = 1;
}
else {
    two_hoursPrice = 0;
    two_hoursATR = 0;
    two_hoursSDev = 0;
    two_hoursDenom = 0;
    two_hoursDenomLo = 0;
    two_hoursDenomHi = 0;
    two_hoursBBSInd = 0;
    two_hoursBBSIndLo = 0;
    two_hoursBBSIndHi = 0;
    two_hoursSqueeze = 0;
    two_hoursPreSqueeze = 0;
    two_hoursExtraSqueeze = 0;
    two_hoursMinAggregationPeriod = 0;
}
AddLabel(TwoHourLabel and two_hoursMinAggregationPeriod, "2h", if two_hoursPreSqueeze then GlobalColor("PreSqueeze") else if two_hoursSqueeze then GlobalColor("Squeeze" ) else if two_hoursExtraSqueeze then GlobalColor("ExtraSqueeze") else GlobalColor("NO Squeeze"));

def hourPrice;
def hourATR;
def hourSDev;
def hourDenom;
def hourDenomLo;
def hourDenomHi;
def hourBBSInd;
def hourBBSIndLo;
def hourBBSIndHi;
def hourSqueeze;
def hourPreSqueeze;
def hourExtraSqueeze;
def HourMinAggregationPeriod;
if GetAggregationPeriod() <= AggregationPeriod.HOUR {
    hourPrice = close(period = "1 Hour");
    hourATR = Average(TrueRange(high (period = "1 Hour"), close(period = "1 Hour"), low(period = "1 Hour")), length);
    hourSDev = StDev(hourPrice, length);
    hourDenom = (nk * hourATR);
    hourDenomLo = (nkLo * hourATR);
    hourDenomHi = (nkHi * hourATR);
    hourBBSInd = If (hourDenom <> 0, ((nBB * hourSDev) / hourDenom), 0);
    hourBBSIndLo = If (hourDenomLo <> 0, ((nBB * hourSDev) / hourDenomLo), 0);
    hourBBSIndHi = If (hourDenomHi <> 0, ((nBB * hourSDev) / hourDenomHi), 0);
    hourSqueeze = if hourBBSInd < AlertLine then 1 else 0;
    hourPreSqueeze = if hourBBSIndHi < AlertLine then 1 else 0;
    hourExtraSqueeze = if hourBBSIndLo < AlertLine then 1 else 0;
    HourMinAggregationPeriod = 1;
}
else {
    hourPrice = 0;
    hourATR = 0;
    hourSDev = 0;
    hourDenom = 0;
    hourDenomLo = 0;
    hourDenomHi = 0;
    hourBBSInd = 0;
    hourBBSIndLo = 0;
    hourBBSIndHi = 0;
    hourSqueeze = 0;
    hourPreSqueeze = 0;
    hourExtraSqueeze = 0;
    HourMinAggregationPeriod = 0;
}
AddLabel(HourLabel and HourMinAggregationPeriod, "1h", if hourPreSqueeze then GlobalColor("PreSqueeze") else if hourSqueeze then GlobalColor("Squeeze" ) else if hourExtraSqueeze then GlobalColor("ExtraSqueeze") else GlobalColor("NO Squeeze"));

def Thirty_MinPrice;
def Thirty_MinATR;
def Thirty_MinSDev;
def Thirty_MinDenom;
def Thirty_MinDenomLo;
def Thirty_MinDenomHi;
def Thirty_MinBBSInd;
def Thirty_MinBBSIndLo;
def Thirty_MinBBSIndHi;
def Thirty_MinSqueeze;
def Thirty_MinPreSqueeze;
def Thirty_MinExtraSqueeze;
def Thirty_MinAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.THIRTY_MIN {
    Thirty_MinPrice = close(period = "30 Min");
    Thirty_MinATR = Average(TrueRange(high (period = "30 Min"), close(period = "30 Min"), low(period = "30 Min")), length);
    Thirty_MinSDev = StDev(Thirty_MinPrice, length);
    Thirty_MinDenom = (nk * Thirty_MinATR);
    Thirty_MinDenomLo = (nkLo * Thirty_MinATR);
    Thirty_MinDenomHi = (nkHi * Thirty_MinATR);
    Thirty_MinBBSInd = If (Thirty_MinDenom <> 0, ((nBB * Thirty_MinSDev) / Thirty_MinDenom), 0);
    Thirty_MinBBSIndLo = If (Thirty_MinDenomLo <> 0, ((nBB * Thirty_MinSDev) / Thirty_MinDenomLo), 0);
    Thirty_MinBBSIndHi = If (Thirty_MinDenomHi <> 0, ((nBB * Thirty_MinSDev) / Thirty_MinDenomHi), 0);
    Thirty_MinSqueeze = if Thirty_MinBBSInd < AlertLine then 1 else 0;
    Thirty_MinPreSqueeze = if Thirty_MinBBSIndHi < AlertLine then 1 else 0;
    Thirty_MinExtraSqueeze = if Thirty_MinBBSIndLo < AlertLine then 1 else 0;
    Thirty_MinAggregationPeriod = 1;
}
else {
    Thirty_MinPrice = 0;
    Thirty_MinATR = 0;
    Thirty_MinSDev = 0;
    Thirty_MinDenom = 0;
    Thirty_MinDenomLo = 0;
    Thirty_MinDenomHi = 0;
    Thirty_MinBBSInd = 0;
    Thirty_MinBBSIndLo = 0;
    Thirty_MinBBSIndHi = 0;
    Thirty_MinSqueeze = 0;
    Thirty_MinPreSqueeze = 0;
    Thirty_MinExtraSqueeze = 0;
    Thirty_MinAggregationPeriod = 0;
}
AddLabel(ThirtyMinLabel and Thirty_MinAggregationPeriod, "30m", if Thirty_MinSqueeze then GlobalColor("Squeeze") else if Thirty_MinExtraSqueeze then GlobalColor("ExtraSqueeze") else if Thirty_MinPreSqueeze then GlobalColor("PreSqueeze") else GlobalColor("No Squeeze"));

def Twenty_MinPrice;
def Twenty_MinATR;
def Twenty_MinSDev;
def Twenty_MinDenom;
def Twenty_MinDenomLo;
def Twenty_MinDenomHi;
def Twenty_MinBBSInd;
def Twenty_MinBBSIndLo;
def Twenty_MinBBSIndHi;
def Twenty_MinSqueeze;
def Twenty_MinPreSqueeze;
def Twenty_MinExtraSqueeze;
def Twenty_MinAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.TWENTY_MIN {
    Twenty_MinPrice = close(period = "20 Min");
    Twenty_MinATR = Average(TrueRange(high (period = "20 Min"), close(period = "20 Min"), low(period = "20 Min")), length);
    Twenty_MinSDev = StDev(Twenty_MinPrice, length);
    Twenty_MinDenom = (nk * Twenty_MinATR);
    Twenty_MinDenomLo = (nkLo * Twenty_MinATR);
    Twenty_MinDenomHi = (nkHi * Twenty_MinATR);
    Twenty_MinBBSInd = If (Twenty_MinDenom <> 0, ((nBB * Twenty_MinSDev) / Twenty_MinDenom), 0);
    Twenty_MinBBSIndLo = If (Twenty_MinDenomLo <> 0, ((nBB * Twenty_MinSDev) / Twenty_MinDenomLo), 0);
    Twenty_MinBBSIndHi = If (Twenty_MinDenomHi <> 0, ((nBB * Twenty_MinSDev) / Twenty_MinDenomHi), 0);
    Twenty_MinSqueeze = if Twenty_MinBBSInd < AlertLine then 1 else 0;
    Twenty_MinPreSqueeze = if Twenty_MinBBSIndHi < AlertLine then 1 else 0;
    Twenty_MinExtraSqueeze = if Twenty_MinBBSIndLo < AlertLine then 1 else 0;
    Twenty_MinAggregationPeriod = 1;
}
else {
    Twenty_MinPrice = 0;
    Twenty_MinATR = 0;
    Twenty_MinSDev = 0;
    Twenty_MinDenom = 0;
    Twenty_MinDenomLo = 0;
    Twenty_MinDenomHi = 0;
    Twenty_MinBBSInd = 0;
    Twenty_MinBBSIndLo = 0;
    Twenty_MinBBSIndHi = 0;
    Twenty_MinSqueeze = 0;
    Twenty_MinPreSqueeze = 0;
    Twenty_MinExtraSqueeze = 0;
    Twenty_MinAggregationPeriod = 0;
}
AddLabel(TwentyMinLabel and Twenty_MinAggregationPeriod, "20m", if Twenty_MinSqueeze then GlobalColor("Squeeze") else if Twenty_MinExtraSqueeze then GlobalColor("ExtraSqueeze") else if Twenty_MinPreSqueeze then GlobalColor("PreSqueeze") else GlobalColor("No Squeeze"));


def Fifteen_MinPrice;
def Fifteen_MinATR;
def Fifteen_MinSDev;
def Fifteen_MinDenom;
def Fifteen_MinDenomLo;
def Fifteen_MinDenomHi;
def Fifteen_MinBBSInd;
def Fifteen_MinBBSIndLo;
def Fifteen_MinBBSIndHi;
def Fifteen_MinSqueeze;
def Fifteen_MinPreSqueeze;
def Fifteen_MinExtraSqueeze;
def Fifteen_MinAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN {
    Fifteen_MinPrice = close(period = "15 Min");
    Fifteen_MinATR = Average(TrueRange(high (period = "15 Min"), close(period = "15 Min"), low(period = "15 Min")), length);
    Fifteen_MinSDev = StDev(Fifteen_MinPrice, length);
    Fifteen_MinDenom = (nk * Fifteen_MinATR);
    Fifteen_MinDenomLo = (nkLo * Fifteen_MinATR);
    Fifteen_MinDenomHi = (nkHi * Fifteen_MinATR);
    Fifteen_MinBBSInd = If (Fifteen_MinDenom <> 0, ((nBB * Fifteen_MinSDev) / Fifteen_MinDenom), 0);
    Fifteen_MinBBSIndLo = If (Fifteen_MinDenomLo <> 0, ((nBB * Fifteen_MinSDev) / Fifteen_MinDenomLo), 0);
    Fifteen_MinBBSIndHi = If (Fifteen_MinDenomHi <> 0, ((nBB * Fifteen_MinSDev) / Fifteen_MinDenomHi), 0);
    Fifteen_MinSqueeze = if Fifteen_MinBBSInd < AlertLine then 1 else 0;
    Fifteen_MinPreSqueeze = if Fifteen_MinBBSIndHi < AlertLine then 1 else 0;
    Fifteen_MinExtraSqueeze = if Fifteen_MinBBSIndLo < AlertLine then 1 else 0;
    Fifteen_MinAggregationPeriod = 1;
}
else {
    Fifteen_MinPrice = 0;
    Fifteen_MinATR = 0;
    Fifteen_MinSDev = 0;
    Fifteen_MinDenom = 0;
    Fifteen_MinDenomLo = 0;
    Fifteen_MinDenomHi = 0;
    Fifteen_MinBBSInd = 0;
    Fifteen_MinBBSIndLo = 0;
    Fifteen_MinBBSIndHi = 0;
    Fifteen_MinSqueeze = 0;
    Fifteen_MinPreSqueeze = 0;
    Fifteen_MinExtraSqueeze = 0;
    Fifteen_MinAggregationPeriod = 0;
}
AddLabel(FifteenMinLabel and Fifteen_MinAggregationPeriod, "15m", if Fifteen_MinSqueeze then GlobalColor("Squeeze") else if Fifteen_MinExtraSqueeze then GlobalColor("ExtraSqueeze") else if Fifteen_MinPreSqueeze then GlobalColor("PreSqueeze") else GlobalColor("No Squeeze"));

def ten_minPrice;
def ten_minATR;
def ten_minSDev;
def ten_minDenom;
def ten_minDenomLo;
def ten_minDenomHi;
def ten_minBBSInd;
def ten_minBBSIndLo;
def ten_minBBSIndHi;
def ten_minSqueeze;
def ten_minPreSqueeze;
def ten_minExtraSqueeze;
def ten_minAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.TEN_MIN {
    ten_minPrice = close(period = "10 Min");
    ten_minATR = Average(TrueRange(high (period = "10 Min"), close(period = "10 Min"), low(period = "10 Min")), length);
    ten_minSDev = StDev(ten_minPrice, length);
    ten_minDenom = (nk * ten_minATR);
    ten_minDenomLo = (nkLo * ten_minATR);
    ten_minDenomHi = (nkHi * ten_minATR);
    ten_minBBSInd = If (ten_minDenom <> 0, ((nBB * ten_minSDev) / ten_minDenom), 0);
    ten_minBBSIndLo = If (ten_minDenomLo <> 0, ((nBB * ten_minSDev) / ten_minDenomLo), 0);
    ten_minBBSIndHi = If (ten_minDenomHi <> 0, ((nBB * ten_minSDev) / ten_minDenomHi), 0);
    ten_minSqueeze = if ten_minBBSInd < AlertLine then 1 else 0;
    ten_minPreSqueeze = if ten_minBBSIndHi < AlertLine then 1 else 0;
    ten_minExtraSqueeze = if ten_minBBSIndLo < AlertLine then 1 else 0;
    ten_minAggregationPeriod = 1;
}
else {
    ten_minPrice = 0;
    ten_minATR = 0;
    ten_minSDev = 0;
    ten_minDenom = 0;
    ten_minDenomLo = 0;
    ten_minDenomHi = 0;
    ten_minBBSInd = 0;
    ten_minBBSIndLo = 0;
    ten_minBBSIndHi = 0;
    ten_minSqueeze = 0;
    ten_minPreSqueeze = 0;
    ten_minExtraSqueeze = 0;
    ten_minAggregationPeriod = 0;
}
AddLabel(TenMinLabel and ten_minAggregationPeriod, "10m", if ten_minSqueeze then GlobalColor("Squeeze") else if ten_minExtraSqueeze then GlobalColor("ExtraSqueeze") else if ten_minPreSqueeze then GlobalColor("PreSqueeze") else GlobalColor("No Squeeze"));


def five_minPrice;
def five_minATR;
def five_minSDev;
def five_minDenom;
def five_minDenomLo;
def five_minDenomHi;
def five_minBBSInd;
def five_minBBSIndLo;
def five_minBBSIndHi;
def five_minSqueeze;
def five_minPreSqueeze;
def five_minExtraSqueeze;
def five_minAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.FIVE_MIN {
    five_minPrice = close(period = "5 Min");
    five_minATR = Average(TrueRange(high (period = "5 Min"), close(period = "5 Min"), low(period = "5 Min")), length);
    five_minSDev = StDev(five_minPrice, length);
    five_minDenom = (nk * five_minATR);
    five_minDenomLo = (nkLo * five_minATR);
    five_minDenomHi = (nkHi * five_minATR);
    five_minBBSInd = If (five_minDenom <> 0, ((nBB * five_minSDev) / five_minDenom), 0);
    five_minBBSIndLo = If (five_minDenomLo <> 0, ((nBB * five_minSDev) / five_minDenomLo), 0);
    five_minBBSIndHi = If (five_minDenomHi <> 0, ((nBB * five_minSDev) / five_minDenomHi), 0);
    five_minSqueeze = if five_minBBSInd < AlertLine then 1 else 0;
    five_minPreSqueeze = if five_minBBSIndHi < AlertLine then 1 else 0;
    five_minExtraSqueeze = if five_minBBSIndLo < AlertLine then 1 else 0;
    five_minAggregationPeriod = 1;
}
else {
    five_minPrice = 0;
    five_minATR = 0;
    five_minSDev = 0;
    five_minDenom = 0;
    five_minDenomLo = 0;
    five_minDenomHi = 0;
    five_minBBSInd = 0;
    five_minBBSIndLo = 0;
    five_minBBSIndHi = 0;
    five_minSqueeze = 0;
    five_minPreSqueeze = 0;
    five_minExtraSqueeze = 0;
    five_minAggregationPeriod = 0;
}
AddLabel(FiveMinLabel and five_minAggregationPeriod, "5m", if five_minSqueeze then GlobalColor("Squeeze") else if five_minExtraSqueeze then GlobalColor("ExtraSqueeze") else if five_minPreSqueeze then GlobalColor("PreSqueeze") else GlobalColor("No Squeeze"));


def four_minPrice;
def four_minATR;
def four_minSDev;
def four_minDenom;
def four_minDenomLo;
def four_minDenomHi;
def four_minBBSInd;
def four_minBBSIndLo;
def four_minBBSIndHi;
def four_minSqueeze;
def four_minPreSqueeze;
def four_minExtraSqueeze;
def four_minAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.FOUR_MIN {
    four_minPrice = close(period = "4 Min");
    four_minATR = Average(TrueRange(high (period = "4 Min"), close(period = "4 Min"), low(period = "4 Min")), length);
    four_minSDev = StDev(four_minPrice, length);
    four_minDenom = (nk * four_minATR);
    four_minDenomLo = (nkLo * four_minATR);
    four_minDenomHi = (nkHi * four_minATR);
    four_minBBSInd = If (four_minDenom <> 0, ((nBB * four_minSDev) / four_minDenom), 0);
    four_minBBSIndLo = If (four_minDenomLo <> 0, ((nBB * four_minSDev) / four_minDenomLo), 0);
    four_minBBSIndHi = If (four_minDenomHi <> 0, ((nBB * four_minSDev) / four_minDenomHi), 0);
    four_minSqueeze = if four_minBBSInd < AlertLine then 1 else 0;
    four_minPreSqueeze = if four_minBBSIndHi < AlertLine then 1 else 0;
    four_minExtraSqueeze = if four_minBBSIndLo < AlertLine then 1 else 0;
    four_minAggregationPeriod = 1;
}
else {
    four_minPrice = 0;
    four_minATR = 0;
    four_minSDev = 0;
    four_minDenom = 0;
    four_minDenomLo = 0;
    four_minDenomHi = 0;
    four_minBBSInd = 0;
    four_minBBSIndLo = 0;
    four_minBBSIndHi = 0;
    four_minSqueeze = 0;
    four_minPreSqueeze = 0;
    four_minExtraSqueeze = 0;
    four_minAggregationPeriod = 0;
}
AddLabel(FourMinLabel and four_minAggregationPeriod, "4m", if four_minSqueeze then GlobalColor("Squeeze") else if four_minExtraSqueeze then GlobalColor("ExtraSqueeze") else if four_minPreSqueeze then GlobalColor("PreSqueeze") else GlobalColor("No Squeeze"));


def three_minPrice;
def three_minATR;
def three_minSDev;
def three_minDenom;
def three_minDenomLo;
def three_minDenomHi;
def three_minBBSInd;
def three_minBBSIndLo;
def three_minBBSIndHi;
def three_minSqueeze;
def three_minPreSqueeze;
def three_minExtraSqueeze;
def three_minAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.THREE_MIN {
    three_minPrice = close(period = "3 Min");
    three_minATR = Average(TrueRange(high (period = "3 Min"), close(period = "3 Min"), low(period = "3 Min")), length);
    three_minSDev = StDev(three_minPrice, length);
    three_minDenom = (nk * three_minATR);
    three_minDenomLo = (nkLo * three_minATR);
    three_minDenomHi = (nkHi * three_minATR);
    three_minBBSInd = If (three_minDenom <> 0, ((nBB * three_minSDev) / three_minDenom), 0);
    three_minBBSIndLo = If (three_minDenomLo <> 0, ((nBB * three_minSDev) / three_minDenomLo), 0);
    three_minBBSIndHi = If (three_minDenomHi <> 0, ((nBB * three_minSDev) / three_minDenomHi), 0);
    three_minSqueeze = if three_minBBSInd < AlertLine then 1 else 0;
    three_minPreSqueeze = if three_minBBSIndHi < AlertLine then 1 else 0;
    three_minExtraSqueeze = if three_minBBSIndLo < AlertLine then 1 else 0;
    three_minAggregationPeriod = 1;
}
else {
    three_minPrice = 0;
    three_minATR = 0;
    three_minSDev = 0;
    three_minDenom = 0;
    three_minDenomLo = 0;
    three_minDenomHi = 0;
    three_minBBSInd = 0;
    three_minBBSIndLo = 0;
    three_minBBSIndHi = 0;
    three_minSqueeze = 0;
    three_minPreSqueeze = 0;
    three_minExtraSqueeze = 0;
    three_minAggregationPeriod = 0;
}
AddLabel(ThreeMinLabel and three_minAggregationPeriod, "3m", if three_minSqueeze then GlobalColor("Squeeze") else if three_minExtraSqueeze then GlobalColor("ExtraSqueeze") else if three_minPreSqueeze then GlobalColor("PreSqueeze") else GlobalColor("No Squeeze"));


def two_minPrice;
def two_minATR;
def two_minSDev;
def two_minDenom;
def two_minDenomLo;
def two_minDenomHi;
def two_minBBSInd;
def two_minBBSIndLo;
def two_minBBSIndHi;
def two_minSqueeze;
def two_minPreSqueeze;
def two_minExtraSqueeze;
def two_minAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.TWO_MIN {
    two_minPrice = close(period = "2 Min");
    two_minATR = Average(TrueRange(high (period = "2 Min"), close(period = "2 Min"), low(period = "2 Min")), length);
    two_minSDev = StDev(two_minPrice, length);
    two_minDenom = (nk * two_minATR);
    two_minDenomLo = (nkLo * two_minATR);
    two_minDenomHi = (nkHi * two_minATR);
    two_minBBSInd = If (two_minDenom <> 0, ((nBB * two_minSDev) / two_minDenom), 0);
    two_minBBSIndLo = If (two_minDenomLo <> 0, ((nBB * two_minSDev) / two_minDenomLo), 0);
    two_minBBSIndHi = If (two_minDenomHi <> 0, ((nBB * two_minSDev) / two_minDenomHi), 0);
    two_minSqueeze = if two_minBBSInd < AlertLine then 1 else 0;
    two_minPreSqueeze = if two_minBBSIndHi < AlertLine then 1 else 0;
    two_minExtraSqueeze = if two_minBBSIndLo < AlertLine then 1 else 0;
    two_minAggregationPeriod = 1;
}
else {
    two_minPrice = 0;
    two_minATR = 0;
    two_minSDev = 0;
    two_minDenom = 0;
    two_minDenomLo = 0;
    two_minDenomHi = 0;
    two_minBBSInd = 0;
    two_minBBSIndLo = 0;
    two_minBBSIndHi = 0;
    two_minSqueeze = 0;
    two_minPreSqueeze = 0;
    two_minExtraSqueeze = 0;
    two_minAggregationPeriod = 0;
}
AddLabel(TwoMinLabel and two_minAggregationPeriod, "2m", if two_minSqueeze then GlobalColor("Squeeze") else if two_minExtraSqueeze then GlobalColor("ExtraSqueeze") else if two_minPreSqueeze then GlobalColor("PreSqueeze") else GlobalColor("No Squeeze"));


def one_minPrice;
def one_minATR;
def one_minSDev;
def one_minDenom;
def one_minDenomLo;
def one_minDenomHi;
def one_minBBSInd;
def one_minBBSIndLo;
def one_minBBSIndHi;
def one_minSqueeze;
def one_minPreSqueeze;
def one_minExtraSqueeze;
def one_minAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.MIN {
    one_minPrice = close(period = "1 Min");
    one_minATR = Average(TrueRange(high (period = "1 Min"), close(period = "1 Min"), low(period = "1 Min")), length);
    one_minSDev = StDev(one_minPrice, length);
    one_minDenom = (nk * one_minATR);
    one_minDenomLo = (nkLo * one_minATR);
    one_minDenomHi = (nkHi * one_minATR);
    one_minBBSInd = If (one_minDenom <> 0, ((nBB * one_minSDev) / one_minDenom), 0);
    one_minBBSIndLo = If (one_minDenomLo <> 0, ((nBB * one_minSDev) / one_minDenomLo), 0);
    one_minBBSIndHi = If (one_minDenomHi <> 0, ((nBB * one_minSDev) / one_minDenomHi), 0);
    one_minSqueeze = if one_minBBSInd < AlertLine then 1 else 0;
    one_minPreSqueeze = if one_minBBSIndHi < AlertLine then 1 else 0;
    one_minExtraSqueeze = if one_minBBSIndLo < AlertLine then 1 else 0;
    one_minAggregationPeriod = 1;
}
else {
    one_minPrice = 0;
    one_minATR = 0;
    one_minSDev = 0;
    one_minDenom = 0;
    one_minDenomLo = 0;
    one_minDenomHi = 0;
    one_minBBSInd = 0;
    one_minBBSIndLo = 0;
    one_minBBSIndHi = 0;
    one_minSqueeze = 0;
    one_minPreSqueeze = 0;
    one_minExtraSqueeze = 0;
    one_minAggregationPeriod = 0;
}
AddLabel(OneMinLabel and one_minAggregationPeriod, "1m", if one_minSqueeze then GlobalColor("Squeeze") else if one_minExtraSqueeze then GlobalColor("ExtraSqueeze") else if one_minPreSqueeze then GlobalColor("PreSqueeze") else GlobalColor("No Squeeze"));
I'm not getting any yellow labels for the Extra-Squeeze, on any timeframe. They are always Red, the same as the Original squeeze. The Original squeeze and Pre-Squeeze label's do change their colors correctly on all timeframes. Can you tell me what I'm doing wrong?
 
Last edited:
I'm not getting any yellow labels for the Extra-Squeeze, on any timeframe. They are always Red, the same as the Original squeeze. The Original squeeze and Pre-Squeeze label's do change their colors correctly on all timeframes. Can you tell me what I'm doing wrong?
Fixed it. Make sure Add Label is hierarchically ordered (1) Extra Squeeze (2) mid (red) squeeze (3) low squeeze.
 
Last edited:
@caseyjbrett Can you explain a bit for a newbie on how to use this study and on which timeframe it works best?
SuryaKiranC’s recommendation is ideal. To be honest, I don’t use these labels or the squeeze as a daily trading indicator. But I used to and I know other’s that have great success with only trading squeeze setups. From my personal experience, squeezes under 1hr are pretty useless. As a general rule of thumb, finding squeezes on multiple time frames will certainly help. Time frame continuity with the squeezes. Example: squeeze on the weekly, 4day, daily, and hourly. How you trade the squeeze is totally up to you. I support what SuryaKiranC said about looking up videos on YouTube. There’s already a ton of info out there. You just need to figure out what works best for you and your trading style!
 
@caseyjbrett Hi Casey have you shared the 10x and the MTF stacked EMAs labels? If not would you please be so kind to. Thank you!
Hey I'm sorry for the delayed reply. I completely forgot to get back to you! I'd be happy to share. But remind me again what the 10x are? If memory serves, that's for trend? See stacked EMA script attached.
Code:
#MTF STACKED EMA'S LABELS
#BY: CASEY BRETT


DefineGlobalColor("StackedPositive", color.green);
DefineGlobalColor("StackedNegative", color.red);
DefineGlobalColor("Warning", color.yellow);
DefineGlobalColor("Neutral", color.gray);

# MONTH STACKED EMA'S LABEL

def EMA89Month;
def EMA55Month;
def EMA34Month;
def EMA21Month;
def EMA8Month;
def SPMonth;
def SNMonth;
def SPWMonth;
def SNWMonth;
def monthAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.MONTH {
    
    EMA89Month = expAverage(close(period="MONTH"),89);
    EMA55Month = expAverage(close(period="MONTH"),55);
    EMA34Month = expAverage(close(period="MONTH"),34);
    EMA21Month = expAverage(close(period="MONTH"),21);
    EMA8Month = expAverage(close(period="MONTH"),8);
    SPMonth = ema8Month > ema21Month and EMA21Month > EMA34Month and EMA34Month > EMA55Month and EMA55Month > EMA89Month;
    SNMonth = ema8Month < ema21Month and ema21Month < EMA34Month and EMA34Month < EMA55Month and EMA55Month < EMA89Month;
    SPWMonth = ema8Month < ema21Month and EMA34Month > EMA55Month and EMA55Month > EMA89Month;
    SNWMonth = ema8Month > ema21Month  and EMA34Month < EMA55Month and EMA55Month < EMA89Month;
    monthAggregationPeriod = 1;
}
else {
    EMA89Month = 0;
    EMA55Month = 0;
    EMA34Month = 0;
    EMA21Month =0;
    EMA8Month =0;
    SPMonth = 0;
    SNMonth = 0;
    SPWMonth = 0;
    SNWMonth = 0;
    monthAggregationPeriod =0;
}

AddLabel(monthAggregationPeriod, "M: EMA's", if SPMonth then GlobalColor("StackedPositive") else if SNMonth then GlobalColor("StackedNegative") else if (SPWMonth or SNWMonth) then GlobalColor("Warning") else GlobalColor("Neutral"));

# WEEK STACKED EMA'S LABEL

def EMA89Week;
def EMA55Week;
def EMA34Week;
def EMA21Week;
def EMA8Week;
def SPWeek;
def SNWeek;
def SPWWeek;
def SNWWeek;
def WeekAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.Week {
    
    EMA89Week = expAverage(close(period="Week"),89);
    EMA55Week = expAverage(close(period="Week"),55);
    EMA34Week = expAverage(close(period="Week"),34);
    EMA21Week = expAverage(close(period="Week"),21);
    EMA8Week = expAverage(close(period="Week"),8);
    SPWeek = ema8Week > ema21Week and EMA21Week > EMA34Week and EMA34Week > EMA55Week and EMA55Week > EMA89Week;
    SNWeek = ema8Week < ema21Week and ema21Week < EMA34Week and EMA34Week < EMA55Week and EMA55Week < EMA89Week;
    SPWWeek = ema8Week < ema21Week and EMA34Week > EMA55Week and EMA55Week > EMA89Week;
    SNWWeek = ema8Week > ema21Week  and EMA34Week < EMA55Week and EMA55Week < EMA89Week;
    WeekAggregationPeriod = 1;
}
else {
    EMA89Week = 0;
    EMA55Week = 0;
    EMA34Week = 0;
    EMA21Week =0;
    EMA8Week =0;
    SPWeek = 0;
    SNWeek = 0;
    SPWWeek = 0;
    SNWWeek = 0;
    WeekAggregationPeriod =0;
}

AddLabel(WeekAggregationPeriod, "W: EMA's", if SPWeek then GlobalColor("StackedPositive") else if SNWeek then GlobalColor("StackedNegative") else if (SPWWeek or SNWWeek) then GlobalColor("Warning") else GlobalColor("Neutral"));

# 4-DAY STACKED EMA'S LABEL

def EMA89FOUR_DAYS;
def EMA55FOUR_DAYS;
def EMA34FOUR_DAYS;
def EMA21FOUR_DAYS;
def EMA8FOUR_DAYS;
def SPFOUR_DAYS;
def SNFOUR_DAYS;
def SPWFOUR_DAYS;
def SNWFOUR_DAYS;
def FOUR_DAYSAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.FOUR_DAYS {
    
    EMA89FOUR_DAYS = expAverage(close(period="4 DAYS"),89);
    EMA55FOUR_DAYS = expAverage(close(period="4 DAYS"),55);
    EMA34FOUR_DAYS = expAverage(close(period="4 DAYS"),34);
    EMA21FOUR_DAYS = expAverage(close(period="4 DAYS"),21);
    EMA8FOUR_DAYS = expAverage(close(period="4 DAYS"),8);
    SPFOUR_DAYS = ema8FOUR_DAYS > ema21FOUR_DAYS and EMA21FOUR_DAYS > EMA34FOUR_DAYS and EMA34FOUR_DAYS > EMA55FOUR_DAYS and EMA55FOUR_DAYS > EMA89FOUR_DAYS;
    SNFOUR_DAYS = ema8FOUR_DAYS < ema21FOUR_DAYS and ema21FOUR_DAYS < EMA34FOUR_DAYS and EMA34FOUR_DAYS < EMA55FOUR_DAYS and EMA55FOUR_DAYS < EMA89FOUR_DAYS;
    SPWFOUR_DAYS = ema8FOUR_DAYS < ema21FOUR_DAYS and EMA34FOUR_DAYS > EMA55FOUR_DAYS and EMA55FOUR_DAYS > EMA89FOUR_DAYS;
    SNWFOUR_DAYS = ema8FOUR_DAYS > ema21FOUR_DAYS  and EMA34FOUR_DAYS < EMA55FOUR_DAYS and EMA55FOUR_DAYS < EMA89FOUR_DAYS;
    FOUR_DAYSAggregationPeriod = 1;
}
else {
    EMA89FOUR_DAYS = 0;
    EMA55FOUR_DAYS = 0;
    EMA34FOUR_DAYS = 0;
    EMA21FOUR_DAYS =0;
    EMA8FOUR_DAYS =0;
    SPFOUR_DAYS = 0;
    SNFOUR_DAYS = 0;
    SPWFOUR_DAYS = 0;
    SNWFOUR_DAYS = 0;
    FOUR_DAYSAggregationPeriod =0;
}

AddLabel(FOUR_DAYSAggregationPeriod, "4D: EMA's", if SPFOUR_DAYS then GlobalColor("StackedPositive") else if SNFOUR_DAYS then GlobalColor("StackedNegative") else if (SPWFOUR_DAYS or SNWFOUR_DAYS) then GlobalColor("Warning") else GlobalColor("Neutral"));

# 3-DAYS STACKED EMA'S LABEL

def EMA89THREE_DAYS;
def EMA55THREE_DAYS;
def EMA34THREE_DAYS;
def EMA21THREE_DAYS;
def EMA8THREE_DAYS;
def SPTHREE_DAYS;
def SNTHREE_DAYS;
def SPWTHREE_DAYS;
def SNWTHREE_DAYS;
def THREE_DAYSAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.THREE_DAYS {
    
    EMA89THREE_DAYS = expAverage(close(period="3 DAYS"),89);
    EMA55THREE_DAYS = expAverage(close(period="3 DAYS"),55);
    EMA34THREE_DAYS = expAverage(close(period="3 DAYS"),34);
    EMA21THREE_DAYS = expAverage(close(period="3 DAYS"),21);
    EMA8THREE_DAYS = expAverage(close(period="3 DAYS"),8);
    SPTHREE_DAYS = ema8THREE_DAYS > ema21THREE_DAYS and EMA21THREE_DAYS > EMA34THREE_DAYS and EMA34THREE_DAYS > EMA55THREE_DAYS and EMA55THREE_DAYS > EMA89THREE_DAYS;
    SNTHREE_DAYS = ema8THREE_DAYS < ema21THREE_DAYS and ema21THREE_DAYS < EMA34THREE_DAYS and EMA34THREE_DAYS < EMA55THREE_DAYS and EMA55THREE_DAYS < EMA89THREE_DAYS;
    SPWTHREE_DAYS = ema8THREE_DAYS < ema21THREE_DAYS and EMA34THREE_DAYS > EMA55THREE_DAYS and EMA55THREE_DAYS > EMA89THREE_DAYS;
    SNWTHREE_DAYS = ema8THREE_DAYS > ema21THREE_DAYS  and EMA34THREE_DAYS < EMA55THREE_DAYS and EMA55THREE_DAYS < EMA89THREE_DAYS;
    THREE_DAYSAggregationPeriod = 1;
}
else {
    EMA89THREE_DAYS = 0;
    EMA55THREE_DAYS = 0;
    EMA34THREE_DAYS = 0;
    EMA21THREE_DAYS =0;
    EMA8THREE_DAYS =0;
    SPTHREE_DAYS = 0;
    SNTHREE_DAYS = 0;
    SPWTHREE_DAYS = 0;
    SNWTHREE_DAYS = 0;
    THREE_DAYSAggregationPeriod =0;
}

AddLabel(THREE_DAYSAggregationPeriod, "3D: EMA's", if SPTHREE_DAYS then GlobalColor("StackedPositive") else if SNTHREE_DAYS then GlobalColor("StackedNegative") else if (SPWTHREE_DAYS or SNWTHREE_DAYS) then GlobalColor("Warning") else GlobalColor("Neutral"));

# 2-DAYS STACKED EMA'S LABEL

def EMA89TWO_DAYS;
def EMA55TWO_DAYS;
def EMA34TWO_DAYS;
def EMA21TWO_DAYS;
def EMA8TWO_DAYS;
def SPTWO_DAYS;
def SNTWO_DAYS;
def SPWTWO_DAYS;
def SNWTWO_DAYS;
def TWO_DAYSAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.TWO_DAYS {
    
    EMA89TWO_DAYS = expAverage(close(period="2 DAYS"),89);
    EMA55TWO_DAYS = expAverage(close(period="2 DAYS"),55);
    EMA34TWO_DAYS = expAverage(close(period="2 DAYS"),34);
    EMA21TWO_DAYS = expAverage(close(period="2 DAYS"),21);
    EMA8TWO_DAYS = expAverage(close(period="2 DAYS"),8);
    SPTWO_DAYS = ema8TWO_DAYS > ema21TWO_DAYS and EMA21TWO_DAYS > EMA34TWO_DAYS and EMA34TWO_DAYS > EMA55TWO_DAYS and EMA55TWO_DAYS > EMA89TWO_DAYS;
    SNTWO_DAYS = ema8TWO_DAYS < ema21TWO_DAYS and ema21TWO_DAYS < EMA34TWO_DAYS and EMA34TWO_DAYS < EMA55TWO_DAYS and EMA55TWO_DAYS < EMA89TWO_DAYS;
    SPWTWO_DAYS = ema8TWO_DAYS < ema21TWO_DAYS and EMA34TWO_DAYS > EMA55TWO_DAYS and EMA55TWO_DAYS > EMA89TWO_DAYS;
    SNWTWO_DAYS = ema8TWO_DAYS > ema21TWO_DAYS  and EMA34TWO_DAYS < EMA55TWO_DAYS and EMA55TWO_DAYS < EMA89TWO_DAYS;
    TWO_DAYSAggregationPeriod = 1;
}
else {
    EMA89TWO_DAYS = 0;
    EMA55TWO_DAYS = 0;
    EMA34TWO_DAYS = 0;
    EMA21TWO_DAYS =0;
    EMA8TWO_DAYS =0;
    SPTWO_DAYS = 0;
    SNTWO_DAYS = 0;
    SPWTWO_DAYS = 0;
    SNWTWO_DAYS = 0;
    TWO_DAYSAggregationPeriod =0;
}

AddLabel(TWO_DAYSAggregationPeriod, "2D: EMA's", if SPTWO_DAYS then GlobalColor("StackedPositive") else if SNTWO_DAYS then GlobalColor("StackedNegative") else if (SPWTWO_DAYS or SNWTWO_DAYS) then GlobalColor("Warning") else GlobalColor("Neutral"));

# ONE DAY STACKED EMA'S LABEL

def EMA89DAY;
def EMA55DAY;
def EMA34DAY;
def EMA21DAY;
def EMA8DAY;
def SPDAY;
def SNDAY;
def SPWDAY;
def SNWDAY;
def DAYAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.DAY {
    
    EMA89DAY = expAverage(close(period="DAY"),89);
    EMA55DAY = expAverage(close(period="DAY"),55);
    EMA34DAY = expAverage(close(period="DAY"),34);
    EMA21DAY = expAverage(close(period="DAY"),21);
    EMA8DAY = expAverage(close(period="DAY"),8);
    SPDAY = ema8DAY > ema21DAY and EMA21DAY > EMA34DAY and EMA34DAY > EMA55DAY and EMA55DAY > EMA89DAY;
    SNDAY = ema8DAY < ema21DAY and ema21DAY < EMA34DAY and EMA34DAY < EMA55DAY and EMA55DAY < EMA89DAY;
    SPWDAY = ema8DAY < ema21DAY and EMA34DAY > EMA55DAY and EMA55DAY > EMA89DAY;
    SNWDAY = ema8DAY > ema21DAY  and EMA34DAY < EMA55DAY and EMA55DAY < EMA89DAY;
    DAYAggregationPeriod = 1;
}
else {
    EMA89DAY = 0;
    EMA55DAY = 0;
    EMA34DAY = 0;
    EMA21DAY =0;
    EMA8DAY =0;
    SPDAY = 0;
    SNDAY = 0;
    SPWDAY = 0;
    SNWDAY = 0;
    DAYAggregationPeriod =0;
}

AddLabel(DAYAggregationPeriod, "D: EMA's", if SPDAY then GlobalColor("StackedPositive") else if SNDAY then GlobalColor("StackedNegative") else if (SPWDAY or SNWDAY) then GlobalColor("Warning") else GlobalColor("Neutral"));

# 4 HOUR STACKED EMA'S LABEL

def EMA89FOUR_HOURS;
def EMA55FOUR_HOURS;
def EMA34FOUR_HOURS;
def EMA21FOUR_HOURS;
def EMA8FOUR_HOURS;
def SPFOUR_HOURS;
def SNFOUR_HOURS;
def SPWFOUR_HOURS;
def SNWFOUR_HOURS;
def FOUR_HOURSAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.FOUR_HOURS {
    
    EMA89FOUR_HOURS = expAverage(close(period="4 HOURS"),89);
    EMA55FOUR_HOURS = expAverage(close(period="4 HOURS"),55);
    EMA34FOUR_HOURS = expAverage(close(period="4 HOURS"),34);
    EMA21FOUR_HOURS = expAverage(close(period="4 HOURS"),21);
    EMA8FOUR_HOURS = expAverage(close(period="4 HOURS"),8);
    SPFOUR_HOURS = ema8FOUR_HOURS > ema21FOUR_HOURS and EMA21FOUR_HOURS > EMA34FOUR_HOURS and EMA34FOUR_HOURS > EMA55FOUR_HOURS and EMA55FOUR_HOURS > EMA89FOUR_HOURS;
    SNFOUR_HOURS = ema8FOUR_HOURS < ema21FOUR_HOURS and ema21FOUR_HOURS < EMA34FOUR_HOURS and EMA34FOUR_HOURS < EMA55FOUR_HOURS and EMA55FOUR_HOURS < EMA89FOUR_HOURS;
    SPWFOUR_HOURS = ema8FOUR_HOURS < ema21FOUR_HOURS and EMA34FOUR_HOURS > EMA55FOUR_HOURS and EMA55FOUR_HOURS > EMA89FOUR_HOURS;
    SNWFOUR_HOURS = ema8FOUR_HOURS > ema21FOUR_HOURS  and EMA34FOUR_HOURS < EMA55FOUR_HOURS and EMA55FOUR_HOURS < EMA89FOUR_HOURS;
    FOUR_HOURSAggregationPeriod = 1;
}
else {
    EMA89FOUR_HOURS = 0;
    EMA55FOUR_HOURS = 0;
    EMA34FOUR_HOURS = 0;
    EMA21FOUR_HOURS =0;
    EMA8FOUR_HOURS =0;
    SPFOUR_HOURS = 0;
    SNFOUR_HOURS = 0;
    SPWFOUR_HOURS = 0;
    SNWFOUR_HOURS = 0;
    FOUR_HOURSAggregationPeriod =0;
}

AddLabel(FOUR_HOURSAggregationPeriod, "4h: EMA's", if SPFOUR_HOURS then GlobalColor("StackedPositive") else if SNFOUR_HOURS then GlobalColor("StackedNegative") else if (SPWFOUR_HOURS or SNWFOUR_HOURS) then GlobalColor("Warning") else GlobalColor("Neutral"));

# 2 HOUR STACKED EMA'S LABEL

def EMA89TWO_HOURS;
def EMA55TWO_HOURS;
def EMA34TWO_HOURS;
def EMA21TWO_HOURS;
def EMA8TWO_HOURS;
def SPTWO_HOURS;
def SNTWO_HOURS;
def SPWTWO_HOURS;
def SNWTWO_HOURS;
def TWO_HOURSAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.TWO_HOURS {
    
    EMA89TWO_HOURS = expAverage(close(period="2 HOURS"),89);
    EMA55TWO_HOURS = expAverage(close(period="2 HOURS"),55);
    EMA34TWO_HOURS = expAverage(close(period="2 HOURS"),34);
    EMA21TWO_HOURS = expAverage(close(period="2 HOURS"),21);
    EMA8TWO_HOURS = expAverage(close(period="2 HOURS"),8);
    SPTWO_HOURS = ema8TWO_HOURS > ema21TWO_HOURS and EMA21TWO_HOURS > EMA34TWO_HOURS and EMA34TWO_HOURS > EMA55TWO_HOURS and EMA55TWO_HOURS > EMA89TWO_HOURS;
    SNTWO_HOURS = ema8TWO_HOURS < ema21TWO_HOURS and ema21TWO_HOURS < EMA34TWO_HOURS and EMA34TWO_HOURS < EMA55TWO_HOURS and EMA55TWO_HOURS < EMA89TWO_HOURS;
    SPWTWO_HOURS = ema8TWO_HOURS < ema21TWO_HOURS and EMA34TWO_HOURS > EMA55TWO_HOURS and EMA55TWO_HOURS > EMA89TWO_HOURS;
    SNWTWO_HOURS = ema8TWO_HOURS > ema21TWO_HOURS  and EMA34TWO_HOURS < EMA55TWO_HOURS and EMA55TWO_HOURS < EMA89TWO_HOURS;
    TWO_HOURSAggregationPeriod = 1;
}
else {
    EMA89TWO_HOURS = 0;
    EMA55TWO_HOURS = 0;
    EMA34TWO_HOURS = 0;
    EMA21TWO_HOURS =0;
    EMA8TWO_HOURS =0;
    SPTWO_HOURS = 0;
    SNTWO_HOURS = 0;
    SPWTWO_HOURS = 0;
    SNWTWO_HOURS = 0;
    TWO_HOURSAggregationPeriod =0;
}

AddLabel(TWO_HOURSAggregationPeriod, "2h: EMA's", if SPTWO_HOURS then GlobalColor("StackedPositive") else if SNTWO_HOURS then GlobalColor("StackedNegative") else if (SPWTWO_HOURS or SNWTWO_HOURS) then GlobalColor("Warning") else GlobalColor("Neutral"));

# ONE HOUR STACKED EMA'S SCHEDULE

def EMA89HOUR;
def EMA55HOUR;
def EMA34HOUR;
def EMA21HOUR;
def EMA8HOUR;
def SPHOUR;
def SNHOUR;
def SPWHOUR;
def SNWHOUR;
def HOURAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.HOUR {
    
    EMA89HOUR = expAverage(close(period="1 HOUR"),89);
    EMA55HOUR = expAverage(close(period="1 HOUR"),55);
    EMA34HOUR = expAverage(close(period="1 HOUR"),34);
    EMA21HOUR = expAverage(close(period="1 HOUR"),21);
    EMA8HOUR = expAverage(close(period="1 HOUR"),8);
    SPHOUR = ema8HOUR > ema21HOUR and EMA21HOUR > EMA34HOUR and EMA34HOUR > EMA55HOUR and EMA55HOUR > EMA89HOUR;
    SNHOUR = ema8HOUR < ema21HOUR and ema21HOUR < EMA34HOUR and EMA34HOUR < EMA55HOUR and EMA55HOUR < EMA89HOUR;
    SPWHOUR = ema8HOUR < ema21HOUR and EMA34HOUR > EMA55HOUR and EMA55HOUR > EMA89HOUR;
    SNWHOUR = ema8HOUR > ema21HOUR  and EMA34HOUR < EMA55HOUR and EMA55HOUR < EMA89HOUR;
    HOURAggregationPeriod = 1;
}
else {
    EMA89HOUR = 0;
    EMA55HOUR = 0;
    EMA34HOUR = 0;
    EMA21HOUR =0;
    EMA8HOUR =0;
    SPHOUR = 0;
    SNHOUR = 0;
    SPWHOUR = 0;
    SNWHOUR = 0;
    HOURAggregationPeriod =0;
}

AddLabel(HOURAggregationPeriod, "1h: EMA's", if SPHOUR then GlobalColor("StackedPositive") else if SNHOUR then GlobalColor("StackedNegative") else if (SPWHOUR or SNWHOUR) then GlobalColor("Warning") else GlobalColor("Neutral"));

# 30-MIN STACKED EMA'S LABEL

def EMA89THIRTY_MIN;
def EMA55THIRTY_MIN;
def EMA34THIRTY_MIN;
def EMA21THIRTY_MIN;
def EMA8THIRTY_MIN;
def SPTHIRTY_MIN;
def SNTHIRTY_MIN;
def SPWTHIRTY_MIN;
def SNWTHIRTY_MIN;
def THIRTY_MINAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.THIRTY_MIN {
    
    EMA89THIRTY_MIN = expAverage(close(period="30 MIN"),89);
    EMA55THIRTY_MIN = expAverage(close(period="30 MIN"),55);
    EMA34THIRTY_MIN = expAverage(close(period="30 MIN"),34);
    EMA21THIRTY_MIN = expAverage(close(period="30 MIN"),21);
    EMA8THIRTY_MIN = expAverage(close(period="30 MIN"),8);
    SPTHIRTY_MIN = ema8THIRTY_MIN > ema21THIRTY_MIN and EMA21THIRTY_MIN > EMA34THIRTY_MIN and EMA34THIRTY_MIN > EMA55THIRTY_MIN and EMA55THIRTY_MIN > EMA89THIRTY_MIN;
    SNTHIRTY_MIN = ema8THIRTY_MIN < ema21THIRTY_MIN and ema21THIRTY_MIN < EMA34THIRTY_MIN and EMA34THIRTY_MIN < EMA55THIRTY_MIN and EMA55THIRTY_MIN < EMA89THIRTY_MIN;
    SPWTHIRTY_MIN = ema8THIRTY_MIN < ema21THIRTY_MIN and EMA34THIRTY_MIN > EMA55THIRTY_MIN and EMA55THIRTY_MIN > EMA89THIRTY_MIN;
    SNWTHIRTY_MIN = ema8THIRTY_MIN > ema21THIRTY_MIN  and EMA34THIRTY_MIN < EMA55THIRTY_MIN and EMA55THIRTY_MIN < EMA89THIRTY_MIN;
    THIRTY_MINAggregationPeriod = 1;
}
else {
    EMA89THIRTY_MIN = 0;
    EMA55THIRTY_MIN = 0;
    EMA34THIRTY_MIN = 0;
    EMA21THIRTY_MIN =0;
    EMA8THIRTY_MIN =0;
    SPTHIRTY_MIN = 0;
    SNTHIRTY_MIN = 0;
    SPWTHIRTY_MIN = 0;
    SNWTHIRTY_MIN = 0;
    THIRTY_MINAggregationPeriod =0;
}

AddLabel(THIRTY_MINAggregationPeriod, "30m: EMA's", if SPTHIRTY_MIN then GlobalColor("StackedPositive") else if SNTHIRTY_MIN then GlobalColor("StackedNegative") else if (SPWTHIRTY_MIN or SNWTHIRTY_MIN) then GlobalColor("Warning") else GlobalColor("Neutral"));
 
Hey I'm sorry for the delayed reply. I completely forgot to get back to you! I'd be happy to share. But remind me again what the 10x are? If memory serves, that's for trend? See stacked EMA script attached.
Code:
#MTF STACKED EMA'S LABELS
#BY: CASEY BRETT


DefineGlobalColor("StackedPositive", color.green);
DefineGlobalColor("StackedNegative", color.red);
DefineGlobalColor("Warning", color.yellow);
DefineGlobalColor("Neutral", color.gray);

# MONTH STACKED EMA'S LABEL

def EMA89Month;
def EMA55Month;
def EMA34Month;
def EMA21Month;
def EMA8Month;
def SPMonth;
def SNMonth;
def SPWMonth;
def SNWMonth;
def monthAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.MONTH {
   
    EMA89Month = expAverage(close(period="MONTH"),89);
    EMA55Month = expAverage(close(period="MONTH"),55);
    EMA34Month = expAverage(close(period="MONTH"),34);
    EMA21Month = expAverage(close(period="MONTH"),21);
    EMA8Month = expAverage(close(period="MONTH"),8);
    SPMonth = ema8Month > ema21Month and EMA21Month > EMA34Month and EMA34Month > EMA55Month and EMA55Month > EMA89Month;
    SNMonth = ema8Month < ema21Month and ema21Month < EMA34Month and EMA34Month < EMA55Month and EMA55Month < EMA89Month;
    SPWMonth = ema8Month < ema21Month and EMA34Month > EMA55Month and EMA55Month > EMA89Month;
    SNWMonth = ema8Month > ema21Month  and EMA34Month < EMA55Month and EMA55Month < EMA89Month;
    monthAggregationPeriod = 1;
}
else {
    EMA89Month = 0;
    EMA55Month = 0;
    EMA34Month = 0;
    EMA21Month =0;
    EMA8Month =0;
    SPMonth = 0;
    SNMonth = 0;
    SPWMonth = 0;
    SNWMonth = 0;
    monthAggregationPeriod =0;
}

AddLabel(monthAggregationPeriod, "M: EMA's", if SPMonth then GlobalColor("StackedPositive") else if SNMonth then GlobalColor("StackedNegative") else if (SPWMonth or SNWMonth) then GlobalColor("Warning") else GlobalColor("Neutral"));

# WEEK STACKED EMA'S LABEL

def EMA89Week;
def EMA55Week;
def EMA34Week;
def EMA21Week;
def EMA8Week;
def SPWeek;
def SNWeek;
def SPWWeek;
def SNWWeek;
def WeekAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.Week {
   
    EMA89Week = expAverage(close(period="Week"),89);
    EMA55Week = expAverage(close(period="Week"),55);
    EMA34Week = expAverage(close(period="Week"),34);
    EMA21Week = expAverage(close(period="Week"),21);
    EMA8Week = expAverage(close(period="Week"),8);
    SPWeek = ema8Week > ema21Week and EMA21Week > EMA34Week and EMA34Week > EMA55Week and EMA55Week > EMA89Week;
    SNWeek = ema8Week < ema21Week and ema21Week < EMA34Week and EMA34Week < EMA55Week and EMA55Week < EMA89Week;
    SPWWeek = ema8Week < ema21Week and EMA34Week > EMA55Week and EMA55Week > EMA89Week;
    SNWWeek = ema8Week > ema21Week  and EMA34Week < EMA55Week and EMA55Week < EMA89Week;
    WeekAggregationPeriod = 1;
}
else {
    EMA89Week = 0;
    EMA55Week = 0;
    EMA34Week = 0;
    EMA21Week =0;
    EMA8Week =0;
    SPWeek = 0;
    SNWeek = 0;
    SPWWeek = 0;
    SNWWeek = 0;
    WeekAggregationPeriod =0;
}

AddLabel(WeekAggregationPeriod, "W: EMA's", if SPWeek then GlobalColor("StackedPositive") else if SNWeek then GlobalColor("StackedNegative") else if (SPWWeek or SNWWeek) then GlobalColor("Warning") else GlobalColor("Neutral"));

# 4-DAY STACKED EMA'S LABEL

def EMA89FOUR_DAYS;
def EMA55FOUR_DAYS;
def EMA34FOUR_DAYS;
def EMA21FOUR_DAYS;
def EMA8FOUR_DAYS;
def SPFOUR_DAYS;
def SNFOUR_DAYS;
def SPWFOUR_DAYS;
def SNWFOUR_DAYS;
def FOUR_DAYSAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.FOUR_DAYS {
   
    EMA89FOUR_DAYS = expAverage(close(period="4 DAYS"),89);
    EMA55FOUR_DAYS = expAverage(close(period="4 DAYS"),55);
    EMA34FOUR_DAYS = expAverage(close(period="4 DAYS"),34);
    EMA21FOUR_DAYS = expAverage(close(period="4 DAYS"),21);
    EMA8FOUR_DAYS = expAverage(close(period="4 DAYS"),8);
    SPFOUR_DAYS = ema8FOUR_DAYS > ema21FOUR_DAYS and EMA21FOUR_DAYS > EMA34FOUR_DAYS and EMA34FOUR_DAYS > EMA55FOUR_DAYS and EMA55FOUR_DAYS > EMA89FOUR_DAYS;
    SNFOUR_DAYS = ema8FOUR_DAYS < ema21FOUR_DAYS and ema21FOUR_DAYS < EMA34FOUR_DAYS and EMA34FOUR_DAYS < EMA55FOUR_DAYS and EMA55FOUR_DAYS < EMA89FOUR_DAYS;
    SPWFOUR_DAYS = ema8FOUR_DAYS < ema21FOUR_DAYS and EMA34FOUR_DAYS > EMA55FOUR_DAYS and EMA55FOUR_DAYS > EMA89FOUR_DAYS;
    SNWFOUR_DAYS = ema8FOUR_DAYS > ema21FOUR_DAYS  and EMA34FOUR_DAYS < EMA55FOUR_DAYS and EMA55FOUR_DAYS < EMA89FOUR_DAYS;
    FOUR_DAYSAggregationPeriod = 1;
}
else {
    EMA89FOUR_DAYS = 0;
    EMA55FOUR_DAYS = 0;
    EMA34FOUR_DAYS = 0;
    EMA21FOUR_DAYS =0;
    EMA8FOUR_DAYS =0;
    SPFOUR_DAYS = 0;
    SNFOUR_DAYS = 0;
    SPWFOUR_DAYS = 0;
    SNWFOUR_DAYS = 0;
    FOUR_DAYSAggregationPeriod =0;
}

AddLabel(FOUR_DAYSAggregationPeriod, "4D: EMA's", if SPFOUR_DAYS then GlobalColor("StackedPositive") else if SNFOUR_DAYS then GlobalColor("StackedNegative") else if (SPWFOUR_DAYS or SNWFOUR_DAYS) then GlobalColor("Warning") else GlobalColor("Neutral"));

# 3-DAYS STACKED EMA'S LABEL

def EMA89THREE_DAYS;
def EMA55THREE_DAYS;
def EMA34THREE_DAYS;
def EMA21THREE_DAYS;
def EMA8THREE_DAYS;
def SPTHREE_DAYS;
def SNTHREE_DAYS;
def SPWTHREE_DAYS;
def SNWTHREE_DAYS;
def THREE_DAYSAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.THREE_DAYS {
   
    EMA89THREE_DAYS = expAverage(close(period="3 DAYS"),89);
    EMA55THREE_DAYS = expAverage(close(period="3 DAYS"),55);
    EMA34THREE_DAYS = expAverage(close(period="3 DAYS"),34);
    EMA21THREE_DAYS = expAverage(close(period="3 DAYS"),21);
    EMA8THREE_DAYS = expAverage(close(period="3 DAYS"),8);
    SPTHREE_DAYS = ema8THREE_DAYS > ema21THREE_DAYS and EMA21THREE_DAYS > EMA34THREE_DAYS and EMA34THREE_DAYS > EMA55THREE_DAYS and EMA55THREE_DAYS > EMA89THREE_DAYS;
    SNTHREE_DAYS = ema8THREE_DAYS < ema21THREE_DAYS and ema21THREE_DAYS < EMA34THREE_DAYS and EMA34THREE_DAYS < EMA55THREE_DAYS and EMA55THREE_DAYS < EMA89THREE_DAYS;
    SPWTHREE_DAYS = ema8THREE_DAYS < ema21THREE_DAYS and EMA34THREE_DAYS > EMA55THREE_DAYS and EMA55THREE_DAYS > EMA89THREE_DAYS;
    SNWTHREE_DAYS = ema8THREE_DAYS > ema21THREE_DAYS  and EMA34THREE_DAYS < EMA55THREE_DAYS and EMA55THREE_DAYS < EMA89THREE_DAYS;
    THREE_DAYSAggregationPeriod = 1;
}
else {
    EMA89THREE_DAYS = 0;
    EMA55THREE_DAYS = 0;
    EMA34THREE_DAYS = 0;
    EMA21THREE_DAYS =0;
    EMA8THREE_DAYS =0;
    SPTHREE_DAYS = 0;
    SNTHREE_DAYS = 0;
    SPWTHREE_DAYS = 0;
    SNWTHREE_DAYS = 0;
    THREE_DAYSAggregationPeriod =0;
}

AddLabel(THREE_DAYSAggregationPeriod, "3D: EMA's", if SPTHREE_DAYS then GlobalColor("StackedPositive") else if SNTHREE_DAYS then GlobalColor("StackedNegative") else if (SPWTHREE_DAYS or SNWTHREE_DAYS) then GlobalColor("Warning") else GlobalColor("Neutral"));

# 2-DAYS STACKED EMA'S LABEL

def EMA89TWO_DAYS;
def EMA55TWO_DAYS;
def EMA34TWO_DAYS;
def EMA21TWO_DAYS;
def EMA8TWO_DAYS;
def SPTWO_DAYS;
def SNTWO_DAYS;
def SPWTWO_DAYS;
def SNWTWO_DAYS;
def TWO_DAYSAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.TWO_DAYS {
   
    EMA89TWO_DAYS = expAverage(close(period="2 DAYS"),89);
    EMA55TWO_DAYS = expAverage(close(period="2 DAYS"),55);
    EMA34TWO_DAYS = expAverage(close(period="2 DAYS"),34);
    EMA21TWO_DAYS = expAverage(close(period="2 DAYS"),21);
    EMA8TWO_DAYS = expAverage(close(period="2 DAYS"),8);
    SPTWO_DAYS = ema8TWO_DAYS > ema21TWO_DAYS and EMA21TWO_DAYS > EMA34TWO_DAYS and EMA34TWO_DAYS > EMA55TWO_DAYS and EMA55TWO_DAYS > EMA89TWO_DAYS;
    SNTWO_DAYS = ema8TWO_DAYS < ema21TWO_DAYS and ema21TWO_DAYS < EMA34TWO_DAYS and EMA34TWO_DAYS < EMA55TWO_DAYS and EMA55TWO_DAYS < EMA89TWO_DAYS;
    SPWTWO_DAYS = ema8TWO_DAYS < ema21TWO_DAYS and EMA34TWO_DAYS > EMA55TWO_DAYS and EMA55TWO_DAYS > EMA89TWO_DAYS;
    SNWTWO_DAYS = ema8TWO_DAYS > ema21TWO_DAYS  and EMA34TWO_DAYS < EMA55TWO_DAYS and EMA55TWO_DAYS < EMA89TWO_DAYS;
    TWO_DAYSAggregationPeriod = 1;
}
else {
    EMA89TWO_DAYS = 0;
    EMA55TWO_DAYS = 0;
    EMA34TWO_DAYS = 0;
    EMA21TWO_DAYS =0;
    EMA8TWO_DAYS =0;
    SPTWO_DAYS = 0;
    SNTWO_DAYS = 0;
    SPWTWO_DAYS = 0;
    SNWTWO_DAYS = 0;
    TWO_DAYSAggregationPeriod =0;
}

AddLabel(TWO_DAYSAggregationPeriod, "2D: EMA's", if SPTWO_DAYS then GlobalColor("StackedPositive") else if SNTWO_DAYS then GlobalColor("StackedNegative") else if (SPWTWO_DAYS or SNWTWO_DAYS) then GlobalColor("Warning") else GlobalColor("Neutral"));

# ONE DAY STACKED EMA'S LABEL

def EMA89DAY;
def EMA55DAY;
def EMA34DAY;
def EMA21DAY;
def EMA8DAY;
def SPDAY;
def SNDAY;
def SPWDAY;
def SNWDAY;
def DAYAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.DAY {
   
    EMA89DAY = expAverage(close(period="DAY"),89);
    EMA55DAY = expAverage(close(period="DAY"),55);
    EMA34DAY = expAverage(close(period="DAY"),34);
    EMA21DAY = expAverage(close(period="DAY"),21);
    EMA8DAY = expAverage(close(period="DAY"),8);
    SPDAY = ema8DAY > ema21DAY and EMA21DAY > EMA34DAY and EMA34DAY > EMA55DAY and EMA55DAY > EMA89DAY;
    SNDAY = ema8DAY < ema21DAY and ema21DAY < EMA34DAY and EMA34DAY < EMA55DAY and EMA55DAY < EMA89DAY;
    SPWDAY = ema8DAY < ema21DAY and EMA34DAY > EMA55DAY and EMA55DAY > EMA89DAY;
    SNWDAY = ema8DAY > ema21DAY  and EMA34DAY < EMA55DAY and EMA55DAY < EMA89DAY;
    DAYAggregationPeriod = 1;
}
else {
    EMA89DAY = 0;
    EMA55DAY = 0;
    EMA34DAY = 0;
    EMA21DAY =0;
    EMA8DAY =0;
    SPDAY = 0;
    SNDAY = 0;
    SPWDAY = 0;
    SNWDAY = 0;
    DAYAggregationPeriod =0;
}

AddLabel(DAYAggregationPeriod, "D: EMA's", if SPDAY then GlobalColor("StackedPositive") else if SNDAY then GlobalColor("StackedNegative") else if (SPWDAY or SNWDAY) then GlobalColor("Warning") else GlobalColor("Neutral"));

# 4 HOUR STACKED EMA'S LABEL

def EMA89FOUR_HOURS;
def EMA55FOUR_HOURS;
def EMA34FOUR_HOURS;
def EMA21FOUR_HOURS;
def EMA8FOUR_HOURS;
def SPFOUR_HOURS;
def SNFOUR_HOURS;
def SPWFOUR_HOURS;
def SNWFOUR_HOURS;
def FOUR_HOURSAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.FOUR_HOURS {
   
    EMA89FOUR_HOURS = expAverage(close(period="4 HOURS"),89);
    EMA55FOUR_HOURS = expAverage(close(period="4 HOURS"),55);
    EMA34FOUR_HOURS = expAverage(close(period="4 HOURS"),34);
    EMA21FOUR_HOURS = expAverage(close(period="4 HOURS"),21);
    EMA8FOUR_HOURS = expAverage(close(period="4 HOURS"),8);
    SPFOUR_HOURS = ema8FOUR_HOURS > ema21FOUR_HOURS and EMA21FOUR_HOURS > EMA34FOUR_HOURS and EMA34FOUR_HOURS > EMA55FOUR_HOURS and EMA55FOUR_HOURS > EMA89FOUR_HOURS;
    SNFOUR_HOURS = ema8FOUR_HOURS < ema21FOUR_HOURS and ema21FOUR_HOURS < EMA34FOUR_HOURS and EMA34FOUR_HOURS < EMA55FOUR_HOURS and EMA55FOUR_HOURS < EMA89FOUR_HOURS;
    SPWFOUR_HOURS = ema8FOUR_HOURS < ema21FOUR_HOURS and EMA34FOUR_HOURS > EMA55FOUR_HOURS and EMA55FOUR_HOURS > EMA89FOUR_HOURS;
    SNWFOUR_HOURS = ema8FOUR_HOURS > ema21FOUR_HOURS  and EMA34FOUR_HOURS < EMA55FOUR_HOURS and EMA55FOUR_HOURS < EMA89FOUR_HOURS;
    FOUR_HOURSAggregationPeriod = 1;
}
else {
    EMA89FOUR_HOURS = 0;
    EMA55FOUR_HOURS = 0;
    EMA34FOUR_HOURS = 0;
    EMA21FOUR_HOURS =0;
    EMA8FOUR_HOURS =0;
    SPFOUR_HOURS = 0;
    SNFOUR_HOURS = 0;
    SPWFOUR_HOURS = 0;
    SNWFOUR_HOURS = 0;
    FOUR_HOURSAggregationPeriod =0;
}

AddLabel(FOUR_HOURSAggregationPeriod, "4h: EMA's", if SPFOUR_HOURS then GlobalColor("StackedPositive") else if SNFOUR_HOURS then GlobalColor("StackedNegative") else if (SPWFOUR_HOURS or SNWFOUR_HOURS) then GlobalColor("Warning") else GlobalColor("Neutral"));

# 2 HOUR STACKED EMA'S LABEL

def EMA89TWO_HOURS;
def EMA55TWO_HOURS;
def EMA34TWO_HOURS;
def EMA21TWO_HOURS;
def EMA8TWO_HOURS;
def SPTWO_HOURS;
def SNTWO_HOURS;
def SPWTWO_HOURS;
def SNWTWO_HOURS;
def TWO_HOURSAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.TWO_HOURS {
   
    EMA89TWO_HOURS = expAverage(close(period="2 HOURS"),89);
    EMA55TWO_HOURS = expAverage(close(period="2 HOURS"),55);
    EMA34TWO_HOURS = expAverage(close(period="2 HOURS"),34);
    EMA21TWO_HOURS = expAverage(close(period="2 HOURS"),21);
    EMA8TWO_HOURS = expAverage(close(period="2 HOURS"),8);
    SPTWO_HOURS = ema8TWO_HOURS > ema21TWO_HOURS and EMA21TWO_HOURS > EMA34TWO_HOURS and EMA34TWO_HOURS > EMA55TWO_HOURS and EMA55TWO_HOURS > EMA89TWO_HOURS;
    SNTWO_HOURS = ema8TWO_HOURS < ema21TWO_HOURS and ema21TWO_HOURS < EMA34TWO_HOURS and EMA34TWO_HOURS < EMA55TWO_HOURS and EMA55TWO_HOURS < EMA89TWO_HOURS;
    SPWTWO_HOURS = ema8TWO_HOURS < ema21TWO_HOURS and EMA34TWO_HOURS > EMA55TWO_HOURS and EMA55TWO_HOURS > EMA89TWO_HOURS;
    SNWTWO_HOURS = ema8TWO_HOURS > ema21TWO_HOURS  and EMA34TWO_HOURS < EMA55TWO_HOURS and EMA55TWO_HOURS < EMA89TWO_HOURS;
    TWO_HOURSAggregationPeriod = 1;
}
else {
    EMA89TWO_HOURS = 0;
    EMA55TWO_HOURS = 0;
    EMA34TWO_HOURS = 0;
    EMA21TWO_HOURS =0;
    EMA8TWO_HOURS =0;
    SPTWO_HOURS = 0;
    SNTWO_HOURS = 0;
    SPWTWO_HOURS = 0;
    SNWTWO_HOURS = 0;
    TWO_HOURSAggregationPeriod =0;
}

AddLabel(TWO_HOURSAggregationPeriod, "2h: EMA's", if SPTWO_HOURS then GlobalColor("StackedPositive") else if SNTWO_HOURS then GlobalColor("StackedNegative") else if (SPWTWO_HOURS or SNWTWO_HOURS) then GlobalColor("Warning") else GlobalColor("Neutral"));

# ONE HOUR STACKED EMA'S SCHEDULE

def EMA89HOUR;
def EMA55HOUR;
def EMA34HOUR;
def EMA21HOUR;
def EMA8HOUR;
def SPHOUR;
def SNHOUR;
def SPWHOUR;
def SNWHOUR;
def HOURAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.HOUR {
   
    EMA89HOUR = expAverage(close(period="1 HOUR"),89);
    EMA55HOUR = expAverage(close(period="1 HOUR"),55);
    EMA34HOUR = expAverage(close(period="1 HOUR"),34);
    EMA21HOUR = expAverage(close(period="1 HOUR"),21);
    EMA8HOUR = expAverage(close(period="1 HOUR"),8);
    SPHOUR = ema8HOUR > ema21HOUR and EMA21HOUR > EMA34HOUR and EMA34HOUR > EMA55HOUR and EMA55HOUR > EMA89HOUR;
    SNHOUR = ema8HOUR < ema21HOUR and ema21HOUR < EMA34HOUR and EMA34HOUR < EMA55HOUR and EMA55HOUR < EMA89HOUR;
    SPWHOUR = ema8HOUR < ema21HOUR and EMA34HOUR > EMA55HOUR and EMA55HOUR > EMA89HOUR;
    SNWHOUR = ema8HOUR > ema21HOUR  and EMA34HOUR < EMA55HOUR and EMA55HOUR < EMA89HOUR;
    HOURAggregationPeriod = 1;
}
else {
    EMA89HOUR = 0;
    EMA55HOUR = 0;
    EMA34HOUR = 0;
    EMA21HOUR =0;
    EMA8HOUR =0;
    SPHOUR = 0;
    SNHOUR = 0;
    SPWHOUR = 0;
    SNWHOUR = 0;
    HOURAggregationPeriod =0;
}

AddLabel(HOURAggregationPeriod, "1h: EMA's", if SPHOUR then GlobalColor("StackedPositive") else if SNHOUR then GlobalColor("StackedNegative") else if (SPWHOUR or SNWHOUR) then GlobalColor("Warning") else GlobalColor("Neutral"));

# 30-MIN STACKED EMA'S LABEL

def EMA89THIRTY_MIN;
def EMA55THIRTY_MIN;
def EMA34THIRTY_MIN;
def EMA21THIRTY_MIN;
def EMA8THIRTY_MIN;
def SPTHIRTY_MIN;
def SNTHIRTY_MIN;
def SPWTHIRTY_MIN;
def SNWTHIRTY_MIN;
def THIRTY_MINAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.THIRTY_MIN {
   
    EMA89THIRTY_MIN = expAverage(close(period="30 MIN"),89);
    EMA55THIRTY_MIN = expAverage(close(period="30 MIN"),55);
    EMA34THIRTY_MIN = expAverage(close(period="30 MIN"),34);
    EMA21THIRTY_MIN = expAverage(close(period="30 MIN"),21);
    EMA8THIRTY_MIN = expAverage(close(period="30 MIN"),8);
    SPTHIRTY_MIN = ema8THIRTY_MIN > ema21THIRTY_MIN and EMA21THIRTY_MIN > EMA34THIRTY_MIN and EMA34THIRTY_MIN > EMA55THIRTY_MIN and EMA55THIRTY_MIN > EMA89THIRTY_MIN;
    SNTHIRTY_MIN = ema8THIRTY_MIN < ema21THIRTY_MIN and ema21THIRTY_MIN < EMA34THIRTY_MIN and EMA34THIRTY_MIN < EMA55THIRTY_MIN and EMA55THIRTY_MIN < EMA89THIRTY_MIN;
    SPWTHIRTY_MIN = ema8THIRTY_MIN < ema21THIRTY_MIN and EMA34THIRTY_MIN > EMA55THIRTY_MIN and EMA55THIRTY_MIN > EMA89THIRTY_MIN;
    SNWTHIRTY_MIN = ema8THIRTY_MIN > ema21THIRTY_MIN  and EMA34THIRTY_MIN < EMA55THIRTY_MIN and EMA55THIRTY_MIN < EMA89THIRTY_MIN;
    THIRTY_MINAggregationPeriod = 1;
}
else {
    EMA89THIRTY_MIN = 0;
    EMA55THIRTY_MIN = 0;
    EMA34THIRTY_MIN = 0;
    EMA21THIRTY_MIN =0;
    EMA8THIRTY_MIN =0;
    SPTHIRTY_MIN = 0;
    SNTHIRTY_MIN = 0;
    SPWTHIRTY_MIN = 0;
    SNWTHIRTY_MIN = 0;
    THIRTY_MINAggregationPeriod =0;
}

AddLabel(THIRTY_MINAggregationPeriod, "30m: EMA's", if SPTHIRTY_MIN then GlobalColor("StackedPositive") else if SNTHIRTY_MIN then GlobalColor("StackedNegative") else if (SPWTHIRTY_MIN or SNWTHIRTY_MIN) then GlobalColor("Warning") else GlobalColor("Neutral"));
Thank you again, will test it.

@caseyjbrett The 10x are for trend correct.
 
Thank you again, will test it.

@caseyjbrett The 10x are for trend correct.
Again, sorry for the delayed reply; I haven't forgotten about you! I have 2 different scripts for MTF Trend Labels. One of them I created. It's simple. The label is green if the time frame (the name of the label shows what TF obviously) is trending up - but here's the simple part, it's solely based on candle open and candle close. Since the larger TF labels will not have currently closed candles, those labels use the opening price and the last price. I only use the following labels: Month, Week, 4day, Day, 4hour, Hour, 30min, & 15min and, because of that, the first script only includes those timeframes. The 2nd version of my script will include all timeframes from Month down to 1minute. You're able to toggle each timeframe on and off in the settings window of the indicator.

**NOTE: please read the comments at the top of my indicator script so you understand it completely: FTFC (Full-Time-Frame-Continuity) LABELS

The 2nd script is for MTF DMI labels created by TOS Indicators. At the top of the script you'll see the comments, but here's a link to the full (video) tutorial where the guy makes it. In case you're not familiar with DMI it's the Directional Movement Index and it tracks a ticker's trend. The specifics of how it's calculated are pretty complicated, but the gist is - the labels show red if DMI- is higher/above DMI+ and if the monthlyADX is greater than current ADX levels. You can watch the tutorial video and read through the script if you want to understand the in and outs of how it works.
Code:
##FTFC (Full-Time-Frame-Continuity) Labels##
# By: Casey Brett
#IMPORTANT: In order for all labels to show up on your chart you MUST do the following 2 things:
#1 - Use a Time Frame less than OR equal to the lowest label (15minute)
#2 - Have at least 30 days of time frame.  Ex. 30 days :1 min // 30 Days : 15 minutes // 45 Days : 30 minutes

input MonthLabel = yes;
input WeekLabel = yes;
input FourDayLabel = yes;
input DayLabel = yes;
input FourHourLabel = yes;
input HourLabel = yes;
input ThirtyMinLabel = yes;
input FifteenMinLabel = yes;

DefineGlobalColor("UP", color.green);
DefineGlobalColor("DOWN", color.red);

## Month Aggregation Period Variables

def MonthOpen;
def MonthClose;
def MonthUp;
def MonthDown;
def MonthAggregationPeriod;
if getAggregationPeriod() <= AggregationPeriod.Month {
    MonthOpen = open(period = "Month");
    MonthClose = close(period = "Month");
    MonthUp = if MonthClose > MonthOpen then 1 else 0;
    MonthDown = if MonthClose < MonthOpen then 1 else 0;
    MonthAggregationPeriod = 1;
}
else {
    MonthOpen = 0;
    MonthClose = 0;
    MonthUp = 0;
    MonthDown = 0;
    MonthAggregationPeriod = 0;
}
AddLabel(MonthLabel and MonthAggregationPeriod, " M ", if MonthUp then GlobalColor("UP") else if MonthDown then GlobalColor("DOWN") else Color.White);

## Week Aggregation Period Variables

def WeekOpen;
def WeekClose;
def WeekUp;
def WeekDown;
def WeekAggregationPeriod;
if getAggregationPeriod() <= AggregationPeriod.Week {
    WeekOpen = open(period = "Week");
    WeekClose = close(period = "Week");
    WeekUp = if WeekClose > WeekOpen then 1 else 0;
    WeekDown = if WeekClose < WeekOpen then 1 else 0;
    WeekAggregationPeriod = 1;
}
else {
    WeekOpen = 0;
    WeekClose = 0;
    WeekUp = 0;
    WeekDown = 0;
    WeekAggregationPeriod = 0;
}
AddLabel(WeekLabel and WeekAggregationPeriod, " W ", if WeekUp then GlobalColor("UP") else if WeekDown then GlobalColor("DOWN") else Color.White);

## Four_Days Aggregation Period Variables

def Four_DaysOpen;
def Four_DaysClose;
def Four_DaysUp;
def Four_DaysDown;
def Four_DaysAggregationPeriod;
if getAggregationPeriod() <= AggregationPeriod.Four_Days {
    Four_DaysOpen = open(period = "4 Days");
    Four_DaysClose = close(period = "4 Days");
    Four_DaysUp = if Four_DaysClose > Four_DaysOpen then 1 else 0;
    Four_DaysDown = if Four_DaysClose < Four_DaysOpen then 1 else 0;
    Four_DaysAggregationPeriod = 1;
}
else {
    Four_DaysOpen = 0;
    Four_DaysClose = 0;
    Four_DaysUp = 0;
    Four_DaysDown = 0;
    Four_DaysAggregationPeriod = 0;
}
AddLabel(FourDayLabel and Four_DaysAggregationPeriod, " 4D ", if Four_DaysUp then GlobalColor("UP") else if Four_DaysDown then GlobalColor("DOWN") else Color.White);

## Day Aggregation Period Variables

def DayOpen;
def DayClose;
def DayUp;
def DayDown;
def DayAggregationPeriod;
if getAggregationPeriod() <= AggregationPeriod.Day {
    DayOpen = open(period = "Day");
    DayClose = close(period = "Day");
    DayUp = if DayClose > DayOpen then 1 else 0;
    DayDown = if DayClose < DayOpen then 1 else 0;
    DayAggregationPeriod = 1;
}
else {
    DayOpen = 0;
    DayClose = 0;
    DayUp = 0;
    DayDown = 0;
    DayAggregationPeriod = 0;
}
AddLabel(DayLabel and DayAggregationPeriod, " D ", if DayUp then GlobalColor("UP") else if DayDown then GlobalColor("DOWN") else Color.White);

## four_hours Aggregation Period Variables

def four_hoursOpen;
def four_hoursClose;
def four_hoursUp;
def four_hoursDown;
def four_hoursAggregationPeriod;
if getAggregationPeriod() <= AggregationPeriod.four_hours {
    four_hoursOpen = open(period = "4 hours");
    four_hoursClose = close(period = "4 hours");
    four_hoursUp = if four_hoursClose > four_hoursOpen then 1 else 0;
    four_hoursDown = if four_hoursClose < four_hoursOpen then 1 else 0;
    four_hoursAggregationPeriod = 1;
}
else {
    four_hoursOpen = 0;
    four_hoursClose = 0;
    four_hoursUp = 0;
    four_hoursDown = 0;
    four_hoursAggregationPeriod = 0;
}
AddLabel(FourHourLabel and four_hoursAggregationPeriod, " 4H ", if four_hoursUp then GlobalColor("UP") else if four_hoursDown then GlobalColor("DOWN") else Color.White);

## Hour Aggregation Period Variables

def HourOpen;
def HourClose;
def HourUp;
def HourDown;
def HourAggregationPeriod;
if getAggregationPeriod() <= AggregationPeriod.Hour {
    HourOpen = open(period = "1 Hour");
    HourClose = close(period = "1 Hour");
    HourUp = if HourClose > HourOpen then 1 else 0;
    HourDown = if HourClose < HourOpen then 1 else 0;
    HourAggregationPeriod = 1;
}
else {
    HourOpen = 0;
    HourClose = 0;
    HourUp = 0;
    HourDown = 0;
    HourAggregationPeriod = 0;
}
AddLabel(HourLabel and HourAggregationPeriod, " H ", if HourUp then GlobalColor("UP") else if HourDown then GlobalColor("DOWN") else Color.White);

## Thirty_Min Aggregation Period Variables

def Thirty_MinOpen;
def Thirty_MinClose;
def Thirty_MinUp;
def Thirty_MinDown;
def Thirty_MinAggregationPeriod;
if getAggregationPeriod() <= AggregationPeriod.Thirty_Min {
    Thirty_MinOpen = open(period = "30 Min");
    Thirty_MinClose = close(period = "30 Min");
    Thirty_MinUp = if Thirty_MinClose > Thirty_MinOpen then 1 else 0;
    Thirty_MinDown = if Thirty_MinClose < Thirty_MinOpen then 1 else 0;
    Thirty_MinAggregationPeriod = 1;
}
else {
    Thirty_MinOpen = 0;
    Thirty_MinClose = 0;
    Thirty_MinUp = 0;
    Thirty_MinDown = 0;
    Thirty_MinAggregationPeriod = 0;
}
AddLabel(ThirtyMinLabel and Thirty_MinAggregationPeriod, " 30M ", if Thirty_MinUp then GlobalColor("UP") else if Thirty_MinDown then GlobalColor("DOWN") else Color.White);

## Fifteen_Min Aggregation Period Variables

def Fifteen_MinOpen;
def Fifteen_MinClose;
def Fifteen_MinUp;
def Fifteen_MinDown;
def Fifteen_MinAggregationPeriod;
if getAggregationPeriod() <= AggregationPeriod.Fifteen_Min {
    Fifteen_MinOpen = open(period = "15 Min");
    Fifteen_MinClose = close(period = "15 Min");
    Fifteen_MinUp = if Fifteen_MinClose > Fifteen_MinOpen then 1 else 0;
    Fifteen_MinDown = if Fifteen_MinClose < Fifteen_MinOpen then 1 else 0;
    Fifteen_MinAggregationPeriod = 1;
}
else {
    Fifteen_MinOpen = 0;
    Fifteen_MinClose = 0;
    Fifteen_MinUp = 0;
    Fifteen_MinDown = 0;
    Fifteen_MinAggregationPeriod = 0;
}
AddLabel(FifteenMinLabel and Fifteen_MinAggregationPeriod, " 15M ", if Fifteen_MinUp then GlobalColor("UP") else if Fifteen_MinDown then GlobalColor("DOWN") else Color.White);


5XDoV1O.png
 
Last edited:
Thank you again, will test it.

@caseyjbrett The 10x are for trend correct.
Here's the 2nd version of my script which includes the following timeframes: Month, Week, 4day, 2day, Day, 4hour, 2hour, hour, 30min, 15min, 5min, 1min
Code:
##FTFC (Full-Time-Frame-Continuity) Labels##
# By: Casey Brett
#IMPORTANT: In order for all labels to show up on your chart you MUST do the following 2 things:
#1 - Use a Time Frame less than OR equal to the lowest label (15minute)
#2 - Have at least 30 days of time frame.  Ex. 30 days :1 min // 30 Days : 15 minutes // 45 Days : 30 minutes

input MonthLabel = yes;
input WeekLabel = yes;
input FourDayLabel = yes;
input TwoDayLabel = yes;
input DayLabel = yes;
input FourHourLabel = yes;
input TwoHourLabel = yes;
input HourLabel = yes;
input ThirtyMinLabel = yes;
input FifteenMinLabel = yes;
input FiveMinLabel = yes;
input OneMinLabel = yes;

DefineGlobalColor("UP", color.green);
DefineGlobalColor("DOWN", color.red);

## Month Aggregation Period Variables

def MonthOpen;
def MonthClose;
def MonthUp;
def MonthDown;
def MonthAggregationPeriod;
if getAggregationPeriod() <= AggregationPeriod.Month {
    MonthOpen = open(period = "Month");
    MonthClose = close(period = "Month");
    MonthUp = if MonthClose > MonthOpen then 1 else 0;
    MonthDown = if MonthClose < MonthOpen then 1 else 0;
    MonthAggregationPeriod = 1;
}
else {
    MonthOpen = 0;
    MonthClose = 0;
    MonthUp = 0;
    MonthDown = 0;
    MonthAggregationPeriod = 0;
}
AddLabel(MonthLabel and MonthAggregationPeriod, " M ", if MonthUp then GlobalColor("UP") else if MonthDown then GlobalColor("DOWN") else Color.White);

## Week Aggregation Period Variables

def WeekOpen;
def WeekClose;
def WeekUp;
def WeekDown;
def WeekAggregationPeriod;
if getAggregationPeriod() <= AggregationPeriod.Week {
    WeekOpen = open(period = "Week");
    WeekClose = close(period = "Week");
    WeekUp = if WeekClose > WeekOpen then 1 else 0;
    WeekDown = if WeekClose < WeekOpen then 1 else 0;
    WeekAggregationPeriod = 1;
}
else {
    WeekOpen = 0;
    WeekClose = 0;
    WeekUp = 0;
    WeekDown = 0;
    WeekAggregationPeriod = 0;
}
AddLabel(WeekLabel and WeekAggregationPeriod, " W ", if WeekUp then GlobalColor("UP") else if WeekDown then GlobalColor("DOWN") else Color.White);

## Four_Days Aggregation Period Variables

def Four_DaysOpen;
def Four_DaysClose;
def Four_DaysUp;
def Four_DaysDown;
def Four_DaysAggregationPeriod;
if getAggregationPeriod() <= AggregationPeriod.Four_Days {
    Four_DaysOpen = open(period = "4 Days");
    Four_DaysClose = close(period = "4 Days");
    Four_DaysUp = if Four_DaysClose > Four_DaysOpen then 1 else 0;
    Four_DaysDown = if Four_DaysClose < Four_DaysOpen then 1 else 0;
    Four_DaysAggregationPeriod = 1;
}
else {
    Four_DaysOpen = 0;
    Four_DaysClose = 0;
    Four_DaysUp = 0;
    Four_DaysDown = 0;
    Four_DaysAggregationPeriod = 0;
}
AddLabel(FourDayLabel and Four_DaysAggregationPeriod, " 4D ", if Four_DaysUp then GlobalColor("UP") else if Four_DaysDown then GlobalColor("DOWN") else Color.White);

## Two_Days Aggregation Period Variables

def Two_DaysOpen;
def Two_DaysClose;
def Two_DaysUp;
def Two_DaysDown;
def Two_DaysAggregationPeriod;
if getAggregationPeriod() <= AggregationPeriod.Two_Days {
    Two_DaysOpen = open(period = "2 Days");
    Two_DaysClose = close(period = "2 Days");
    Two_DaysUp = if Two_DaysClose > Two_DaysOpen then 1 else 0;
    Two_DaysDown = if Two_DaysClose < Two_DaysOpen then 1 else 0;
    Two_DaysAggregationPeriod = 1;
}
else {
    Two_DaysOpen = 0;
    Two_DaysClose = 0;
    Two_DaysUp = 0;
    Two_DaysDown = 0;
    Two_DaysAggregationPeriod = 0;
}
AddLabel(TwoDayLabel and Two_DaysAggregationPeriod, " 2D ", if Two_DaysUp then GlobalColor("UP") else if Two_DaysDown then GlobalColor("DOWN") else Color.White);


## Day Aggregation Period Variables

def DayOpen;
def DayClose;
def DayUp;
def DayDown;
def DayAggregationPeriod;
if getAggregationPeriod() <= AggregationPeriod.Day {
    DayOpen = open(period = "Day");
    DayClose = close(period = "Day");
    DayUp = if DayClose > DayOpen then 1 else 0;
    DayDown = if DayClose < DayOpen then 1 else 0;
    DayAggregationPeriod = 1;
}
else {
    DayOpen = 0;
    DayClose = 0;
    DayUp = 0;
    DayDown = 0;
    DayAggregationPeriod = 0;
}
AddLabel(DayLabel and DayAggregationPeriod, " D ", if DayUp then GlobalColor("UP") else if DayDown then GlobalColor("DOWN") else Color.White);

## four_hours Aggregation Period Variables

def four_hoursOpen;
def four_hoursClose;
def four_hoursUp;
def four_hoursDown;
def four_hoursAggregationPeriod;
if getAggregationPeriod() <= AggregationPeriod.four_hours {
    four_hoursOpen = open(period = "4 hours");
    four_hoursClose = close(period = "4 hours");
    four_hoursUp = if four_hoursClose > four_hoursOpen then 1 else 0;
    four_hoursDown = if four_hoursClose < four_hoursOpen then 1 else 0;
    four_hoursAggregationPeriod = 1;
}
else {
    four_hoursOpen = 0;
    four_hoursClose = 0;
    four_hoursUp = 0;
    four_hoursDown = 0;
    four_hoursAggregationPeriod = 0;
}
AddLabel(FourHourLabel and four_hoursAggregationPeriod, " 4H ", if four_hoursUp then GlobalColor("UP") else if four_hoursDown then GlobalColor("DOWN") else Color.White);

## Two_Hours Aggregation Period Variables

def Two_HoursOpen;
def Two_HoursClose;
def Two_HoursUp;
def Two_HoursDown;
def Two_HoursAggregationPeriod;
if getAggregationPeriod() <= AggregationPeriod.Two_Hours {
    Two_HoursOpen = open(period = "2 Hours");
    Two_HoursClose = close(period = "2 Hours");
    Two_HoursUp = if Two_HoursClose > Two_HoursOpen then 1 else 0;
    Two_HoursDown = if Two_HoursClose < Two_HoursOpen then 1 else 0;
    Two_HoursAggregationPeriod = 1;
}
else {
    Two_HoursOpen = 0;
    Two_HoursClose = 0;
    Two_HoursUp = 0;
    Two_HoursDown = 0;
    Two_HoursAggregationPeriod = 0;
}
AddLabel(TwoHourLabel and Two_HoursAggregationPeriod, " 2H ", if Two_HoursUp then GlobalColor("UP") else if Two_HoursDown then GlobalColor("DOWN") else Color.White);


## Hour Aggregation Period Variables

def HourOpen;
def HourClose;
def HourUp;
def HourDown;
def HourAggregationPeriod;
if getAggregationPeriod() <= AggregationPeriod.Hour {
    HourOpen = open(period = "1 Hour");
    HourClose = close(period = "1 Hour");
    HourUp = if HourClose > HourOpen then 1 else 0;
    HourDown = if HourClose < HourOpen then 1 else 0;
    HourAggregationPeriod = 1;
}
else {
    HourOpen = 0;
    HourClose = 0;
    HourUp = 0;
    HourDown = 0;
    HourAggregationPeriod = 0;
}
AddLabel(HourLabel and HourAggregationPeriod, " H ", if HourUp then GlobalColor("UP") else if HourDown then GlobalColor("DOWN") else Color.White);

## Thirty_Min Aggregation Period Variables

def Thirty_MinOpen;
def Thirty_MinClose;
def Thirty_MinUp;
def Thirty_MinDown;
def Thirty_MinAggregationPeriod;
if getAggregationPeriod() <= AggregationPeriod.Thirty_Min {
    Thirty_MinOpen = open(period = "30 Min");
    Thirty_MinClose = close(period = "30 Min");
    Thirty_MinUp = if Thirty_MinClose > Thirty_MinOpen then 1 else 0;
    Thirty_MinDown = if Thirty_MinClose < Thirty_MinOpen then 1 else 0;
    Thirty_MinAggregationPeriod = 1;
}
else {
    Thirty_MinOpen = 0;
    Thirty_MinClose = 0;
    Thirty_MinUp = 0;
    Thirty_MinDown = 0;
    Thirty_MinAggregationPeriod = 0;
}
AddLabel(ThirtyMinLabel and Thirty_MinAggregationPeriod, " 30M ", if Thirty_MinUp then GlobalColor("UP") else if Thirty_MinDown then GlobalColor("DOWN") else Color.White);

## Fifteen_Min Aggregation Period Variables

def Fifteen_MinOpen;
def Fifteen_MinClose;
def Fifteen_MinUp;
def Fifteen_MinDown;
def Fifteen_MinAggregationPeriod;
if getAggregationPeriod() <= AggregationPeriod.Fifteen_Min {
    Fifteen_MinOpen = open(period = "15 Min");
    Fifteen_MinClose = close(period = "15 Min");
    Fifteen_MinUp = if Fifteen_MinClose > Fifteen_MinOpen then 1 else 0;
    Fifteen_MinDown = if Fifteen_MinClose < Fifteen_MinOpen then 1 else 0;
    Fifteen_MinAggregationPeriod = 1;
}
else {
    Fifteen_MinOpen = 0;
    Fifteen_MinClose = 0;
    Fifteen_MinUp = 0;
    Fifteen_MinDown = 0;
    Fifteen_MinAggregationPeriod = 0;
}
AddLabel(FifteenMinLabel and Fifteen_MinAggregationPeriod, " 15M ", if Fifteen_MinUp then GlobalColor("UP") else if Fifteen_MinDown then GlobalColor("DOWN") else Color.White);

## Five_Min Aggregation Period Variables

def Five_MinOpen;
def Five_MinClose;
def Five_MinUp;
def Five_MinDown;
def Five_MinAggregationPeriod;
if getAggregationPeriod() <= AggregationPeriod.Five_Min {
    Five_MinOpen = open(period = "5 Min");
    Five_MinClose = close(period = "5 Min");
    Five_MinUp = if Five_MinClose > Five_MinOpen then 1 else 0;
    Five_MinDown = if Five_MinClose < Five_MinOpen then 1 else 0;
    Five_MinAggregationPeriod = 1;
}
else {
    Five_MinOpen = 0;
    Five_MinClose = 0;
    Five_MinUp = 0;
    Five_MinDown = 0;
    Five_MinAggregationPeriod = 0;
}
AddLabel(FiveMinLabel and Five_MinAggregationPeriod, " 5M ", if Five_MinUp then GlobalColor("UP") else if Five_MinDown then GlobalColor("DOWN") else Color.White);

## One_Min Aggregation Period Variables

def One_MinOpen;
def One_MinClose;
def One_MinUp;
def One_MinDown;
def One_MinAggregationPeriod;
if getAggregationPeriod() <= AggregationPeriod.MIN {
    One_MinOpen = open(period = "1 Min");
    One_MinClose = close(period = "1 Min");
    One_MinUp = if One_MinClose > One_MinOpen then 1 else 0;
    One_MinDown = if One_MinClose < One_MinOpen then 1 else 0;
    One_MinAggregationPeriod = 1;
}
else {
    One_MinOpen = 0;
    One_MinClose = 0;
    One_MinUp = 0;
    One_MinDown = 0;
    One_MinAggregationPeriod = 0;
}
AddLabel(OneMinLabel and One_MinAggregationPeriod, " 1M ", if One_MinUp then GlobalColor("UP") else if One_MinDown then GlobalColor("DOWN") else Color.White);


uDoSBhg.png
 
Last edited:
Thank you again, will test it.

@caseyjbrett The 10x are for trend correct.
Finally, here's the MTF DMI Labels Script by TOS Indicators.

Code:
#TOS Indicators
#Home of the Volatility Box
#Full tutorial here: tosindicators.com/indicators/mtf-dmi
#Contains code written by Hubert Senters and Pete Hahn https://futures.io/thinkorswim/34885-help-adx-dmi-2.html

#Update notes:
#11/21/19 - Colored candles fixed, ADXLength variable renamed to ADXLevels
#11/20/19 - Separated labels into separate conditions, to avoid label logic from confusing TOS.
#11/19/19 - Logic behind bullish, bearish and neutral zones updated, thanks to member feedback. More detail available in DMI Power Scans tutorial video.
#11/14/19 - Arrows are not added to the current version of the code, only colored candles


input coloredCandlesOn = yes;
input length = 14;
input ADXLevels = 20;
input averageType = AverageType.WILDERS;



def monthPlus;
def monthMinus;
def monthAdx;

def monthBullishSignal;
def monthBearishSignal;


def monthBullishZone;
def monthBearishZone;
def monthNeutralZone;

def monthHiDiff;
def monthLoDiff;
def monthPlusDM;
def monthMinusDM;
def monthDX;
if GetAggregationPeriod() <= AggregationPeriod.month{

    monthHiDiff = high(period = "Month") - high(period = "Month")[1];
    monthLoDiff = low(period = "Month")[1] - low(period = "Month");
    monthPlusDM = if monthHiDiff > monthLoDiff and monthHiDiff > 0 then monthHiDiff else 0;
    monthMinusDM =  if monthLoDiff > monthHiDiff and monthLoDiff > 0 then monthLoDiff else 0;
    monthPlus = 100 * MovingAverage(averageType, monthPlusDM, length);
    monthMinus = 100 * MovingAverage(averageType, monthMinusDM, length);
    monthBullishSignal = monthPlus crosses above monthMinus;
    monthBearishSignal = monthPlus crosses below monthMinus;

    monthDX = if (monthPlus + monthMinus > 0) then 100 * AbsValue(monthPlus - monthMinus) / (monthPlus + monthMinus) else 0;
    monthAdx = MovingAverage(averageType, monthDX, length);

    monthBullishZone = monthPlus > monthMinus and monthADX >= ADXLevels;
    monthBearishZone = monthPlus < monthMinus and monthADX >= ADXLevels;
    monthNeutralZone = !monthBullishZone and !monthBearishZone;

}
else {
    monthPlus = 0;
    monthMinus = 0;
    monthAdx = 0;
    monthPlusDM = 0;
    monthMinusDM = 0;
    monthBullishSignal = 0;
    monthBearishSignal = 0;
    monthDX = 0;

    monthBullishZone = 0;
    monthBearishZone = 0;
    monthNeutralZone = 0;

    monthHiDiff = 0;
    monthLoDiff = 0;

}


AddLabel(monthBullishZone, "DI:M", color.green); AddLabel(monthBearishZone, "DI:M", color.red); AddLabel(monthNeutralZone, "DI:M", color.yellow);




def weekPlus;
def weekMinus;
def weekAdx;

def weekBullishSignal;
def weekBearishSignal;


def weekBullishZone;
def weekBearishZone;
def weekNeutralZone;

def weekHiDiff;
def weekLoDiff;
def weekPlusDM;
def weekMinusDM;
def weekDX;
if GetAggregationPeriod() <= AggregationPeriod.week{

    weekHiDiff = high(period = "week") - high(period = "week")[1];
    weekLoDiff = low(period = "week")[1] - low(period = "week");
    weekPlusDM = if weekHiDiff > weekLoDiff and weekHiDiff > 0 then weekHiDiff else 0;
    weekMinusDM =  if weekLoDiff > weekHiDiff and weekLoDiff > 0 then weekLoDiff else 0;
    weekPlus = 100 * MovingAverage(averageType, weekPlusDM, length);
    weekMinus = 100 * MovingAverage(averageType, weekMinusDM, length);
    weekBullishSignal = weekPlus crosses above weekMinus;
    weekBearishSignal = weekPlus crosses below weekMinus;

    weekDX = if (weekPlus + weekMinus > 0) then 100 * AbsValue(weekPlus - weekMinus) / (weekPlus + weekMinus) else 0;
    weekAdx = MovingAverage(averageType, weekDX, length);

    weekBullishZone = weekPlus > weekMinus and weekADX >= ADXLevels;
    weekBearishZone = weekPlus < weekMinus and weekADX >= ADXLevels;
    weekNeutralZone = !weekBullishZone and !weekBearishZone;

}
else {
    weekPlus = 0;
    weekMinus = 0;
    weekAdx = 0;
    weekPlusDM = 0;
    weekMinusDM = 0;
    weekBullishSignal = 0;
    weekBearishSignal = 0;
    weekDX = 0;

    weekBullishZone = 0;
    weekBearishZone = 0;
    weekNeutralZone = 0;

    weekHiDiff = 0;
    weekLoDiff = 0;

}


AddLabel(weekBullishZone, "DI:W", color.green); AddLabel(weekBearishZone, "DI:W", color.red); AddLabel(weekNeutralZone, "DI:W", color.yellow);





def fourDaysPlus;
def fourDaysMinus;
def fourDaysAdx;

def fourDaysBullishSignal;
def fourDaysBearishSignal;


def fourDaysBullishZone;
def fourDaysBearishZone;
def fourDaysNeutralZone;

def fourDaysHiDiff;
def fourDaysLoDiff;
def fourDaysPlusDM;
def fourDaysMinusDM;
def fourDaysDX;
if GetAggregationPeriod() <= AggregationPeriod.four_Days{

    fourDaysHiDiff = high(period = "4 Days") - high(period = "4 Days")[1];
    fourDaysLoDiff = low(period = "4 Days")[1] - low(period = "4 Days");
    fourDaysPlusDM = if fourDaysHiDiff > fourDaysLoDiff and fourDaysHiDiff > 0 then fourDaysHiDiff else 0;
    fourDaysMinusDM =  if fourDaysLoDiff > fourDaysHiDiff and fourDaysLoDiff > 0 then fourDaysLoDiff else 0;
    fourDaysPlus = 100 * MovingAverage(averageType, fourDaysPlusDM, length);
    fourDaysMinus = 100 * MovingAverage(averageType, fourDaysMinusDM, length);
    fourDaysBullishSignal = fourDaysPlus crosses above fourDaysMinus;
    fourDaysBearishSignal = fourDaysPlus crosses below fourDaysMinus;

    fourDaysDX = if (fourDaysPlus + fourDaysMinus > 0) then 100 * AbsValue(fourDaysPlus - fourDaysMinus) / (fourDaysPlus + fourDaysMinus) else 0;
    fourDaysAdx = MovingAverage(averageType, fourDaysDX, length);

    fourDaysBullishZone = fourDaysPlus > fourDaysMinus and fourDaysADX >= ADXLevels;
    fourDaysBearishZone = fourDaysPlus < fourDaysMinus and fourDaysADX >= ADXLevels;
    fourDaysNeutralZone = !fourDaysBullishZone and !fourDaysBearishZone;

}
else {
    fourDaysPlus = 0;
    fourDaysMinus = 0;
    fourDaysAdx = 0;
    fourDaysPlusDM = 0;
    fourDaysMinusDM = 0;
    fourDaysBullishSignal = 0;
    fourDaysBearishSignal = 0;
    fourDaysDX = 0;

    fourDaysBullishZone = 0;
    fourDaysBearishZone = 0;
    fourDaysNeutralZone = 0;

    fourDaysHiDiff = 0;
    fourDaysLoDiff = 0;

}


AddLabel(fourDaysBullishZone, "DI:4D", color.green); AddLabel(fourDaysBearishZone, "DI:4D", color.red); AddLabel(fourDaysNeutralZone, "DI:4D", color.yellow);




def threeDaysPlus;
def threeDaysMinus;
def threeDaysAdx;

def threeDaysBullishSignal;
def threeDaysBearishSignal;


def threeDaysBullishZone;
def threeDaysBearishZone;
def threeDaysNeutralZone;

def threeDaysHiDiff;
def threeDaysLoDiff;
def threeDaysPlusDM;
def threeDaysMinusDM;
def threeDaysDX;
if GetAggregationPeriod() <= AggregationPeriod.three_Days{

    threeDaysHiDiff = high(period = "3 Days") - high(period = "3 Days")[1];
    threeDaysLoDiff = low(period = "3 Days")[1] - low(period = "3 Days");
    threeDaysPlusDM = if threeDaysHiDiff > threeDaysLoDiff and threeDaysHiDiff > 0 then threeDaysHiDiff else 0;
    threeDaysMinusDM =  if threeDaysLoDiff > threeDaysHiDiff and threeDaysLoDiff > 0 then threeDaysLoDiff else 0;
    threeDaysPlus = 100 * MovingAverage(averageType, threeDaysPlusDM, length);
    threeDaysMinus = 100 * MovingAverage(averageType, threeDaysMinusDM, length);
    threeDaysBullishSignal = threeDaysPlus crosses above threeDaysMinus;
    threeDaysBearishSignal = threeDaysPlus crosses below threeDaysMinus;

    threeDaysDX = if (threeDaysPlus + threeDaysMinus > 0) then 100 * AbsValue(threeDaysPlus - threeDaysMinus) / (threeDaysPlus + threeDaysMinus) else 0;
    threeDaysAdx = MovingAverage(averageType, threeDaysDX, length);

    threeDaysBullishZone = threeDaysPlus > threeDaysMinus and threeDaysADX >= ADXLevels;
    threeDaysBearishZone = threeDaysPlus < threeDaysMinus and threeDaysADX >= ADXLevels;
    threeDaysNeutralZone = !threeDaysBullishZone and !threeDaysBearishZone;

}
else {
    threeDaysPlus = 0;
    threeDaysMinus = 0;
    threeDaysAdx = 0;
    threeDaysPlusDM = 0;
    threeDaysMinusDM = 0;
    threeDaysBullishSignal = 0;
    threeDaysBearishSignal = 0;
    threeDaysDX = 0;

    threeDaysBullishZone = 0;
    threeDaysBearishZone = 0;
    threeDaysNeutralZone = 0;

    threeDaysHiDiff = 0;
    threeDaysLoDiff = 0;

}


AddLabel(threeDaysBullishZone, "DI:3D", color.green); AddLabel(threeDaysBearishZone, "DI:3D", color.red); AddLabel(threeDaysNeutralZone, "DI:3D", color.yellow);




def twoDaysPlus;
def twoDaysMinus;
def twoDaysAdx;

def twoDaysBullishSignal;
def twoDaysBearishSignal;


def twoDaysBullishZone;
def twoDaysBearishZone;
def twoDaysNeutralZone;

def twoDaysHiDiff;
def twoDaysLoDiff;
def twoDaysPlusDM;
def twoDaysMinusDM;
def twoDaysDX;
if GetAggregationPeriod() <= AggregationPeriod.two_Days{

    twoDaysHiDiff = high(period = "2 Days") - high(period = "2 Days")[1];
    twoDaysLoDiff = low(period = "2 Days")[1] - low(period = "2 Days");
    twoDaysPlusDM = if twoDaysHiDiff > twoDaysLoDiff and twoDaysHiDiff > 0 then twoDaysHiDiff else 0;
    twoDaysMinusDM =  if twoDaysLoDiff > twoDaysHiDiff and twoDaysLoDiff > 0 then twoDaysLoDiff else 0;
    twoDaysPlus = 100 * MovingAverage(averageType, twoDaysPlusDM, length);
    twoDaysMinus = 100 * MovingAverage(averageType, twoDaysMinusDM, length);
    twoDaysBullishSignal = twoDaysPlus crosses above twoDaysMinus;
    twoDaysBearishSignal = twoDaysPlus crosses below twoDaysMinus;

    twoDaysDX = if (twoDaysPlus + twoDaysMinus > 0) then 100 * AbsValue(twoDaysPlus - twoDaysMinus) / (twoDaysPlus + twoDaysMinus) else 0;
    twoDaysAdx = MovingAverage(averageType, twoDaysDX, length);

    twoDaysBullishZone = twoDaysPlus > twoDaysMinus and twoDaysADX >= ADXLevels;
    twoDaysBearishZone = twoDaysPlus < twoDaysMinus and twoDaysADX >= ADXLevels;
    twoDaysNeutralZone = !twoDaysBullishZone and !twoDaysBearishZone;

}
else {
    twoDaysPlus = 0;
    twoDaysMinus = 0;
    twoDaysAdx = 0;
    twoDaysPlusDM = 0;
    twoDaysMinusDM = 0;
    twoDaysBullishSignal = 0;
    twoDaysBearishSignal = 0;
    twoDaysDX = 0;

    twoDaysBullishZone = 0;
    twoDaysBearishZone = 0;
    twoDaysNeutralZone = 0;

    twoDaysHiDiff = 0;
    twoDaysLoDiff = 0;

}


AddLabel(twoDaysBullishZone, "DI:2D", color.green); AddLabel(twoDaysBearishZone, "DI:2D", color.red); AddLabel(twoDaysNeutralZone, "DI:2D", color.yellow);



def DayPlus;
def DayMinus;
def DayAdx;

def DayBullishSignal;
def DayBearishSignal;


def DayBullishZone;
def DayBearishZone;
def DayNeutralZone;

def DayHiDiff;
def DayLoDiff;
def DayPlusDM;
def DayMinusDM;
def DayDX;
if GetAggregationPeriod() <= AggregationPeriod.Day{

    DayHiDiff = high(period = "Day") - high(period = "Day")[1];
    DayLoDiff = low(period = "Day")[1] - low(period = "Day");
    DayPlusDM = if DayHiDiff > DayLoDiff and DayHiDiff > 0 then DayHiDiff else 0;
    DayMinusDM =  if DayLoDiff > DayHiDiff and DayLoDiff > 0 then DayLoDiff else 0;
    DayPlus = 100 * MovingAverage(averageType, DayPlusDM, length);
    DayMinus = 100 * MovingAverage(averageType, DayMinusDM, length);
    DayBullishSignal = DayPlus crosses above DayMinus;
    DayBearishSignal = DayPlus crosses below DayMinus;

    DayDX = if (DayPlus + DayMinus > 0) then 100 * AbsValue(DayPlus - DayMinus) / (DayPlus + DayMinus) else 0;
    DayAdx = MovingAverage(averageType, DayDX, length);

    DayBullishZone = DayPlus > DayMinus and DayADX >= ADXLevels;
    DayBearishZone = DayPlus < DayMinus and DayADX >= ADXLevels;
    DayNeutralZone = !DayBullishZone and !DayBearishZone;

}
else {
    DayPlus = 0;
    DayMinus = 0;
    DayAdx = 0;
    DayPlusDM = 0;
    DayMinusDM = 0;
    DayBullishSignal = 0;
    DayBearishSignal = 0;
    DayDX = 0;

    DayBullishZone = 0;
    DayBearishZone = 0;
    DayNeutralZone = 0;

    DayHiDiff = 0;
    DayLoDiff = 0;

}


AddLabel(DayBullishZone, "DI:D", color.green); AddLabel(DayBearishZone, "DI:D", color.red); AddLabel(DayNeutralZone, "DI:D", color.yellow);






def fourHoursPlus;
def fourHoursMinus;
def fourHoursAdx;

def fourHoursBullishSignal;
def fourHoursBearishSignal;


def fourHoursBullishZone;
def fourHoursBearishZone;
def fourHoursNeutralZone;

def fourHoursHiDiff;
def fourHoursLoDiff;
def fourHoursPlusDM;
def fourHoursMinusDM;
def fourHoursDX;
if GetAggregationPeriod() <= AggregationPeriod.four_Hours{

    fourHoursHiDiff = high(period = "4 Hours") - high(period = "4 Hours")[1];
    fourHoursLoDiff = low(period = "4 Hours")[1] - low(period = "4 Hours");
    fourHoursPlusDM = if fourHoursHiDiff > fourHoursLoDiff and fourHoursHiDiff > 0 then fourHoursHiDiff else 0;
    fourHoursMinusDM =  if fourHoursLoDiff > fourHoursHiDiff and fourHoursLoDiff > 0 then fourHoursLoDiff else 0;
    fourHoursPlus = 100 * MovingAverage(averageType, fourHoursPlusDM, length);
    fourHoursMinus = 100 * MovingAverage(averageType, fourHoursMinusDM, length);
    fourHoursBullishSignal = fourHoursPlus crosses above fourHoursMinus;
    fourHoursBearishSignal = fourHoursPlus crosses below fourHoursMinus;

    fourHoursDX = if (fourHoursPlus + fourHoursMinus > 0) then 100 * AbsValue(fourHoursPlus - fourHoursMinus) / (fourHoursPlus + fourHoursMinus) else 0;
    fourHoursAdx = MovingAverage(averageType, fourHoursDX, length);

    fourHoursBullishZone = fourHoursPlus > fourHoursMinus and fourHoursADX >= ADXLevels;
    fourHoursBearishZone = fourHoursPlus < fourHoursMinus and fourHoursADX >= ADXLevels;
    fourHoursNeutralZone = !fourHoursBullishZone and !fourHoursBearishZone;

}
else {
    fourHoursPlus = 0;
    fourHoursMinus = 0;
    fourHoursAdx = 0;
    fourHoursPlusDM = 0;
    fourHoursMinusDM = 0;
    fourHoursBullishSignal = 0;
    fourHoursBearishSignal = 0;
    fourHoursDX = 0;

    fourHoursBullishZone = 0;
    fourHoursBearishZone = 0;
    fourHoursNeutralZone = 0;

    fourHoursHiDiff = 0;
    fourHoursLoDiff = 0;

}


AddLabel(fourHoursBullishZone, "DI:4H", color.green); AddLabel(fourHoursBearishZone, "DI:4H", color.red); AddLabel(fourHoursNeutralZone, "DI:4H", color.yellow);





def twoHoursPlus;
def twoHoursMinus;
def twoHoursAdx;

def twoHoursBullishSignal;
def twoHoursBearishSignal;


def twoHoursBullishZone;
def twoHoursBearishZone;
def twoHoursNeutralZone;

def twoHoursHiDiff;
def twoHoursLoDiff;
def twoHoursPlusDM;
def twoHoursMinusDM;
def twoHoursDX;
if GetAggregationPeriod() <= AggregationPeriod.two_Hours{

    twoHoursHiDiff = high(period = "2 Hours") - high(period = "2 Hours")[1];
    twoHoursLoDiff = low(period = "2 Hours")[1] - low(period = "2 Hours");
    twoHoursPlusDM = if twoHoursHiDiff > twoHoursLoDiff and twoHoursHiDiff > 0 then twoHoursHiDiff else 0;
    twoHoursMinusDM =  if twoHoursLoDiff > twoHoursHiDiff and twoHoursLoDiff > 0 then twoHoursLoDiff else 0;
    twoHoursPlus = 100 * MovingAverage(averageType, twoHoursPlusDM, length);
    twoHoursMinus = 100 * MovingAverage(averageType, twoHoursMinusDM, length);
    twoHoursBullishSignal = twoHoursPlus crosses above twoHoursMinus;
    twoHoursBearishSignal = twoHoursPlus crosses below twoHoursMinus;

    twoHoursDX = if (twoHoursPlus + twoHoursMinus > 0) then 100 * AbsValue(twoHoursPlus - twoHoursMinus) / (twoHoursPlus + twoHoursMinus) else 0;
    twoHoursAdx = MovingAverage(averageType, twoHoursDX, length);

    twoHoursBullishZone = twoHoursPlus > twoHoursMinus and twoHoursADX >= ADXLevels;
    twoHoursBearishZone = twoHoursPlus < twoHoursMinus and twoHoursADX >= ADXLevels;
    twoHoursNeutralZone = !twoHoursBullishZone and !twoHoursBearishZone;

}
else {
    twoHoursPlus = 0;
    twoHoursMinus = 0;
    twoHoursAdx = 0;
    twoHoursPlusDM = 0;
    twoHoursMinusDM = 0;
    twoHoursBullishSignal = 0;
    twoHoursBearishSignal = 0;
    twoHoursDX = 0;

    twoHoursBullishZone = 0;
    twoHoursBearishZone = 0;
    twoHoursNeutralZone = 0;

    twoHoursHiDiff = 0;
    twoHoursLoDiff = 0;

}


AddLabel(twoHoursBullishZone, "DI:2H", color.green); AddLabel(twoHoursBearishZone, "DI:2H", color.red); AddLabel(twoHoursNeutralZone, "DI:2H", color.yellow);



def HourPlus;
def HourMinus;
def HourAdx;

def HourBullishSignal;
def HourBearishSignal;


def HourBullishZone;
def HourBearishZone;
def HourNeutralZone;

def HourHiDiff;
def HourLoDiff;
def HourPlusDM;
def HourMinusDM;
def HourDX;
if GetAggregationPeriod() <= AggregationPeriod.Hour{

    HourHiDiff = high(period = "1 Hour") - high(period = "1 Hour")[1];
    HourLoDiff = low(period = "1 Hour")[1] - low(period = "1 Hour");
    HourPlusDM = if HourHiDiff > HourLoDiff and HourHiDiff > 0 then HourHiDiff else 0;
    HourMinusDM =  if HourLoDiff > HourHiDiff and HourLoDiff > 0 then HourLoDiff else 0;
    HourPlus = 100 * MovingAverage(averageType, HourPlusDM, length);
    HourMinus = 100 * MovingAverage(averageType, HourMinusDM, length);
    HourBullishSignal = HourPlus crosses above HourMinus;
    HourBearishSignal = HourPlus crosses below HourMinus;

    HourDX = if (HourPlus + HourMinus > 0) then 100 * AbsValue(HourPlus - HourMinus) / (HourPlus + HourMinus) else 0;
    HourAdx = MovingAverage(averageType, HourDX, length);

    HourBullishZone = HourPlus > HourMinus and HourADX >= ADXLevels;
    HourBearishZone = HourPlus < HourMinus and HourADX >= ADXLevels;
    HourNeutralZone = !HourBullishZone and !HourBearishZone;

}
else {
    HourPlus = 0;
    HourMinus = 0;
    HourAdx = 0;
    HourPlusDM = 0;
    HourMinusDM = 0;
    HourBullishSignal = 0;
    HourBearishSignal = 0;
    HourDX = 0;

    HourBullishZone = 0;
    HourBearishZone = 0;
    HourNeutralZone = 0;

    HourHiDiff = 0;
    HourLoDiff = 0;

}


AddLabel(HourBullishZone, "DI:1H", color.green); AddLabel(HourBearishZone, "DI:1H", color.red); AddLabel(HourNeutralZone, "DI:1H", color.yellow);

 

def thirtyMinPlus;
def thirtyMinMinus;
def thirtyMinAdx;

def thirtyMinBullishSignal;
def thirtyMinBearishSignal;


def thirtyMinBullishZone;
def thirtyMinBearishZone;
def thirtyMinNeutralZone;

def thirtyMinHiDiff;
def thirtyMinLoDiff;
def thirtyMinPlusDM;
def thirtyMinMinusDM;
def thirtyMinDX;
if GetAggregationPeriod() <= AggregationPeriod.thirty_Min{

    thirtyMinHiDiff = high(period = "30 Min") - high(period = "30 Min")[1];
    thirtyMinLoDiff = low(period = "30 Min")[1] - low(period = "30 Min");
    thirtyMinPlusDM = if thirtyMinHiDiff > thirtyMinLoDiff and thirtyMinHiDiff > 0 then thirtyMinHiDiff else 0;
    thirtyMinMinusDM =  if thirtyMinLoDiff > thirtyMinHiDiff and thirtyMinLoDiff > 0 then thirtyMinLoDiff else 0;
    thirtyMinPlus = 100 * MovingAverage(averageType, thirtyMinPlusDM, length);
    thirtyMinMinus = 100 * MovingAverage(averageType, thirtyMinMinusDM, length);
    thirtyMinBullishSignal = thirtyMinPlus crosses above thirtyMinMinus;
    thirtyMinBearishSignal = thirtyMinPlus crosses below thirtyMinMinus;

    thirtyMinDX = if (thirtyMinPlus + thirtyMinMinus > 0) then 100 * AbsValue(thirtyMinPlus - thirtyMinMinus) / (thirtyMinPlus + thirtyMinMinus) else 0;
    thirtyMinAdx = MovingAverage(averageType, thirtyMinDX, length);

    thirtyMinBullishZone = thirtyMinPlus > thirtyMinMinus and thirtyMinADX >= ADXLevels;
    thirtyMinBearishZone = thirtyMinPlus < thirtyMinMinus and thirtyMinADX >= ADXLevels;
    thirtyMinNeutralZone = !thirtyMinBullishZone and !thirtyMinBearishZone;

}
else {
    thirtyMinPlus = 0;
    thirtyMinMinus = 0;
    thirtyMinAdx = 0;
    thirtyMinPlusDM = 0;
    thirtyMinMinusDM = 0;
    thirtyMinBullishSignal = 0;
    thirtyMinBearishSignal = 0;
    thirtyMinDX = 0;

    thirtyMinBullishZone = 0;
    thirtyMinBearishZone = 0;
    thirtyMinNeutralZone = 0;

    thirtyMinHiDiff = 0;
    thirtyMinLoDiff = 0;

}


AddLabel(thirtyMinBullishZone, "DI:30m", color.green); AddLabel(thirtyMinBearishZone, "DI:30m", color.red); AddLabel(thirtyMinNeutralZone, "DI:30m", color.yellow);




def fifteenMinPlus;
def fifteenMinMinus;
def fifteenMinAdx;

def fifteenMinBullishSignal;
def fifteenMinBearishSignal;


def fifteenMinBullishZone;
def fifteenMinBearishZone;
def fifteenMinNeutralZone;

def fifteenMinHiDiff;
def fifteenMinLoDiff;
def fifteenMinPlusDM;
def fifteenMinMinusDM;
def fifteenMinDX;
if GetAggregationPeriod() <= AggregationPeriod.fifteen_Min{

    fifteenMinHiDiff = high(period = "15 Min") - high(period = "15 Min")[1];
    fifteenMinLoDiff = low(period = "15 Min")[1] - low(period = "15 Min");
    fifteenMinPlusDM = if fifteenMinHiDiff > fifteenMinLoDiff and fifteenMinHiDiff > 0 then fifteenMinHiDiff else 0;
    fifteenMinMinusDM =  if fifteenMinLoDiff > fifteenMinHiDiff and fifteenMinLoDiff > 0 then fifteenMinLoDiff else 0;
    fifteenMinPlus = 100 * MovingAverage(averageType, fifteenMinPlusDM, length);
    fifteenMinMinus = 100 * MovingAverage(averageType, fifteenMinMinusDM, length);
    fifteenMinBullishSignal = fifteenMinPlus crosses above fifteenMinMinus;
    fifteenMinBearishSignal = fifteenMinPlus crosses below fifteenMinMinus;

    fifteenMinDX = if (fifteenMinPlus + fifteenMinMinus > 0) then 100 * AbsValue(fifteenMinPlus - fifteenMinMinus) / (fifteenMinPlus + fifteenMinMinus) else 0;
    fifteenMinAdx = MovingAverage(averageType, fifteenMinDX, length);

    fifteenMinBullishZone = fifteenMinPlus > fifteenMinMinus and fifteenMinADX >= ADXLevels;
    fifteenMinBearishZone = fifteenMinPlus < fifteenMinMinus and fifteenMinADX >= ADXLevels;
    fifteenMinNeutralZone = !fifteenMinBullishZone and !fifteenMinBearishZone;

}
else {
    fifteenMinPlus = 0;
    fifteenMinMinus = 0;
    fifteenMinAdx = 0;
    fifteenMinPlusDM = 0;
    fifteenMinMinusDM = 0;
    fifteenMinBullishSignal = 0;
    fifteenMinBearishSignal = 0;
    fifteenMinDX = 0;

    fifteenMinBullishZone = 0;
    fifteenMinBearishZone = 0;
    fifteenMinNeutralZone = 0;

    fifteenMinHiDiff = 0;
    fifteenMinLoDiff = 0;

}


AddLabel(fifteenMinBullishZone, "DI:15m", color.green); AddLabel(fifteenMinBearishZone, "DI:15m", color.red); AddLabel(fifteenMinNeutralZone, "DI:15m", color.yellow);





def tenMinPlus;
def tenMinMinus;
def tenMinAdx;

def tenMinBullishSignal;
def tenMinBearishSignal;


def tenMinBullishZone;
def tenMinBearishZone;
def tenMinNeutralZone;

def tenMinHiDiff;
def tenMinLoDiff;
def tenMinPlusDM;
def tenMinMinusDM;
def tenMinDX;
if GetAggregationPeriod() <= AggregationPeriod.ten_Min{

    tenMinHiDiff = high(period = "10 Min") - high(period = "10 Min")[1];
    tenMinLoDiff = low(period = "10 Min")[1] - low(period = "10 Min");
    tenMinPlusDM = if tenMinHiDiff > tenMinLoDiff and tenMinHiDiff > 0 then tenMinHiDiff else 0;
    tenMinMinusDM =  if tenMinLoDiff > tenMinHiDiff and tenMinLoDiff > 0 then tenMinLoDiff else 0;
    tenMinPlus = 100 * MovingAverage(averageType, tenMinPlusDM, length);
    tenMinMinus = 100 * MovingAverage(averageType, tenMinMinusDM, length);
    tenMinBullishSignal = tenMinPlus crosses above tenMinMinus;
    tenMinBearishSignal = tenMinPlus crosses below tenMinMinus;

    tenMinDX = if (tenMinPlus + tenMinMinus > 0) then 100 * AbsValue(tenMinPlus - tenMinMinus) / (tenMinPlus + tenMinMinus) else 0;
    tenMinAdx = MovingAverage(averageType, tenMinDX, length);

    tenMinBullishZone = tenMinPlus > tenMinMinus and tenMinADX >= ADXLevels;
    tenMinBearishZone = tenMinPlus < tenMinMinus and tenMinADX >= ADXLevels;
    tenMinNeutralZone = !tenMinBullishZone and !tenMinBearishZone;

}
else {
    tenMinPlus = 0;
    tenMinMinus = 0;
    tenMinAdx = 0;
    tenMinPlusDM = 0;
    tenMinMinusDM = 0;
    tenMinBullishSignal = 0;
    tenMinBearishSignal = 0;
    tenMinDX = 0;

    tenMinBullishZone = 0;
    tenMinBearishZone = 0;
    tenMinNeutralZone = 0;

    tenMinHiDiff = 0;
    tenMinLoDiff = 0;

}


AddLabel(tenMinBullishZone, "DI:10m", color.green); AddLabel(tenMinBearishZone, "DI:10m", color.red); AddLabel(tenMinNeutralZone, "DI:10m", color.yellow);




def fiveMinPlus;
def fiveMinMinus;
def fiveMinAdx;

def fiveMinBullishSignal;
def fiveMinBearishSignal;


def fiveMinBullishZone;
def fiveMinBearishZone;
def fiveMinNeutralZone;

def fiveMinHiDiff;
def fiveMinLoDiff;
def fiveMinPlusDM;
def fiveMinMinusDM;
def fiveMinDX;
if GetAggregationPeriod() <= AggregationPeriod.five_Min{

    fiveMinHiDiff = high(period = "5 Min") - high(period = "5 Min")[1];
    fiveMinLoDiff = low(period = "5 Min")[1] - low(period = "5 Min");
    fiveMinPlusDM = if fiveMinHiDiff > fiveMinLoDiff and fiveMinHiDiff > 0 then fiveMinHiDiff else 0;
    fiveMinMinusDM =  if fiveMinLoDiff > fiveMinHiDiff and fiveMinLoDiff > 0 then fiveMinLoDiff else 0;
    fiveMinPlus = 100 * MovingAverage(averageType, fiveMinPlusDM, length);
    fiveMinMinus = 100 * MovingAverage(averageType, fiveMinMinusDM, length);
    fiveMinBullishSignal = fiveMinPlus crosses above fiveMinMinus;
    fiveMinBearishSignal = fiveMinPlus crosses below fiveMinMinus;

    fiveMinDX = if (fiveMinPlus + fiveMinMinus > 0) then 100 * AbsValue(fiveMinPlus - fiveMinMinus) / (fiveMinPlus + fiveMinMinus) else 0;
    fiveMinAdx = MovingAverage(averageType, fiveMinDX, length);

    fiveMinBullishZone = fiveMinPlus > fiveMinMinus and fiveMinADX >= ADXLevels;
    fiveMinBearishZone = fiveMinPlus < fiveMinMinus and fiveMinADX >= ADXLevels;
    fiveMinNeutralZone = !fiveMinBullishZone and !fiveMinBearishZone;

}
else {
    fiveMinPlus = 0;
    fiveMinMinus = 0;
    fiveMinAdx = 0;
    fiveMinPlusDM = 0;
    fiveMinMinusDM = 0;
    fiveMinBullishSignal = 0;
    fiveMinBearishSignal = 0;
    fiveMinDX = 0;

    fiveMinBullishZone = 0;
    fiveMinBearishZone = 0;
    fiveMinNeutralZone = 0;

    fiveMinHiDiff = 0;
    fiveMinLoDiff = 0;

}


AddLabel(fiveMinBullishZone, "DI:5m", color.green); AddLabel(fiveMinBearishZone, "DI:5m", color.red); AddLabel(fiveMinNeutralZone, "DI:5m", color.yellow);




def fourMinPlus;
def fourMinMinus;
def fourMinAdx;

def fourMinBullishSignal;
def fourMinBearishSignal;


def fourMinBullishZone;
def fourMinBearishZone;
def fourMinNeutralZone;

def fourMinHiDiff;
def fourMinLoDiff;
def fourMinPlusDM;
def fourMinMinusDM;
def fourMinDX;
if GetAggregationPeriod() <= AggregationPeriod.four_Min{

    fourMinHiDiff = high(period = "4 Min") - high(period = "4 Min")[1];
    fourMinLoDiff = low(period = "4 Min")[1] - low(period = "4 Min");
    fourMinPlusDM = if fourMinHiDiff > fourMinLoDiff and fourMinHiDiff > 0 then fourMinHiDiff else 0;
    fourMinMinusDM =  if fourMinLoDiff > fourMinHiDiff and fourMinLoDiff > 0 then fourMinLoDiff else 0;
    fourMinPlus = 100 * MovingAverage(averageType, fourMinPlusDM, length);
    fourMinMinus = 100 * MovingAverage(averageType, fourMinMinusDM, length);
    fourMinBullishSignal = fourMinPlus crosses above fourMinMinus;
    fourMinBearishSignal = fourMinPlus crosses below fourMinMinus;

    fourMinDX = if (fourMinPlus + fourMinMinus > 0) then 100 * AbsValue(fourMinPlus - fourMinMinus) / (fourMinPlus + fourMinMinus) else 0;
    fourMinAdx = MovingAverage(averageType, fourMinDX, length);

    fourMinBullishZone = fourMinPlus > fourMinMinus and fourMinADX >= ADXLevels;
    fourMinBearishZone = fourMinPlus < fourMinMinus and fourMinADX >= ADXLevels;
    fourMinNeutralZone = !fourMinBullishZone and !fourMinBearishZone;

}
else {
    fourMinPlus = 0;
    fourMinMinus = 0;
    fourMinAdx = 0;
    fourMinPlusDM = 0;
    fourMinMinusDM = 0;
    fourMinBullishSignal = 0;
    fourMinBearishSignal = 0;
    fourMinDX = 0;

    fourMinBullishZone = 0;
    fourMinBearishZone = 0;
    fourMinNeutralZone = 0;

    fourMinHiDiff = 0;
    fourMinLoDiff = 0;

}


AddLabel(fourMinBullishZone, "DI:4m", color.green); AddLabel(fourMinBearishZone, "DI:4m", color.red); AddLabel(fourMinNeutralZone, "DI:4m", color.yellow);




def threeMinPlus;
def threeMinMinus;
def threeMinAdx;

def threeMinBullishSignal;
def threeMinBearishSignal;


def threeMinBullishZone;
def threeMinBearishZone;
def threeMinNeutralZone;

def threeMinHiDiff;
def threeMinLoDiff;
def threeMinPlusDM;
def threeMinMinusDM;
def threeMinDX;
if GetAggregationPeriod() <= AggregationPeriod.three_Min{

    threeMinHiDiff = high(period = "3 Min") - high(period = "3 Min")[1];
    threeMinLoDiff = low(period = "3 Min")[1] - low(period = "3 Min");
    threeMinPlusDM = if threeMinHiDiff > threeMinLoDiff and threeMinHiDiff > 0 then threeMinHiDiff else 0;
    threeMinMinusDM =  if threeMinLoDiff > threeMinHiDiff and threeMinLoDiff > 0 then threeMinLoDiff else 0;
    threeMinPlus = 100 * MovingAverage(averageType, threeMinPlusDM, length);
    threeMinMinus = 100 * MovingAverage(averageType, threeMinMinusDM, length);
    threeMinBullishSignal = threeMinPlus crosses above threeMinMinus;
    threeMinBearishSignal = threeMinPlus crosses below threeMinMinus;

    threeMinDX = if (threeMinPlus + threeMinMinus > 0) then 100 * AbsValue(threeMinPlus - threeMinMinus) / (threeMinPlus + threeMinMinus) else 0;
    threeMinAdx = MovingAverage(averageType, threeMinDX, length);

    threeMinBullishZone = threeMinPlus > threeMinMinus and threeMinADX >= ADXLevels;
    threeMinBearishZone = threeMinPlus < threeMinMinus and threeMinADX >= ADXLevels;
    threeMinNeutralZone = !threeMinBullishZone and !threeMinBearishZone;

}
else {
    threeMinPlus = 0;
    threeMinMinus = 0;
    threeMinAdx = 0;
    threeMinPlusDM = 0;
    threeMinMinusDM = 0;
    threeMinBullishSignal = 0;
    threeMinBearishSignal = 0;
    threeMinDX = 0;

    threeMinBullishZone = 0;
    threeMinBearishZone = 0;
    threeMinNeutralZone = 0;

    threeMinHiDiff = 0;
    threeMinLoDiff = 0;

}


AddLabel(threeMinBullishZone, "DI:3m", color.green); AddLabel(threeMinBearishZone, "DI:3m", color.red); AddLabel(threeMinNeutralZone, "DI:3m", color.yellow);




def twoMinPlus;
def twoMinMinus;
def twoMinAdx;

def twoMinBullishSignal;
def twoMinBearishSignal;


def twoMinBullishZone;
def twoMinBearishZone;
def twoMinNeutralZone;

def twoMinHiDiff;
def twoMinLoDiff;
def twoMinPlusDM;
def twoMinMinusDM;
def twoMinDX;
if GetAggregationPeriod() <= AggregationPeriod.two_Min{

    twoMinHiDiff = high(period = "2 Min") - high(period = "2 Min")[1];
    twoMinLoDiff = low(period = "2 Min")[1] - low(period = "2 Min");
    twoMinPlusDM = if twoMinHiDiff > twoMinLoDiff and twoMinHiDiff > 0 then twoMinHiDiff else 0;
    twoMinMinusDM =  if twoMinLoDiff > twoMinHiDiff and twoMinLoDiff > 0 then twoMinLoDiff else 0;
    twoMinPlus = 100 * MovingAverage(averageType, twoMinPlusDM, length);
    twoMinMinus = 100 * MovingAverage(averageType, twoMinMinusDM, length);
    twoMinBullishSignal = twoMinPlus crosses above twoMinMinus;
    twoMinBearishSignal = twoMinPlus crosses below twoMinMinus;

    twoMinDX = if (twoMinPlus + twoMinMinus > 0) then 100 * AbsValue(twoMinPlus - twoMinMinus) / (twoMinPlus + twoMinMinus) else 0;
    twoMinAdx = MovingAverage(averageType, twoMinDX, length);

    twoMinBullishZone = twoMinPlus > twoMinMinus and twoMinADX >= ADXLevels;
    twoMinBearishZone = twoMinPlus < twoMinMinus and twoMinADX >= ADXLevels;
    twoMinNeutralZone = !twoMinBullishZone and !twoMinBearishZone;

}
else {
    twoMinPlus = 0;
    twoMinMinus = 0;
    twoMinAdx = 0;
    twoMinPlusDM = 0;
    twoMinMinusDM = 0;
    twoMinBullishSignal = 0;
    twoMinBearishSignal = 0;
    twoMinDX = 0;

    twoMinBullishZone = 0;
    twoMinBearishZone = 0;
    twoMinNeutralZone = 0;

    twoMinHiDiff = 0;
    twoMinLoDiff = 0;

}


AddLabel(twoMinBullishZone, "DI:2m", color.green); AddLabel(twoMinBearishZone, "DI:2m", color.red); AddLabel(twoMinNeutralZone, "DI:2m", color.yellow);





def MinPlus;
def MinMinus;
def MinAdx;

def MinBullishSignal;
def MinBearishSignal;


def MinBullishZone;
def MinBearishZone;
def MinNeutralZone;

def MinHiDiff;
def MinLoDiff;
def MinPlusDM;
def MinMinusDM;
def MinDX;
if GetAggregationPeriod() <= AggregationPeriod.Min{

    MinHiDiff = high(period = "1 Min") - high(period = "1 Min")[1];
    MinLoDiff = low(period = "1 Min")[1] - low(period = "1 Min");
    MinPlusDM = if MinHiDiff > MinLoDiff and MinHiDiff > 0 then MinHiDiff else 0;
    MinMinusDM =  if MinLoDiff > MinHiDiff and MinLoDiff > 0 then MinLoDiff else 0;
    MinPlus = 100 * MovingAverage(averageType, MinPlusDM, length);
    MinMinus = 100 * MovingAverage(averageType, MinMinusDM, length);
    MinBullishSignal = MinPlus crosses above MinMinus;
    MinBearishSignal = MinPlus crosses below MinMinus;

    MinDX = if (MinPlus + MinMinus > 0) then 100 * AbsValue(MinPlus - MinMinus) / (MinPlus + MinMinus) else 0;
    MinAdx = MovingAverage(averageType, MinDX, length);

    MinBullishZone = MinPlus > MinMinus and MinADX >= ADXLevels;
    MinBearishZone = MinPlus < MinMinus and MinADX >= ADXLevels;
    MinNeutralZone = !MinBullishZone and !MinBearishZone;

}
else {
    MinPlus = 0;
    MinMinus = 0;
    MinAdx = 0;
    MinPlusDM = 0;
    MinMinusDM = 0;
    MinBullishSignal = 0;
    MinBearishSignal = 0;
    MinDX = 0;

    MinBullishZone = 0;
    MinBearishZone = 0;
    MinNeutralZone = 0;

    MinHiDiff = 0;
    MinLoDiff = 0;

}


AddLabel(MinBullishZone, "DI:1m", color.green); AddLabel(MinBearishZone, "DI:1m", color.red); AddLabel(MinNeutralZone, "DI:1m", color.yellow);




def HiDiff = high - high[1];
def LoDiff = low[1] - low;
def PlusDM = if HiDiff > LoDiff and HiDiff > 0 then HiDiff else 0;
def MinusDM =  if LoDiff > HiDiff and LoDiff > 0 then LoDiff else 0;

def Plus = 100 * MovingAverage(averageType, PlusDM, length);
def Minus = 100 * MovingAverage(averageType, MinusDM, length);
def BullishSignal = Plus crosses above Minus;
def BearishSignal = Plus crosses below Minus;
def DX = if (Plus + Minus > 0) then 100 * AbsValue(Plus - Minus) / (Plus + Minus) else 0;
def Adx = MovingAverage(averageType, DX, length);

def BullishZone = Plus > Minus and ADX >= ADXLevels;
def BearishZone = Plus < Minus and ADX >= ADXLevels;
def NeutralZone = !BullishZone and !BearishZone;

AssignPriceColor(if coloredCandlesOn and NeutralZone then Color.YELLOW else if coloredCandlesOn and BullishZone then Color.GREEN else if coloredCandlesOn and BearishZone then Color.RED else Color.CURRENT);


gvTyinJ.png
 
Last edited:
Firstly - script much appreciated, on the Mutisqueeze labels, I seem to have the issue with the "ExtraSqueeze" staying red
this is what I currently have
AddLabel(OneMinLabel and one_minAggregationPeriod, "1m", if one_minExtraSqueeze then GlobalColor("ExtraSqueeze") else if one_minSqueeze then GlobalColor("Squeeze") else if one_minPreSqueeze then GlobalColor("PreSqueeze") else GlobalColor("No Squeeze"));

What am I missing?
 
Firstly - script much appreciated, on the Mutisqueeze labels, I seem to have the issue with the "ExtraSqueeze" staying red
this is what I currently have
AddLabel(OneMinLabel and one_minAggregationPeriod, "1m", if one_minExtraSqueeze then GlobalColor("ExtraSqueeze") else if one_minSqueeze then GlobalColor("Squeeze") else if one_minPreSqueeze then GlobalColor("PreSqueeze") else GlobalColor("No Squeeze"));

What am I missing?
You're welcome. I don't think this would have any impact on the colors, but, for whatever reason, your script lists the squeezes in a different order. See below. If it's not working for you, then I can only surmise that it's an issue on your end. The script works fine for me and everyone else that has downloaded it. Try restarting your application.

AddLabel(OneMinLabel and one_minAggregationPeriod, "1m", if one_minSqueeze then GlobalColor("Squeeze") else if one_minExtraSqueeze then GlobalColor("ExtraSqueeze") else if one_minPreSqueeze then GlobalColor("PreSqueeze") else GlobalColor("No Squeeze"));
 
i need some help im trying to play witrh a mtf Squeeze lable with squezze count but having truble with the count part, it dose not give me the count and stays on extra squeez. here is just the 30 min
Code:
#MTF SQUEEZE PRO LABELS
#BY: CASEY BRETT WITH THE USE OF CODE FROM: TOS Indicators
#combined dot/hist by ZIZ aka goingdark365
# original squeeze, red,
# "Pre-Squeeze"   orange,
# "Extra-Squeeze" yellow,
# no squeeze,     green BLK

##Global Variables
input length = 20;
def AlertLine = 1;
input nk = 1.5;
input nkHi = 2;
input nkLo = 1;
def nBB = 2;
input averageType = AverageType.simple;
def displace = 0;
input trueRangeAverageType = AverageType.SIMPLE;

##
input price = close;
input momolength = 20;
input momoaverageType = AverageType.SIMPLE;


def K = (Highest(high, momolength) + Lowest(low, momolength)) /2 + ExpAverage(close, momolength);
def momo = Inertia(price - K / 2, momolength);

def pos         = momo >= 0;
def neg         = momo < 0;
def up         = momo >= momo[1];
def dn         = momo < momo[1];

def PosUp = pos and up;
def PosDn = pos and dn;
def NegDn = neg and dn;
def NegUp = neg and up;




defineGlobalColor("PosUp", color.cyan);
defineGlobalColor("PosDn", color.blue);
defineGlobalColor("NegDn", color.red);
defineGlobalColor("NegUp", color.yellow);
defineGlobalColor("Neutral", color.gray);
##




input MonthLabel = yes;
input WeekLabel = yes;
input ThreeDayLabel = yes;
input TwoDayLabel = yes;
input DayLabel = yes;
input FourHourLabel = yes;
input HourLabel = yes;
input ThirtyMinLabel = yes;


DefineGlobalColor("ExtraSqueeze", Color.YELLOW);
DefineGlobalColor("Squeeze", Color.RED);
DefineGlobalColor("PreSqueeze", Color.dark_ORANGE);
DefineGlobalColor("NO Squeeze", Color.black);
#AddLabel(yes,("SQZ:"), Color.white);
## Month Aggregation Period Variables
def momothirty_minprice;
def momoKthirty_min;
def momothirty_minmomo;
Def momothirty_min_ExpAverage;
Def momothirty_minpos;
Def momothirty_minneg;
Def momothirty_minup;
Def momothirty_mindn;
Def momothirty_minPosUp;
Def momothirty_minPosDn;
Def momothirty_minNegDn;
Def momothirty_minNegUp;
Def momothirty_minAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.thirty_min {
    momothirty_minprice = close(period="30 Min");
    momoKthirty_min = (Highest(high(period="30 Min"), momolength) + Lowest(low(period="30 Min"), momolength)) /2 + ExpAverage(close(period="30 Min"), momolength);
    momothirty_minmomo = Inertia(momothirty_minprice- momokthirty_min / 2, momolength);
    momothirty_min_ExpAverage = ExpAverage(close(period="30 Min"), momoLength);
    momothirty_minpos = momothirty_minmomo >= 0;
    momothirty_minneg = momothirty_minmomo < 0;
    momothirty_minup  = momothirty_minmomo >= momothirty_minmomo[1];
    momothirty_mindn  = momothirty_minmomo < momothirty_minmomo[1];

    momothirty_minPosUp = momothirty_minpos and momothirty_minup;
    momothirty_minPosDn = momothirty_minpos and momothirty_mindn;
    momothirty_minNegDn = momothirty_minneg and momothirty_mindn;
    momothirty_minNegUp = momothirty_minneg and momothirty_minup;
    momothirty_minAggregationPeriod = 1;
}
Else {
    momothirty_minprice = 0;
    momoKthirty_min = 0;
    momothirty_minmomo = 0;
    momothirty_min_ExpAverage = 0;
    momothirty_minpos = 0;
    momothirty_minneg = 0;
    momothirty_minup = 0;
    momothirty_mindn = 0;
    momothirty_minPosUp = 0;
    momothirty_minPosDn = 0;
    momothirty_minNegDn = 0;
    momothirty_minNegUp = 0;
    momothirty_minAggregationPeriod = 0;
}
AddLabel(ThirtyMinLabel and momothirty_minAggregationPeriod, "30m", if momothirty_minPosUp then globalColor("PosUp") else if momothirty_minPosDn then globalColor("PosDn") else if momothirty_minNegDn then globalColor("NegDn") else if momothirty_minNegUp then globalColor("NegUp") else globalColor("Neutral"));
#





def Thirty_MinPrice;
def Thirty_MinATR;
def Thirty_MinSDev;
def Thirty_MinDenom;
def Thirty_MinDenomLo;
def Thirty_MinDenomHi;
def Thirty_MinBBSInd;
def Thirty_MinBBSIndLo;
def Thirty_MinBBSIndHi;
def Thirty_MinSqueeze;
def Thirty_MinPreSqueeze;
def Thirty_MinExtraSqueeze;
def Thirty_MinAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.THIRTY_MIN {
    Thirty_MinPrice = close(period = "30 Min");
    Thirty_MinATR = Average(TrueRange(high (period = "30 Min"), close(period = "30 Min"), low(period = "30 Min")), length);
    Thirty_MinSDev = StDev(Thirty_MinPrice, length);
    Thirty_MinDenom = (nk * Thirty_MinATR);
    Thirty_MinDenomLo = (nkLo * Thirty_MinATR);
    Thirty_MinDenomHi = (nkHi * Thirty_MinATR);
    Thirty_MinBBSInd = If (Thirty_MinDenom <> 0, ((nBB * Thirty_MinSDev) / Thirty_MinDenom), 0);
    Thirty_MinBBSIndLo = If (Thirty_MinDenomLo <> 0, ((nBB * Thirty_MinSDev) / Thirty_MinDenomLo), 0);
    Thirty_MinBBSIndHi = If (Thirty_MinDenomHi <> 0, ((nBB * Thirty_MinSDev) / Thirty_MinDenomHi), 0);
    Thirty_MinSqueeze = if Thirty_MinBBSInd < AlertLine then 1 else 0;
    Thirty_MinPreSqueeze = if Thirty_MinBBSIndHi < AlertLine then 1 else 0;
    Thirty_MinExtraSqueeze = if Thirty_MinBBSIndLo < AlertLine then 1 else 0;
    Thirty_MinAggregationPeriod = 1;
}
else {
    Thirty_MinPrice = 0;
    Thirty_MinATR = 0;
    Thirty_MinSDev = 0;
    Thirty_MinDenom = 0;
    Thirty_MinDenomLo = 0;
    Thirty_MinDenomHi = 0;
    Thirty_MinBBSInd = 0;
    Thirty_MinBBSIndLo = 0;
    Thirty_MinBBSIndHi = 0;
    Thirty_MinSqueeze = 0;
    Thirty_MinPreSqueeze = 0;
    Thirty_MinExtraSqueeze = 0;
    Thirty_MinAggregationPeriod = 0;
}



def countThirty_MinExtraSqueeze = if Thirty_MinExtraSqueeze and !Thirty_MinExtraSqueeze[1] then 1 else countThirty_MinExtraSqueeze[1]+1;

def countThirty_MinSqueeze = if Thirty_MinSqueeze and ! Thirty_MinSqueeze[1] then 1 else countThirty_MinSqueeze[1]+1;

def countThirty_MinPreSqueeze = if  Thirty_MinPreSqueeze and ! Thirty_MinPreSqueeze[1] then 1 else countThirty_MinPreSqueeze[1]+1;


AddLabel(ThirtyMinLabel and Thirty_MinAggregationPeriod, "30m",
if Thirty_MinExtraSqueeze + countThirty_MinExtraSqueeze then GlobalColor("ExtraSqueeze")
else if Thirty_MinSqueeze + countThirty_MinSqueeze then GlobalColor("Squeeze")
else if Thirty_MinPreSqueeze + countThirty_MinPreSqueeze   then GlobalColor("PreSqueeze")

else GlobalColor("No Squeeze"));
 
i need some help im trying to play witrh a mtf Squeeze lable with squezze count but having truble with the count part, it dose not give me the count and stays on extra squeez. here is just the 30 min
Code:
#MTF SQUEEZE PRO LABELS
#BY: CASEY BRETT WITH THE USE OF CODE FROM: TOS Indicators
#combined dot/hist by ZIZ aka goingdark365
# original squeeze, red,
# "Pre-Squeeze"   orange,
# "Extra-Squeeze" yellow,
# no squeeze,     green BLK

##Global Variables
input length = 20;
def AlertLine = 1;
input nk = 1.5;
input nkHi = 2;
input nkLo = 1;
def nBB = 2;
input averageType = AverageType.simple;
def displace = 0;
input trueRangeAverageType = AverageType.SIMPLE;

##
input price = close;
input momolength = 20;
input momoaverageType = AverageType.SIMPLE;


def K = (Highest(high, momolength) + Lowest(low, momolength)) /2 + ExpAverage(close, momolength);
def momo = Inertia(price - K / 2, momolength);

def pos         = momo >= 0;
def neg         = momo < 0;
def up         = momo >= momo[1];
def dn         = momo < momo[1];

def PosUp = pos and up;
def PosDn = pos and dn;
def NegDn = neg and dn;
def NegUp = neg and up;




defineGlobalColor("PosUp", color.cyan);
defineGlobalColor("PosDn", color.blue);
defineGlobalColor("NegDn", color.red);
defineGlobalColor("NegUp", color.yellow);
defineGlobalColor("Neutral", color.gray);
##




input MonthLabel = yes;
input WeekLabel = yes;
input ThreeDayLabel = yes;
input TwoDayLabel = yes;
input DayLabel = yes;
input FourHourLabel = yes;
input HourLabel = yes;
input ThirtyMinLabel = yes;


DefineGlobalColor("ExtraSqueeze", Color.YELLOW);
DefineGlobalColor("Squeeze", Color.RED);
DefineGlobalColor("PreSqueeze", Color.dark_ORANGE);
DefineGlobalColor("NO Squeeze", Color.black);
#AddLabel(yes,("SQZ:"), Color.white);
## Month Aggregation Period Variables
def momothirty_minprice;
def momoKthirty_min;
def momothirty_minmomo;
Def momothirty_min_ExpAverage;
Def momothirty_minpos;
Def momothirty_minneg;
Def momothirty_minup;
Def momothirty_mindn;
Def momothirty_minPosUp;
Def momothirty_minPosDn;
Def momothirty_minNegDn;
Def momothirty_minNegUp;
Def momothirty_minAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.thirty_min {
    momothirty_minprice = close(period="30 Min");
    momoKthirty_min = (Highest(high(period="30 Min"), momolength) + Lowest(low(period="30 Min"), momolength)) /2 + ExpAverage(close(period="30 Min"), momolength);
    momothirty_minmomo = Inertia(momothirty_minprice- momokthirty_min / 2, momolength);
    momothirty_min_ExpAverage = ExpAverage(close(period="30 Min"), momoLength);
    momothirty_minpos = momothirty_minmomo >= 0;
    momothirty_minneg = momothirty_minmomo < 0;
    momothirty_minup  = momothirty_minmomo >= momothirty_minmomo[1];
    momothirty_mindn  = momothirty_minmomo < momothirty_minmomo[1];

    momothirty_minPosUp = momothirty_minpos and momothirty_minup;
    momothirty_minPosDn = momothirty_minpos and momothirty_mindn;
    momothirty_minNegDn = momothirty_minneg and momothirty_mindn;
    momothirty_minNegUp = momothirty_minneg and momothirty_minup;
    momothirty_minAggregationPeriod = 1;
}
Else {
    momothirty_minprice = 0;
    momoKthirty_min = 0;
    momothirty_minmomo = 0;
    momothirty_min_ExpAverage = 0;
    momothirty_minpos = 0;
    momothirty_minneg = 0;
    momothirty_minup = 0;
    momothirty_mindn = 0;
    momothirty_minPosUp = 0;
    momothirty_minPosDn = 0;
    momothirty_minNegDn = 0;
    momothirty_minNegUp = 0;
    momothirty_minAggregationPeriod = 0;
}
AddLabel(ThirtyMinLabel and momothirty_minAggregationPeriod, "30m", if momothirty_minPosUp then globalColor("PosUp") else if momothirty_minPosDn then globalColor("PosDn") else if momothirty_minNegDn then globalColor("NegDn") else if momothirty_minNegUp then globalColor("NegUp") else globalColor("Neutral"));
#





def Thirty_MinPrice;
def Thirty_MinATR;
def Thirty_MinSDev;
def Thirty_MinDenom;
def Thirty_MinDenomLo;
def Thirty_MinDenomHi;
def Thirty_MinBBSInd;
def Thirty_MinBBSIndLo;
def Thirty_MinBBSIndHi;
def Thirty_MinSqueeze;
def Thirty_MinPreSqueeze;
def Thirty_MinExtraSqueeze;
def Thirty_MinAggregationPeriod;

if GetAggregationPeriod() <= AggregationPeriod.THIRTY_MIN {
    Thirty_MinPrice = close(period = "30 Min");
    Thirty_MinATR = Average(TrueRange(high (period = "30 Min"), close(period = "30 Min"), low(period = "30 Min")), length);
    Thirty_MinSDev = StDev(Thirty_MinPrice, length);
    Thirty_MinDenom = (nk * Thirty_MinATR);
    Thirty_MinDenomLo = (nkLo * Thirty_MinATR);
    Thirty_MinDenomHi = (nkHi * Thirty_MinATR);
    Thirty_MinBBSInd = If (Thirty_MinDenom <> 0, ((nBB * Thirty_MinSDev) / Thirty_MinDenom), 0);
    Thirty_MinBBSIndLo = If (Thirty_MinDenomLo <> 0, ((nBB * Thirty_MinSDev) / Thirty_MinDenomLo), 0);
    Thirty_MinBBSIndHi = If (Thirty_MinDenomHi <> 0, ((nBB * Thirty_MinSDev) / Thirty_MinDenomHi), 0);
    Thirty_MinSqueeze = if Thirty_MinBBSInd < AlertLine then 1 else 0;
    Thirty_MinPreSqueeze = if Thirty_MinBBSIndHi < AlertLine then 1 else 0;
    Thirty_MinExtraSqueeze = if Thirty_MinBBSIndLo < AlertLine then 1 else 0;
    Thirty_MinAggregationPeriod = 1;
}
else {
    Thirty_MinPrice = 0;
    Thirty_MinATR = 0;
    Thirty_MinSDev = 0;
    Thirty_MinDenom = 0;
    Thirty_MinDenomLo = 0;
    Thirty_MinDenomHi = 0;
    Thirty_MinBBSInd = 0;
    Thirty_MinBBSIndLo = 0;
    Thirty_MinBBSIndHi = 0;
    Thirty_MinSqueeze = 0;
    Thirty_MinPreSqueeze = 0;
    Thirty_MinExtraSqueeze = 0;
    Thirty_MinAggregationPeriod = 0;
}



def countThirty_MinExtraSqueeze = if Thirty_MinExtraSqueeze and !Thirty_MinExtraSqueeze[1] then 1 else countThirty_MinExtraSqueeze[1]+1;

def countThirty_MinSqueeze = if Thirty_MinSqueeze and ! Thirty_MinSqueeze[1] then 1 else countThirty_MinSqueeze[1]+1;

def countThirty_MinPreSqueeze = if  Thirty_MinPreSqueeze and ! Thirty_MinPreSqueeze[1] then 1 else countThirty_MinPreSqueeze[1]+1;


AddLabel(ThirtyMinLabel and Thirty_MinAggregationPeriod, "30m",
if Thirty_MinExtraSqueeze + countThirty_MinExtraSqueeze then GlobalColor("ExtraSqueeze")
else if Thirty_MinSqueeze + countThirty_MinSqueeze then GlobalColor("Squeeze")
else if Thirty_MinPreSqueeze + countThirty_MinPreSqueeze   then GlobalColor("PreSqueeze")

else GlobalColor("No Squeeze"));

It appears that, within the label script, you have the count condition scripted in the last part of the label statement (the color conditions). Your count conditional statement should be coded in the middle section of the label script where you have the “30m” text. That way, if there’s a squeeze then the count (number) will be displayed within the label. I’m not 100% sure how to script what you’re trying to do. But, perhaps a veteran on here could be of more help.
 
It appears that, within the label script, you have the count condition scripted in the last part of the label statement (the color conditions). Your count conditional statement should be coded in the middle section of the label script where you have the “30m” text. That way, if there’s a squeeze then the count (number) will be displayed within the label. I’m not 100% sure how to script what you’re trying to do. But, perhaps a veteran on here could be of more help.
BOOM got it thank you, so combined all the count into one def and that seems to work

def countThirty = if Thirty_MinExtraSqueeze and !Thirty_MinExtraSqueeze[1] or Thirty_MinSqueeze and !Thirty_MinSqueeze[1] or Thirty_MinPreSqueeze and !Thirty_MinPreSqueeze [1] then 1 else countThirty[1]+1;

AddLabel(ThirtyMinLabel and Thirty_MinAggregationPeriod, "30m" + countThirty ,
if Thirty_MinExtraSqueeze then GlobalColor("ExtraSqueeze")
else if Thirty_MinSqueeze then GlobalColor("Squeeze")
else if Thirty_MinPreSqueeze then GlobalColor("PreSqueeze")

else GlobalColor("No Squeeze"));
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
421 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top