this displays 10 MTF labels
each label represents a different aggregation time
each label compares the current bar close to the previous bar close
it will be green if current bar price is greater than previous bar price
can change the offset to previous bar. default is 1
if chart time is > than an aggregation time, the label is gray
if price of a bar is NAN then label is purple.
. (when chart doesn't have enough data for a big aggregation, like 1 min chart and agg of week)
MTF_price_chg_labels1
http://tos.mx/!CJ6pxyXv
each label represents a different aggregation time
each label compares the current bar close to the previous bar close
it will be green if current bar price is greater than previous bar price
can change the offset to previous bar. default is 1
if chart time is > than an aggregation time, the label is gray
if price of a bar is NAN then label is purple.
. (when chart doesn't have enough data for a big aggregation, like 1 min chart and agg of week)
MTF_price_chg_labels1
http://tos.mx/!CJ6pxyXv
Code:
#MTF_price_chg_labels1
def na = double.nan;
def bn = barnumber();
input price_change_offset = 1;
def o = price_change_offset;
input agg1 = AggregationPeriod.TWO_MIN;
input agg2 = AggregationPeriod.FIVE_MIN;
input agg3 = AggregationPeriod.TEN_MIN;
input agg4 = AggregationPeriod.FIFTEEN_MIN;
input agg5 = AggregationPeriod.thirty_MIN;
input agg6 = AggregationPeriod.hour;
input agg7 = AggregationPeriod.day;
input agg8 = AggregationPeriod.TWO_DAYS;
input agg9 = AggregationPeriod.THREE_DAYS;
input agg10 = AggregationPeriod.week;
def chartagg = getaggregationperiod();
def chartmin = chartagg/60000;
# adjust aggs if too small
def agg1b;
if agg1 >= chartagg then {
agg1b = agg1;
} else {
agg1b = chartagg;
}
def agg1min = agg1/60000;
def agg2b;
if agg2 >= chartagg then {
agg2b = agg2;
} else {
agg2b = chartagg;
}
def agg2min = agg2/60000;
def agg3b;
if agg3 >= chartagg then {
agg3b = agg3;
} else {
agg3b = chartagg;
}
def agg3min = agg3/60000;
def agg4b;
if agg4 >= chartagg then {
agg4b = agg4;
} else {
agg4b = chartagg;
}
def agg4min = agg4/60000;
def agg5b;
if agg5 >= chartagg then {
agg5b = agg5;
} else {
agg5b = chartagg;
}
def agg5min = agg5/60000;
def agg6b;
if agg6 >= chartagg then {
agg6b = agg6;
} else {
agg6b = chartagg;
}
def agg6min = agg6/60000;
def agg7b;
if agg7 >= chartagg then {
agg7b = agg7;
} else {
agg7b = chartagg;
}
def agg7min = agg7/60000;
def agg8b;
if agg8 >= chartagg then {
agg8b = agg8;
} else {
agg8b = chartagg;
}
def agg8min = agg8/60000;
def agg9b;
if agg9 >= chartagg then {
agg9b = agg9;
} else {
agg9b = chartagg;
}
def agg9min = agg9/60000;
def agg10b;
if agg10 >= chartagg then {
agg10b = agg10;
} else {
agg10b = chartagg;
}
def agg10min = agg10/60000;
def p1 = close(period = agg1b);
def p2 = close(period = agg2b);
def p3 = close(period = agg3b);
def p4 = close(period = agg4b);
def p5 = close(period = agg5b);
def p6 = close(period = agg6b);
def p7 = close(period = agg7b);
def p8 = close(period = agg8b);
def p9 = close(period = agg9b);
def p10 = close(period = agg10b);
def agg1up = (close(period = agg1b) > close(period = agg1b)[o]);
def agg2up = (close(period = agg2b) > close(period = agg2b)[o]);
def agg3up = (close(period = agg3b) > close(period = agg3b)[o]);
def agg4up = (close(period = agg4b) > close(period = agg4b)[o]);
def agg5up = (close(period = agg5b) > close(period = agg5b)[o]);
def agg6up = (close(period = agg6b) > close(period = agg6b)[o]);
def agg7up = (close(period = agg7b) > close(period = agg7b)[o]);
def agg8up = (close(period = agg8b) > close(period = agg8b)[o]);
def agg9up = (close(period = agg9b) > close(period = agg9b)[o]);
def agg10up = (close(period = agg10b) > close(period = agg10b)[o]);
#==================================
input show_labels = yes;
addlabel(show_labels, " ", color.black);
#addlabel(show_labels, "change in " + o + " bars", color.yellow);
#addlabel(show_labels, " ", color.black);
# MTF color labels
#https://usethinkscript.com/threads/the-multi-10x-mtf-labels-indicator-for-thinkorswim.1129/page-4#post-69106
AddLabel(show_labels,
(if agg1min < 60 then (agg1min + " m")
else if agg1min < 1440 then ((agg1min / 60) + " H")
else if agg1min < 10080 then (agg1min / (60 * 24) + " D")
else if agg1min == 10080 then "W"
else "--"),
(if isnan(p1) then color.magenta else if agg1 < chartagg then color.dark_gray else if agg1up then Color.GREEN else Color.RED));
AddLabel(show_labels,
(if agg2min < 60 then (agg2min + " m")
else if agg2min < 1440 then ((agg2min / 60) + " H")
else if agg2min < 10080 then (agg2min / (60 * 24) + " D")
else if agg2min == 10080 then "W"
else "--"),
(if isnan(p2) then color.magenta else if agg2 < chartagg then color.dark_gray else if agg2up then Color.GREEN else Color.RED));
AddLabel(show_labels,
(if agg3min < 60 then (agg3min + " m")
else if agg3min < 1440 then ((agg3min / 60) + " H")
else if agg3min < 10080 then (agg3min / (60 * 24) + " D")
else if agg3min == 10080 then "W"
else "--"),
(if isnan(p3) then color.magenta else if agg3 < chartagg then color.dark_gray else if agg3up then Color.GREEN else Color.RED));
AddLabel(show_labels,
(if agg4min < 60 then (agg4min + " m")
else if agg4min < 1440 then ((agg4min / 60) + " H")
else if agg4min < 10080 then (agg4min / (60 * 24) + " D")
else if agg4min == 10080 then "W"
else "--"),
(if isnan(p4) then color.magenta else if agg4 < chartagg then color.dark_gray else if agg4up then Color.GREEN else Color.RED));
AddLabel(show_labels,
(if agg5min < 60 then (agg5min + " m")
else if agg5min < 1440 then ((agg5min / 60) + " H")
else if agg5min < 10080 then (agg5min / (60 * 24) + " D")
else if agg5min == 10080 then "W"
else "--"),
(if isnan(p5) then color.magenta else if agg5 < chartagg then color.dark_gray else if agg5up then Color.GREEN else Color.RED));
AddLabel(show_labels,
(if agg6min < 60 then (agg6min + " m")
else if agg6min < 1440 then ((agg6min / 60) + " H")
else if agg6min < 10080 then (agg6min / (60 * 24) + " D")
else if agg6min == 10080 then "W"
else "--"),
(if isnan(p6) then color.magenta else if agg6 < chartagg then color.dark_gray else if agg6up then Color.GREEN else Color.RED));
AddLabel(show_labels,
(if agg7min < 60 then (agg7min + " m")
else if agg7min < 1440 then ((agg7min / 60) + " H")
else if agg7min < 10080 then (agg7min / (60 * 24) + " D")
else if agg7min == 10080 then "W"
else "--"),
(if isnan(p7) then color.magenta else if agg7 < chartagg then color.dark_gray else if agg7up then Color.GREEN else Color.RED));
AddLabel(show_labels,
(if agg8min < 60 then (agg8min + " m")
else if agg8min < 1440 then ((agg8min / 60) + " H")
else if agg8min < 10080 then (agg8min / (60 * 24) + " D")
else if agg8min == 10080 then "W"
else "--"),
(if isnan(p8) then color.magenta else if agg8 < chartagg then color.dark_gray else if agg8up then Color.GREEN else Color.RED));
AddLabel(show_labels,
(if agg9min < 60 then (agg9min + " m")
else if agg9min < 1440 then ((agg9min / 60) + " H")
else if agg9min < 10080 then (agg9min / (60 * 24) + " D")
else if agg9min == 10080 then "W"
else "--"),
(if isnan(p9) then color.magenta else if agg9 < chartagg then color.dark_gray else if agg9up then Color.GREEN else Color.RED));
AddLabel(show_labels,
(if agg10min < 60 then (agg10min + " m")
else if agg10min < 1440 then ((agg10min / 60) + " H")
else if agg10min < 10080 then (agg10min / (60 * 24) + " D")
else if agg10min == 10080 then "W"
else "--"),
(if isnan(p10) then color.magenta else if agg10 < chartagg then color.dark_gray else if agg10up then Color.GREEN else Color.RED));
addlabel(1, " ", color.black);
# ----------------------------
# ref
#https://usethinkscript.com/threads/the-multi-10x-mtf-labels-indicator-for-thinkorswim.1129/page-4#post-69106
#