MTF 6-TF MA Stack Dashboard For ThinkOrSwim

Ajordan930

Member
VIP
I wanted a quick visual for stacked moving averages with the ability to look at either exponential or simple and modify timeframes. I only went out as far as an hour for options because I usually only scalp or intraday. Added in the ability to select another symbol so I can see QQQ and SPY at the same time. You can select 3 moving averages

1775241990712.png

mod note:
Use CasePurposeOperational Behavior
Higher‑Timeframe Trend ConfirmationEnsure 15m setups align with 30m and 1h structureTrade only when 4 of 6 or more timeframes show the same MA stack direction
Trade FilteringAvoid low‑probability or countertrend tradesMixed colors or fewer than 4 aligned timeframes signal no‑trade conditions
Trend Continuation TimingEnter pullbacks or continuation setups with structural supportUse new bull or bear alignment alerts as confirmation of synchronized trend
Reversal Trap AvoidancePrevent premature fading of trendsA reversal is valid only when multiple timeframes flip together, not when a single TF changes
Multi‑Timeframe CompressionSee 1m through 1h structure without opening multiple chartsTF1–TF6 grid provides a full trend map in one lower pane
Novice Trader GuidanceProvide a simple go or no‑go systemGreen alignment for long bias, red alignment for short bias, yellow or mixed means stand down

Code:
# =========================================================
# 6-TF MA STACK ALIGNMENT
# =========================================================

declare lower;

input customSymbol = "";
input averageType = {default Exponential, Simple};

input fastMA = 5;
input midMA = 13;
input slowMA = 21;

input tf1 = {default M1, M2, M3, M4, M5, M10, M15, M20, M30, H1};
input tf2 = {default M2, M1, M3, M4, M5, M10, M15, M20, M30, H1};
input tf3 = {default M3, M1, M2, M4, M5, M10, M15, M20, M30, H1};
input tf4 = {default M4, M1, M2, M3, M5, M10, M15, M20, M30, H1};
input tf5 = {default M5, M1, M2, M3, M4, M10, M15, M20, M30, H1};
input tf6 = {default M10, M1, M2, M3, M4, M5, M15, M20, M30, H1};

input minAlignment = 4;
input showAlert = yes;
input showLabels = yes;
input labelSize = FontSize.SMALL;
input labelLocation = Location.TOP_LEFT;

def useChart = customSymbol == "";

script stackState {
input c = close;
input f = 5;
input m = 13;
input s = 21;
input avgType = {default Exponential, Simple};

def fastLine;
def midLine;
def slowLine;

if avgType == avgType.Exponential then {
fastLine = ExpAverage(c, f);
midLine = ExpAverage(c, m);
slowLine = ExpAverage(c, s);
} else {
fastLine = Average(c, f);
midLine = Average(c, m);
slowLine = Average(c, s);
}

plot state =
if c > fastLine and fastLine > midLine and midLine > slowLine then 1
else if c < fastLine and fastLine < midLine and midLine < slowLine then -1
else 0;
}

# =============================
# TIMEFRAME CLOSE MAPPING
# =============================
def c1 =
if tf1 == tf1.M1 then (if useChart then close(period = AggregationPeriod.MIN) else close(symbol = customSymbol, period = AggregationPeriod.MIN))
else if tf1 == tf1.M2 then (if useChart then close(period = AggregationPeriod.TWO_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TWO_MIN))
else if tf1 == tf1.M3 then (if useChart then close(period = AggregationPeriod.THREE_MIN) else close(symbol = customSymbol, period = AggregationPeriod.THREE_MIN))
else if tf1 == tf1.M4 then (if useChart then close(period = AggregationPeriod.FOUR_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FOUR_MIN))
else if tf1 == tf1.M5 then (if useChart then close(period = AggregationPeriod.FIVE_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FIVE_MIN))
else if tf1 == tf1.M10 then (if useChart then close(period = AggregationPeriod.TEN_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TEN_MIN))
else if tf1 == tf1.M15 then (if useChart then close(period = AggregationPeriod.FIFTEEN_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FIFTEEN_MIN))
else if tf1 == tf1.M20 then (if useChart then close(period = AggregationPeriod.TWENTY_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TWENTY_MIN))
else if tf1 == tf1.M30 then (if useChart then close(period = AggregationPeriod.THIRTY_MIN) else close(symbol = customSymbol, period = AggregationPeriod.THIRTY_MIN))
else (if useChart then close(period = AggregationPeriod.HOUR) else close(symbol = customSymbol, period = AggregationPeriod.HOUR));

def c2 =
if tf2 == tf2.M1 then (if useChart then close(period = AggregationPeriod.MIN) else close(symbol = customSymbol, period = AggregationPeriod.MIN))
else if tf2 == tf2.M2 then (if useChart then close(period = AggregationPeriod.TWO_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TWO_MIN))
else if tf2 == tf2.M3 then (if useChart then close(period = AggregationPeriod.THREE_MIN) else close(symbol = customSymbol, period = AggregationPeriod.THREE_MIN))
else if tf2 == tf2.M4 then (if useChart then close(period = AggregationPeriod.FOUR_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FOUR_MIN))
else if tf2 == tf2.M5 then (if useChart then close(period = AggregationPeriod.FIVE_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FIVE_MIN))
else if tf2 == tf2.M10 then (if useChart then close(period = AggregationPeriod.TEN_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TEN_MIN))
else if tf2 == tf2.M15 then (if useChart then close(period = AggregationPeriod.FIFTEEN_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FIFTEEN_MIN))
else if tf2 == tf2.M20 then (if useChart then close(period = AggregationPeriod.TWENTY_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TWENTY_MIN))
else if tf2 == tf2.M30 then (if useChart then close(period = AggregationPeriod.THIRTY_MIN) else close(symbol = customSymbol, period = AggregationPeriod.THIRTY_MIN))
else (if useChart then close(period = AggregationPeriod.HOUR) else close(symbol = customSymbol, period = AggregationPeriod.HOUR));

def c3 =
if tf3 == tf3.M1 then (if useChart then close(period = AggregationPeriod.MIN) else close(symbol = customSymbol, period = AggregationPeriod.MIN))
else if tf3 == tf3.M2 then (if useChart then close(period = AggregationPeriod.TWO_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TWO_MIN))
else if tf3 == tf3.M3 then (if useChart then close(period = AggregationPeriod.THREE_MIN) else close(symbol = customSymbol, period = AggregationPeriod.THREE_MIN))
else if tf3 == tf3.M4 then (if useChart then close(period = AggregationPeriod.FOUR_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FOUR_MIN))
else if tf3 == tf3.M5 then (if useChart then close(period = AggregationPeriod.FIVE_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FIVE_MIN))
else if tf3 == tf3.M10 then (if useChart then close(period = AggregationPeriod.TEN_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TEN_MIN))
else if tf3 == tf3.M15 then (if useChart then close(period = AggregationPeriod.FIFTEEN_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FIFTEEN_MIN))
else if tf3 == tf3.M20 then (if useChart then close(period = AggregationPeriod.TWENTY_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TWENTY_MIN))
else if tf3 == tf3.M30 then (if useChart then close(period = AggregationPeriod.THIRTY_MIN) else close(symbol = customSymbol, period = AggregationPeriod.THIRTY_MIN))
else (if useChart then close(period = AggregationPeriod.HOUR) else close(symbol = customSymbol, period = AggregationPeriod.HOUR));

def c4 =
if tf4 == tf4.M1 then (if useChart then close(period = AggregationPeriod.MIN) else close(symbol = customSymbol, period = AggregationPeriod.MIN))
else if tf4 == tf4.M2 then (if useChart then close(period = AggregationPeriod.TWO_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TWO_MIN))
else if tf4 == tf4.M3 then (if useChart then close(period = AggregationPeriod.THREE_MIN) else close(symbol = customSymbol, period = AggregationPeriod.THREE_MIN))
else if tf4 == tf4.M4 then (if useChart then close(period = AggregationPeriod.FOUR_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FOUR_MIN))
else if tf4 == tf4.M5 then (if useChart then close(period = AggregationPeriod.FIVE_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FIVE_MIN))
else if tf4 == tf4.M10 then (if useChart then close(period = AggregationPeriod.TEN_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TEN_MIN))
else if tf4 == tf4.M15 then (if useChart then close(period = AggregationPeriod.FIFTEEN_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FIFTEEN_MIN))
else if tf4 == tf4.M20 then (if useChart then close(period = AggregationPeriod.TWENTY_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TWENTY_MIN))
else if tf4 == tf4.M30 then (if useChart then close(period = AggregationPeriod.THIRTY_MIN) else close(symbol = customSymbol, period = AggregationPeriod.THIRTY_MIN))
else (if useChart then close(period = AggregationPeriod.HOUR) else close(symbol = customSymbol, period = AggregationPeriod.HOUR));

def c5 =
if tf5 == tf5.M1 then (if useChart then close(period = AggregationPeriod.MIN) else close(symbol = customSymbol, period = AggregationPeriod.MIN))
else if tf5 == tf5.M2 then (if useChart then close(period = AggregationPeriod.TWO_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TWO_MIN))
else if tf5 == tf5.M3 then (if useChart then close(period = AggregationPeriod.THREE_MIN) else close(symbol = customSymbol, period = AggregationPeriod.THREE_MIN))
else if tf5 == tf5.M4 then (if useChart then close(period = AggregationPeriod.FOUR_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FOUR_MIN))
else if tf5 == tf5.M5 then (if useChart then close(period = AggregationPeriod.FIVE_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FIVE_MIN))
else if tf5 == tf5.M10 then (if useChart then close(period = AggregationPeriod.TEN_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TEN_MIN))
else if tf5 == tf5.M15 then (if useChart then close(period = AggregationPeriod.FIFTEEN_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FIFTEEN_MIN))
else if tf5 == tf5.M20 then (if useChart then close(period = AggregationPeriod.TWENTY_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TWENTY_MIN))
else if tf5 == tf5.M30 then (if useChart then close(period = AggregationPeriod.THIRTY_MIN) else close(symbol = customSymbol, period = AggregationPeriod.THIRTY_MIN))
else (if useChart then close(period = AggregationPeriod.HOUR) else close(symbol = customSymbol, period = AggregationPeriod.HOUR));

def c6 =
if tf6 == tf6.M1 then (if useChart then close(period = AggregationPeriod.MIN) else close(symbol = customSymbol, period = AggregationPeriod.MIN))
else if tf6 == tf6.M2 then (if useChart then close(period = AggregationPeriod.TWO_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TWO_MIN))
else if tf6 == tf6.M3 then (if useChart then close(period = AggregationPeriod.THREE_MIN) else close(symbol = customSymbol, period = AggregationPeriod.THREE_MIN))
else if tf6 == tf6.M4 then (if useChart then close(period = AggregationPeriod.FOUR_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FOUR_MIN))
else if tf6 == tf6.M5 then (if useChart then close(period = AggregationPeriod.FIVE_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FIVE_MIN))
else if tf6 == tf6.M10 then (if useChart then close(period = AggregationPeriod.TEN_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TEN_MIN))
else if tf6 == tf6.M15 then (if useChart then close(period = AggregationPeriod.FIFTEEN_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FIFTEEN_MIN))
else if tf6 == tf6.M20 then (if useChart then close(period = AggregationPeriod.TWENTY_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TWENTY_MIN))
else if tf6 == tf6.M30 then (if useChart then close(period = AggregationPeriod.THIRTY_MIN) else close(symbol = customSymbol, period = AggregationPeriod.THIRTY_MIN))
else (if useChart then close(period = AggregationPeriod.HOUR) else close(symbol = customSymbol, period = AggregationPeriod.HOUR));

# =============================
# STATES
# =============================
def s1 = stackState(c1, fastMA, midMA, slowMA, averageType);
def s2 = stackState(c2, fastMA, midMA, slowMA, averageType);
def s3 = stackState(c3, fastMA, midMA, slowMA, averageType);
def s4 = stackState(c4, fastMA, midMA, slowMA, averageType);
def s5 = stackState(c5, fastMA, midMA, slowMA, averageType);
def s6 = stackState(c6, fastMA, midMA, slowMA, averageType);

# =============================
# ALIGNMENT
# =============================
def bullCount = (s1 == 1) + (s2 == 1) + (s3 == 1) + (s4 == 1) + (s5 == 1) + (s6 == 1);
def bearCount = (s1 == -1) + (s2 == -1) + (s3 == -1) + (s4 == -1) + (s5 == -1) + (s6 == -1);

def bullAlign = bullCount >= minAlignment;
def bearAlign = bearCount >= minAlignment;

def newBull = bullAlign and !bullAlign[1];
def newBear = bearAlign and !bearAlign[1];

# =============================
# ALERTS
# =============================
Alert(showAlert and newBull, "BULL ALIGNMENT (" + bullCount + "/6)", Alert.BAR, Sound.Ding);
Alert(showAlert and newBear, "BEAR ALIGNMENT (" + bearCount + "/6)", Alert.BAR, Sound.Ding);

# =============================
# GRID
# =============================
plot r6 = 6;
plot r5 = 5;
plot r4 = 4;
plot r3 = 3;
plot r2 = 2;
plot r1 = 1;

r6.SetPaintingStrategy(PaintingStrategy.POINTS);
r5.SetPaintingStrategy(PaintingStrategy.POINTS);
r4.SetPaintingStrategy(PaintingStrategy.POINTS);
r3.SetPaintingStrategy(PaintingStrategy.POINTS);
r2.SetPaintingStrategy(PaintingStrategy.POINTS);
r1.SetPaintingStrategy(PaintingStrategy.POINTS);

r6.SetLineWeight(5);
r5.SetLineWeight(5);
r4.SetLineWeight(5);
r3.SetLineWeight(5);
r2.SetLineWeight(5);
r1.SetLineWeight(5);

r6.AssignValueColor(if s6 == 1 then Color.GREEN else if s6 == -1 then Color.RED else Color.YELLOW);
r5.AssignValueColor(if s5 == 1 then Color.GREEN else if s5 == -1 then Color.RED else Color.YELLOW);
r4.AssignValueColor(if s4 == 1 then Color.GREEN else if s4 == -1 then Color.RED else Color.YELLOW);
r3.AssignValueColor(if s3 == 1 then Color.GREEN else if s3 == -1 then Color.RED else Color.YELLOW);
r2.AssignValueColor(if s2 == 1 then Color.GREEN else if s2 == -1 then Color.RED else Color.YELLOW);
r1.AssignValueColor(if s1 == 1 then Color.GREEN else if s1 == -1 then Color.RED else Color.YELLOW);

# =============================
# ANCHORS
# =============================
plot upperAnchor = 7;
plot lowerAnchor = 0;
upperAnchor.Hide();
lowerAnchor.Hide();

# =============================
# LABELS
# =============================
AddLabel(showLabels,
"SYM " + (if useChart then GetSymbol() else customSymbol),
Color.WHITE,
labelLocation, labelSize);

AddLabel(showLabels,
if averageType == averageType.Exponential then "EXP" else "SMA",
Color.WHITE,
labelLocation, labelSize);

AddLabel(showLabels,
"TF6 " +
(if tf6 == tf6.M1 then "1M"
else if tf6 == tf6.M2 then "2M"
else if tf6 == tf6.M3 then "3M"
else if tf6 == tf6.M4 then "4M"
else if tf6 == tf6.M5 then "5M"
else if tf6 == tf6.M10 then "10M"
else if tf6 == tf6.M15 then "15M"
else if tf6 == tf6.M20 then "20M"
else if tf6 == tf6.M30 then "30M"
else "1H"),
if s6 == 1 then Color.GREEN else if s6 == -1 then Color.RED else Color.YELLOW,
labelLocation, labelSize);

AddLabel(showLabels,
"TF5 " +
(if tf5 == tf5.M1 then "1M"
else if tf5 == tf5.M2 then "2M"
else if tf5 == tf5.M3 then "3M"
else if tf5 == tf5.M4 then "4M"
else if tf5 == tf5.M5 then "5M"
else if tf5 == tf5.M10 then "10M"
else if tf5 == tf5.M15 then "15M"
else if tf5 == tf5.M20 then "20M"
else if tf5 == tf5.M30 then "30M"
else "1H"),
if s5 == 1 then Color.GREEN else if s5 == -1 then Color.RED else Color.YELLOW,
labelLocation, labelSize);

AddLabel(showLabels,
"TF4 " +
(if tf4 == tf4.M1 then "1M"
else if tf4 == tf4.M2 then "2M"
else if tf4 == tf4.M3 then "3M"
else if tf4 == tf4.M4 then "4M"
else if tf4 == tf4.M5 then "5M"
else if tf4 == tf4.M10 then "10M"
else if tf4 == tf4.M15 then "15M"
else if tf4 == tf4.M20 then "20M"
else if tf4 == tf4.M30 then "30M"
else "1H"),
if s4 == 1 then Color.GREEN else if s4 == -1 then Color.RED else Color.YELLOW,
labelLocation, labelSize);

AddLabel(showLabels,
"TF3 " +
(if tf3 == tf3.M1 then "1M"
else if tf3 == tf3.M2 then "2M"
else if tf3 == tf3.M3 then "3M"
else if tf3 == tf3.M4 then "4M"
else if tf3 == tf3.M5 then "5M"
else if tf3 == tf3.M10 then "10M"
else if tf3 == tf3.M15 then "15M"
else if tf3 == tf3.M20 then "20M"
else if tf3 == tf3.M30 then "30M"
else "1H"),
if s3 == 1 then Color.GREEN else if s3 == -1 then Color.RED else Color.YELLOW,
labelLocation, labelSize);

AddLabel(showLabels,
"TF2 " +
(if tf2 == tf2.M1 then "1M"
else if tf2 == tf2.M2 then "2M"
else if tf2 == tf2.M3 then "3M"
else if tf2 == tf2.M4 then "4M"
else if tf2 == tf2.M5 then "5M"
else if tf2 == tf2.M10 then "10M"
else if tf2 == tf2.M15 then "15M"
else if tf2 == tf2.M20 then "20M"
else if tf2 == tf2.M30 then "30M"
else "1H"),
if s2 == 1 then Color.GREEN else if s2 == -1 then Color.RED else Color.YELLOW,
labelLocation, labelSize);

AddLabel(showLabels,
"TF1 " +
(if tf1 == tf1.M1 then "1M"
else if tf1 == tf1.M2 then "2M"
else if tf1 == tf1.M3 then "3M"
else if tf1 == tf1.M4 then "4M"
else if tf1 == tf1.M5 then "5M"
else if tf1 == tf1.M10 then "10M"
else if tf1 == tf1.M15 then "15M"
else if tf1 == tf1.M20 then "20M"
else if tf1 == tf1.M30 then "30M"
else "1H"),
if s1 == 1 then Color.GREEN else if s1 == -1 then Color.RED else Color.YELLOW,
labelLocation, labelSize);

AddLabel(showLabels,
if bullAlign then "BULL " + bullCount + "/6"
else if bearAlign then "BEAR " + bearCount + "/6"
else "MIXED",
if bullAlign then Color.GREEN else if bearAlign then Color.RED else Color.GRAY,
labelLocation, labelSize);

1775242026944.png
 
Last edited by a moderator:
I wanted a quick visual for stacked moving averages with the ability to look at either exponential or simple and modify timeframes. I only went out as far as an hour for options because I usually only scalp or intraday. Added in the ability to select another symbol so I can see QQQ and SPY at the same time. You can select 3 moving averages

View attachment 27308
mod note:
Use CasePurposeOperational Behavior
Higher‑Timeframe Trend ConfirmationEnsure 15m setups align with 30m and 1h structureTrade only when 4 of 6 or more timeframes show the same MA stack direction
Trade FilteringAvoid low‑probability or countertrend tradesMixed colors or fewer than 4 aligned timeframes signal no‑trade conditions
Trend Continuation TimingEnter pullbacks or continuation setups with structural supportUse new bull or bear alignment alerts as confirmation of synchronized trend
Reversal Trap AvoidancePrevent premature fading of trendsA reversal is valid only when multiple timeframes flip together, not when a single TF changes
Multi‑Timeframe CompressionSee 1m through 1h structure without opening multiple chartsTF1–TF6 grid provides a full trend map in one lower pane
Novice Trader GuidanceProvide a simple go or no‑go systemGreen alignment for long bias, red alignment for short bias, yellow or mixed means stand down

Code:
# =========================================================
# 6-TF MA STACK ALIGNMENT
# =========================================================

declare lower;

input customSymbol = "";
input averageType = {default Exponential, Simple};

input fastMA = 5;
input midMA = 13;
input slowMA = 21;

input tf1 = {default M1, M2, M3, M4, M5, M10, M15, M20, M30, H1};
input tf2 = {default M2, M1, M3, M4, M5, M10, M15, M20, M30, H1};
input tf3 = {default M3, M1, M2, M4, M5, M10, M15, M20, M30, H1};
input tf4 = {default M4, M1, M2, M3, M5, M10, M15, M20, M30, H1};
input tf5 = {default M5, M1, M2, M3, M4, M10, M15, M20, M30, H1};
input tf6 = {default M10, M1, M2, M3, M4, M5, M15, M20, M30, H1};

input minAlignment = 4;
input showAlert = yes;
input showLabels = yes;
input labelSize = FontSize.SMALL;
input labelLocation = Location.TOP_LEFT;

def useChart = customSymbol == "";

script stackState {
input c = close;
input f = 5;
input m = 13;
input s = 21;
input avgType = {default Exponential, Simple};

def fastLine;
def midLine;
def slowLine;

if avgType == avgType.Exponential then {
fastLine = ExpAverage(c, f);
midLine = ExpAverage(c, m);
slowLine = ExpAverage(c, s);
} else {
fastLine = Average(c, f);
midLine = Average(c, m);
slowLine = Average(c, s);
}

plot state =
if c > fastLine and fastLine > midLine and midLine > slowLine then 1
else if c < fastLine and fastLine < midLine and midLine < slowLine then -1
else 0;
}

# =============================
# TIMEFRAME CLOSE MAPPING
# =============================
def c1 =
if tf1 == tf1.M1 then (if useChart then close(period = AggregationPeriod.MIN) else close(symbol = customSymbol, period = AggregationPeriod.MIN))
else if tf1 == tf1.M2 then (if useChart then close(period = AggregationPeriod.TWO_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TWO_MIN))
else if tf1 == tf1.M3 then (if useChart then close(period = AggregationPeriod.THREE_MIN) else close(symbol = customSymbol, period = AggregationPeriod.THREE_MIN))
else if tf1 == tf1.M4 then (if useChart then close(period = AggregationPeriod.FOUR_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FOUR_MIN))
else if tf1 == tf1.M5 then (if useChart then close(period = AggregationPeriod.FIVE_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FIVE_MIN))
else if tf1 == tf1.M10 then (if useChart then close(period = AggregationPeriod.TEN_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TEN_MIN))
else if tf1 == tf1.M15 then (if useChart then close(period = AggregationPeriod.FIFTEEN_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FIFTEEN_MIN))
else if tf1 == tf1.M20 then (if useChart then close(period = AggregationPeriod.TWENTY_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TWENTY_MIN))
else if tf1 == tf1.M30 then (if useChart then close(period = AggregationPeriod.THIRTY_MIN) else close(symbol = customSymbol, period = AggregationPeriod.THIRTY_MIN))
else (if useChart then close(period = AggregationPeriod.HOUR) else close(symbol = customSymbol, period = AggregationPeriod.HOUR));

def c2 =
if tf2 == tf2.M1 then (if useChart then close(period = AggregationPeriod.MIN) else close(symbol = customSymbol, period = AggregationPeriod.MIN))
else if tf2 == tf2.M2 then (if useChart then close(period = AggregationPeriod.TWO_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TWO_MIN))
else if tf2 == tf2.M3 then (if useChart then close(period = AggregationPeriod.THREE_MIN) else close(symbol = customSymbol, period = AggregationPeriod.THREE_MIN))
else if tf2 == tf2.M4 then (if useChart then close(period = AggregationPeriod.FOUR_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FOUR_MIN))
else if tf2 == tf2.M5 then (if useChart then close(period = AggregationPeriod.FIVE_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FIVE_MIN))
else if tf2 == tf2.M10 then (if useChart then close(period = AggregationPeriod.TEN_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TEN_MIN))
else if tf2 == tf2.M15 then (if useChart then close(period = AggregationPeriod.FIFTEEN_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FIFTEEN_MIN))
else if tf2 == tf2.M20 then (if useChart then close(period = AggregationPeriod.TWENTY_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TWENTY_MIN))
else if tf2 == tf2.M30 then (if useChart then close(period = AggregationPeriod.THIRTY_MIN) else close(symbol = customSymbol, period = AggregationPeriod.THIRTY_MIN))
else (if useChart then close(period = AggregationPeriod.HOUR) else close(symbol = customSymbol, period = AggregationPeriod.HOUR));

def c3 =
if tf3 == tf3.M1 then (if useChart then close(period = AggregationPeriod.MIN) else close(symbol = customSymbol, period = AggregationPeriod.MIN))
else if tf3 == tf3.M2 then (if useChart then close(period = AggregationPeriod.TWO_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TWO_MIN))
else if tf3 == tf3.M3 then (if useChart then close(period = AggregationPeriod.THREE_MIN) else close(symbol = customSymbol, period = AggregationPeriod.THREE_MIN))
else if tf3 == tf3.M4 then (if useChart then close(period = AggregationPeriod.FOUR_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FOUR_MIN))
else if tf3 == tf3.M5 then (if useChart then close(period = AggregationPeriod.FIVE_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FIVE_MIN))
else if tf3 == tf3.M10 then (if useChart then close(period = AggregationPeriod.TEN_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TEN_MIN))
else if tf3 == tf3.M15 then (if useChart then close(period = AggregationPeriod.FIFTEEN_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FIFTEEN_MIN))
else if tf3 == tf3.M20 then (if useChart then close(period = AggregationPeriod.TWENTY_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TWENTY_MIN))
else if tf3 == tf3.M30 then (if useChart then close(period = AggregationPeriod.THIRTY_MIN) else close(symbol = customSymbol, period = AggregationPeriod.THIRTY_MIN))
else (if useChart then close(period = AggregationPeriod.HOUR) else close(symbol = customSymbol, period = AggregationPeriod.HOUR));

def c4 =
if tf4 == tf4.M1 then (if useChart then close(period = AggregationPeriod.MIN) else close(symbol = customSymbol, period = AggregationPeriod.MIN))
else if tf4 == tf4.M2 then (if useChart then close(period = AggregationPeriod.TWO_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TWO_MIN))
else if tf4 == tf4.M3 then (if useChart then close(period = AggregationPeriod.THREE_MIN) else close(symbol = customSymbol, period = AggregationPeriod.THREE_MIN))
else if tf4 == tf4.M4 then (if useChart then close(period = AggregationPeriod.FOUR_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FOUR_MIN))
else if tf4 == tf4.M5 then (if useChart then close(period = AggregationPeriod.FIVE_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FIVE_MIN))
else if tf4 == tf4.M10 then (if useChart then close(period = AggregationPeriod.TEN_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TEN_MIN))
else if tf4 == tf4.M15 then (if useChart then close(period = AggregationPeriod.FIFTEEN_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FIFTEEN_MIN))
else if tf4 == tf4.M20 then (if useChart then close(period = AggregationPeriod.TWENTY_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TWENTY_MIN))
else if tf4 == tf4.M30 then (if useChart then close(period = AggregationPeriod.THIRTY_MIN) else close(symbol = customSymbol, period = AggregationPeriod.THIRTY_MIN))
else (if useChart then close(period = AggregationPeriod.HOUR) else close(symbol = customSymbol, period = AggregationPeriod.HOUR));

def c5 =
if tf5 == tf5.M1 then (if useChart then close(period = AggregationPeriod.MIN) else close(symbol = customSymbol, period = AggregationPeriod.MIN))
else if tf5 == tf5.M2 then (if useChart then close(period = AggregationPeriod.TWO_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TWO_MIN))
else if tf5 == tf5.M3 then (if useChart then close(period = AggregationPeriod.THREE_MIN) else close(symbol = customSymbol, period = AggregationPeriod.THREE_MIN))
else if tf5 == tf5.M4 then (if useChart then close(period = AggregationPeriod.FOUR_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FOUR_MIN))
else if tf5 == tf5.M5 then (if useChart then close(period = AggregationPeriod.FIVE_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FIVE_MIN))
else if tf5 == tf5.M10 then (if useChart then close(period = AggregationPeriod.TEN_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TEN_MIN))
else if tf5 == tf5.M15 then (if useChart then close(period = AggregationPeriod.FIFTEEN_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FIFTEEN_MIN))
else if tf5 == tf5.M20 then (if useChart then close(period = AggregationPeriod.TWENTY_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TWENTY_MIN))
else if tf5 == tf5.M30 then (if useChart then close(period = AggregationPeriod.THIRTY_MIN) else close(symbol = customSymbol, period = AggregationPeriod.THIRTY_MIN))
else (if useChart then close(period = AggregationPeriod.HOUR) else close(symbol = customSymbol, period = AggregationPeriod.HOUR));

def c6 =
if tf6 == tf6.M1 then (if useChart then close(period = AggregationPeriod.MIN) else close(symbol = customSymbol, period = AggregationPeriod.MIN))
else if tf6 == tf6.M2 then (if useChart then close(period = AggregationPeriod.TWO_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TWO_MIN))
else if tf6 == tf6.M3 then (if useChart then close(period = AggregationPeriod.THREE_MIN) else close(symbol = customSymbol, period = AggregationPeriod.THREE_MIN))
else if tf6 == tf6.M4 then (if useChart then close(period = AggregationPeriod.FOUR_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FOUR_MIN))
else if tf6 == tf6.M5 then (if useChart then close(period = AggregationPeriod.FIVE_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FIVE_MIN))
else if tf6 == tf6.M10 then (if useChart then close(period = AggregationPeriod.TEN_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TEN_MIN))
else if tf6 == tf6.M15 then (if useChart then close(period = AggregationPeriod.FIFTEEN_MIN) else close(symbol = customSymbol, period = AggregationPeriod.FIFTEEN_MIN))
else if tf6 == tf6.M20 then (if useChart then close(period = AggregationPeriod.TWENTY_MIN) else close(symbol = customSymbol, period = AggregationPeriod.TWENTY_MIN))
else if tf6 == tf6.M30 then (if useChart then close(period = AggregationPeriod.THIRTY_MIN) else close(symbol = customSymbol, period = AggregationPeriod.THIRTY_MIN))
else (if useChart then close(period = AggregationPeriod.HOUR) else close(symbol = customSymbol, period = AggregationPeriod.HOUR));

# =============================
# STATES
# =============================
def s1 = stackState(c1, fastMA, midMA, slowMA, averageType);
def s2 = stackState(c2, fastMA, midMA, slowMA, averageType);
def s3 = stackState(c3, fastMA, midMA, slowMA, averageType);
def s4 = stackState(c4, fastMA, midMA, slowMA, averageType);
def s5 = stackState(c5, fastMA, midMA, slowMA, averageType);
def s6 = stackState(c6, fastMA, midMA, slowMA, averageType);

# =============================
# ALIGNMENT
# =============================
def bullCount = (s1 == 1) + (s2 == 1) + (s3 == 1) + (s4 == 1) + (s5 == 1) + (s6 == 1);
def bearCount = (s1 == -1) + (s2 == -1) + (s3 == -1) + (s4 == -1) + (s5 == -1) + (s6 == -1);

def bullAlign = bullCount >= minAlignment;
def bearAlign = bearCount >= minAlignment;

def newBull = bullAlign and !bullAlign[1];
def newBear = bearAlign and !bearAlign[1];

# =============================
# ALERTS
# =============================
Alert(showAlert and newBull, "BULL ALIGNMENT (" + bullCount + "/6)", Alert.BAR, Sound.Ding);
Alert(showAlert and newBear, "BEAR ALIGNMENT (" + bearCount + "/6)", Alert.BAR, Sound.Ding);

# =============================
# GRID
# =============================
plot r6 = 6;
plot r5 = 5;
plot r4 = 4;
plot r3 = 3;
plot r2 = 2;
plot r1 = 1;

r6.SetPaintingStrategy(PaintingStrategy.POINTS);
r5.SetPaintingStrategy(PaintingStrategy.POINTS);
r4.SetPaintingStrategy(PaintingStrategy.POINTS);
r3.SetPaintingStrategy(PaintingStrategy.POINTS);
r2.SetPaintingStrategy(PaintingStrategy.POINTS);
r1.SetPaintingStrategy(PaintingStrategy.POINTS);

r6.SetLineWeight(5);
r5.SetLineWeight(5);
r4.SetLineWeight(5);
r3.SetLineWeight(5);
r2.SetLineWeight(5);
r1.SetLineWeight(5);

r6.AssignValueColor(if s6 == 1 then Color.GREEN else if s6 == -1 then Color.RED else Color.YELLOW);
r5.AssignValueColor(if s5 == 1 then Color.GREEN else if s5 == -1 then Color.RED else Color.YELLOW);
r4.AssignValueColor(if s4 == 1 then Color.GREEN else if s4 == -1 then Color.RED else Color.YELLOW);
r3.AssignValueColor(if s3 == 1 then Color.GREEN else if s3 == -1 then Color.RED else Color.YELLOW);
r2.AssignValueColor(if s2 == 1 then Color.GREEN else if s2 == -1 then Color.RED else Color.YELLOW);
r1.AssignValueColor(if s1 == 1 then Color.GREEN else if s1 == -1 then Color.RED else Color.YELLOW);

# =============================
# ANCHORS
# =============================
plot upperAnchor = 7;
plot lowerAnchor = 0;
upperAnchor.Hide();
lowerAnchor.Hide();

# =============================
# LABELS
# =============================
AddLabel(showLabels,
"SYM " + (if useChart then GetSymbol() else customSymbol),
Color.WHITE,
labelLocation, labelSize);

AddLabel(showLabels,
if averageType == averageType.Exponential then "EXP" else "SMA",
Color.WHITE,
labelLocation, labelSize);

AddLabel(showLabels,
"TF6 " +
(if tf6 == tf6.M1 then "1M"
else if tf6 == tf6.M2 then "2M"
else if tf6 == tf6.M3 then "3M"
else if tf6 == tf6.M4 then "4M"
else if tf6 == tf6.M5 then "5M"
else if tf6 == tf6.M10 then "10M"
else if tf6 == tf6.M15 then "15M"
else if tf6 == tf6.M20 then "20M"
else if tf6 == tf6.M30 then "30M"
else "1H"),
if s6 == 1 then Color.GREEN else if s6 == -1 then Color.RED else Color.YELLOW,
labelLocation, labelSize);

AddLabel(showLabels,
"TF5 " +
(if tf5 == tf5.M1 then "1M"
else if tf5 == tf5.M2 then "2M"
else if tf5 == tf5.M3 then "3M"
else if tf5 == tf5.M4 then "4M"
else if tf5 == tf5.M5 then "5M"
else if tf5 == tf5.M10 then "10M"
else if tf5 == tf5.M15 then "15M"
else if tf5 == tf5.M20 then "20M"
else if tf5 == tf5.M30 then "30M"
else "1H"),
if s5 == 1 then Color.GREEN else if s5 == -1 then Color.RED else Color.YELLOW,
labelLocation, labelSize);

AddLabel(showLabels,
"TF4 " +
(if tf4 == tf4.M1 then "1M"
else if tf4 == tf4.M2 then "2M"
else if tf4 == tf4.M3 then "3M"
else if tf4 == tf4.M4 then "4M"
else if tf4 == tf4.M5 then "5M"
else if tf4 == tf4.M10 then "10M"
else if tf4 == tf4.M15 then "15M"
else if tf4 == tf4.M20 then "20M"
else if tf4 == tf4.M30 then "30M"
else "1H"),
if s4 == 1 then Color.GREEN else if s4 == -1 then Color.RED else Color.YELLOW,
labelLocation, labelSize);

AddLabel(showLabels,
"TF3 " +
(if tf3 == tf3.M1 then "1M"
else if tf3 == tf3.M2 then "2M"
else if tf3 == tf3.M3 then "3M"
else if tf3 == tf3.M4 then "4M"
else if tf3 == tf3.M5 then "5M"
else if tf3 == tf3.M10 then "10M"
else if tf3 == tf3.M15 then "15M"
else if tf3 == tf3.M20 then "20M"
else if tf3 == tf3.M30 then "30M"
else "1H"),
if s3 == 1 then Color.GREEN else if s3 == -1 then Color.RED else Color.YELLOW,
labelLocation, labelSize);

AddLabel(showLabels,
"TF2 " +
(if tf2 == tf2.M1 then "1M"
else if tf2 == tf2.M2 then "2M"
else if tf2 == tf2.M3 then "3M"
else if tf2 == tf2.M4 then "4M"
else if tf2 == tf2.M5 then "5M"
else if tf2 == tf2.M10 then "10M"
else if tf2 == tf2.M15 then "15M"
else if tf2 == tf2.M20 then "20M"
else if tf2 == tf2.M30 then "30M"
else "1H"),
if s2 == 1 then Color.GREEN else if s2 == -1 then Color.RED else Color.YELLOW,
labelLocation, labelSize);

AddLabel(showLabels,
"TF1 " +
(if tf1 == tf1.M1 then "1M"
else if tf1 == tf1.M2 then "2M"
else if tf1 == tf1.M3 then "3M"
else if tf1 == tf1.M4 then "4M"
else if tf1 == tf1.M5 then "5M"
else if tf1 == tf1.M10 then "10M"
else if tf1 == tf1.M15 then "15M"
else if tf1 == tf1.M20 then "20M"
else if tf1 == tf1.M30 then "30M"
else "1H"),
if s1 == 1 then Color.GREEN else if s1 == -1 then Color.RED else Color.YELLOW,
labelLocation, labelSize);

AddLabel(showLabels,
if bullAlign then "BULL " + bullCount + "/6"
else if bearAlign then "BEAR " + bearCount + "/6"
else "MIXED",
if bullAlign then Color.GREEN else if bearAlign then Color.RED else Color.GRAY,
labelLocation, labelSize);

View attachment 27309
AJordan can you share your grid?
 

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
832 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