several - 2nd aggregation candles after last bar for ThinkOrSwim

halcyonguy

Moderator - Expert
VIP
Lifetime
this draws 4 candles after the last bar,
that represent the last 4 - 2nd agg time periods on the chart.

can pick the 2nd aggregation time.
horizontal lines are drawn above and below each period of bars.

i made this from a request.
https://usethinkscript.com/threads/daily-candle-on-one-minute-chart.20588/

a couple of ref links are below

Code:
#mtf_candle_exp_area_01

def na = double.nan;
def cls2 = if isnan(close) then cls2[1] else close;

DefineGlobalColor("agg_lines", color.gray);
#GlobalColor("agg_lines")

input agg = AggregationPeriod.day;
input multiplier = 0.001;

#----------------------
# read agg data before last bar
def b1 = (!isnan(close(period=agg)[-3]) and isnan(close(period=agg)[-4]));
def o1;
def h1;
def l1;
def c1;
if b1 then {
 o1 = open(period=agg);
 h1 = high(period=agg);
 l1 = low(period=agg);
 c1 = close(period=agg);
} else {
 o1 = o1[1];
 h1 = h1[1];
 l1 = l1[1];
 c1 = c1[1];
}

plot zh1 = if b1 then h1*(1+multiplier) else na;
plot zl1 = if b1 then l1*(1-multiplier) else na;
zh1.SetDefaultColor(GlobalColor("agg_lines"));
zl1.SetDefaultColor(GlobalColor("agg_lines"));
zh1.hidebubble();
zl1.hidebubble();
#----------------------
def b2 = (!isnan(close(period=agg)[-2]) and isnan(close(period=agg)[-3]));
def o2;
def h2;
def l2;
def c2;
if b2 then {
 o2 = open(period=agg);
 h2 = high(period=agg);
 l2 = low(period=agg);
 c2 = close(period=agg);
} else {
 o2 = o2[1];
 h2 = h2[1];
 l2 = l2[1];
 c2 = c2[1];
}

plot zh2 = if b2 then h2*(1+multiplier) else na;
plot zl2 = if b2 then l2*(1-multiplier) else na;
zh2.SetDefaultColor(GlobalColor("agg_lines"));
zl2.SetDefaultColor(GlobalColor("agg_lines"));
zh2.hidebubble();
zl2.hidebubble();
#----------------------
def b3 = (!isnan(close(period=agg)[-1]) and isnan(close(period=agg)[-2]));
def o3;
def h3;
def l3;
def c3;
if b3 then {
 o3 = open(period=agg);
 h3 = high(period=agg);
 l3 = low(period=agg);
 c3 = close(period=agg);
} else {
 o3 = o3[1];
 h3 = h3[1];
 l3 = l3[1];
 c3 = c3[1];
}

plot zh3 = if b3 then h3*(1+multiplier) else na;
plot zl3 = if b3 then l3*(1-multiplier) else na;
zh3.SetDefaultColor(GlobalColor("agg_lines"));
zl3.SetDefaultColor(GlobalColor("agg_lines"));
zh3.hidebubble();
zl3.hidebubble();
#----------------------
def b4 = (!isnan(close(period=agg)[0]) and isnan(close(period=agg)[-1]));
def o4;
def h4;
def l4;
def c4;
if b4 then {
 o4 = open(period=agg);
 h4 = high(period=agg);
 l4 = low(period=agg);
 c4 = close(period=agg);
} else {
 o4 = o4[1];
 h4 = h4[1];
 l4 = l4[1];
 c4 = c4[1];
}

plot zh4 = if b4 then h4*(1+multiplier) else na;
plot zl4 = if b4 then l4*(1-multiplier) else na;
zh4.SetDefaultColor(GlobalColor("agg_lines"));
zl4.SetDefaultColor(GlobalColor("agg_lines"));
zh4.hidebubble();
zl4.hidebubble();
#----------------------

# colored column placements, bars after last bar
input offset = 3;
def spac = 2;
def x1 = (!isnan(close[offset+(0*spac)]) and isnan(close[(offset+(0*spac))-1]));
def x2 = (!isnan(close[offset+(1*spac)]) and isnan(close[(offset+(1*spac))-1]));
def x3 = (!isnan(close[offset+(2*spac)]) and isnan(close[(offset+(2*spac))-1]));
def x4 = (!isnan(close[offset+(3*spac)]) and isnan(close[(offset+(3*spac))-1]));
#----------------------

def c1h = if x1 then h1 else na;
def c1l = if x1 then l1 else na;
def c1ogrn = if x1 and o1<=c1 then o1 else na;
def c1cgrn = if x1 and o1<=c1 then c1 else na;
def c1ored = if x1 and o1>c1 then o1 else na;
def c1cred = if x1 and o1>c1 then c1 else na;
#AddChart(high = c1h, low = c1l, open = c1ogrn, close = c1cgrn, type = ChartType.CANDLE, growcolor = color.green);
# swap open/close data for green candle, so body is filled in
AddChart(high = c1h, low = c1l, open = c1cgrn, close = c1ogrn, type = ChartType.CANDLE, growcolor = color.green);
AddChart(high = c1h, low = c1l, open = c1ored, close = c1cred, type = ChartType.CANDLE, growcolor = color.red);

def c2h = if x2 then h2 else na;
def c2l = if x2 then l2 else na;
def c2ogrn = if x2 and o2<=c2 then o2 else na;
def c2cgrn = if x2 and o2<=c2 then c2 else na;
def c2ored = if x2 and o2>c2 then o2 else na;
def c2cred = if x2 and o2>c2 then c2 else na;
#AddChart(high = c2h, low = c2l, open = c2ogrn, close = c2cgrn, type = ChartType.CANDLE, growcolor = color.green);
AddChart(high = c2h, low = c2l, open = c2cgrn, close = c2ogrn, type = ChartType.CANDLE, growcolor = color.green);
AddChart(high = c2h, low = c2l, open = c2ored, close = c2cred, type = ChartType.CANDLE, growcolor = color.red);

def c3h = if x3 then h3 else na;
def c3l = if x3 then l3 else na;
def c3ogrn = if x3 and o3<=c3 then o3 else na;
def c3cgrn = if x3 and o3<=c3 then c3 else na;
def c3ored = if x3 and o3>c3 then o3 else na;
def c3cred = if x3 and o3>c3 then c3 else na;
#AddChart(high = c3h, low = c3l, open = c3ogrn, close = c3cgrn, type = ChartType.CANDLE, growcolor = color.green);
AddChart(high = c3h, low = c3l, open = c3cgrn, close = c3ogrn, type = ChartType.CANDLE, growcolor = color.green);
AddChart(high = c3h, low = c3l, open = c3ored, close = c3cred, type = ChartType.CANDLE, growcolor = color.red);

def c4h = if x4 then h4 else na;
def c4l = if x4 then l4 else na;
def c4ogrn = if x4 and o4<=c4 then o4 else na;
def c4cgrn = if x4 and o4<=c4 then c4 else na;
def c4ored = if x4 and o4>c4 then o4 else na;
def c4cred = if x4 and o4>c4 then c4 else na;
#AddChart(high = c4h, low = c4l, open = c4ogrn, close = c4cgrn, type = ChartType.CANDLE, growcolor = color.green);
AddChart(high = c4h, low = c4l, open = c4cgrn, close = c4ogrn, type = ChartType.CANDLE, growcolor = color.green);
AddChart(high = c4h, low = c4l, open = c4ored, close = c4cred, type = ChartType.CANDLE, growcolor = color.red);
#----------------------

def bubpr = max(h1,max(h2,max(h3,h4)));
def aggmin =  agg/60000;
def y = 0.001;
addchartbubble(x1,bubpr*(1+y),
  (if aggmin < 60 then (aggmin + " m")
  else if aggmin < 1440 then ((aggmin/60) + " H")
  else if aggmin < 10080 then (aggmin/(60*24) + " D")
  else if agg == aggregationPeriod.WEEK then "W"
  else if agg == aggregationPeriod.MONTH then "M"
  else "") + "  bars"
, Color.yellow, yes);

#----------------------

addchartbubble(0 and x1,94.8,
bubpr + "\n" +
h1 + "\n" +
h2 + "\n" +
h3 + "\n" +
h4 + "\n"
, color.cyan, yes);

#----------------------
#refs

# 4 MTF bars after last bar
# https://usethinkscript.com/threads/4-mtf-price-ranges-simulated-candles-after-last-bar-for-thinkorswim.13328/

# agg label
# https://usethinkscript.com/threads/need-help-adding-prices-for-major-indices.7308/#post-70581
#

refs
4 MTF bars after last bar
https://usethinkscript.com/threads/...candles-after-last-bar-for-thinkorswim.13328/

agg label
https://usethinkscript.com/threads/need-help-adding-prices-for-major-indices.7308/#post-70581
 

Attachments

  • 00b-1 5min chart - 30min.JPG
    00b-1 5min chart - 30min.JPG
    57.1 KB · Views: 96
  • 00b-2 15minchart -day.JPG
    00b-2 15minchart -day.JPG
    91 KB · Views: 94

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

here is an updated version that has 10 - 2nd agg candles, after last bar

Code:
#mtf_candle_exp_area_02_10
#https://usethinkscript.com/threads/daily-candle-on-one-minute-chart.20588/
#Daily Candle on One Minute Chart

# chg to 10 bars

def na = double.nan;
def cls2 = if isnan(close) then cls2[1] else close;

DefineGlobalColor("agg_lines", color.gray);
#GlobalColor("agg_lines")

input agg = AggregationPeriod.day;
input multiplier = 0.001;
def n = 10;
#----------------------
# read agg data before last bar
def b1 = (!isnan(close(period=agg)[-(n-1)]) and isnan(close(period=agg)[-(n-0)]));
def o1;
def h1;
def l1;
def c1;
if b1 then {
 o1 = open(period=agg);
 h1 = high(period=agg);
 l1 = low(period=agg);
 c1 = close(period=agg);
} else {
 o1 = o1[1];
 h1 = h1[1];
 l1 = l1[1];
 c1 = c1[1];
}

plot zh1 = if b1 then h1*(1+multiplier) else na;
plot zl1 = if b1 then l1*(1-multiplier) else na;
zh1.SetDefaultColor(GlobalColor("agg_lines"));
zl1.SetDefaultColor(GlobalColor("agg_lines"));
zh1.hidebubble();
zl1.hidebubble();
#----------------------
def b2 = (!isnan(close(period=agg)[-(n-2)]) and isnan(close(period=agg)[-(n-1)]));
def o2;
def h2;
def l2;
def c2;
if b2 then {
 o2 = open(period=agg);
 h2 = high(period=agg);
 l2 = low(period=agg);
 c2 = close(period=agg);
} else {
 o2 = o2[1];
 h2 = h2[1];
 l2 = l2[1];
 c2 = c2[1];
}

plot zh2 = if b2 then h2*(1+multiplier) else na;
plot zl2 = if b2 then l2*(1-multiplier) else na;
zh2.SetDefaultColor(GlobalColor("agg_lines"));
zl2.SetDefaultColor(GlobalColor("agg_lines"));
zh2.hidebubble();
zl2.hidebubble();
#----------------------
def b3 = (!isnan(close(period=agg)[-(n-3)]) and isnan(close(period=agg)[-(n-2)]));
def o3;
def h3;
def l3;
def c3;
if b3 then {
 o3 = open(period=agg);
 h3 = high(period=agg);
 l3 = low(period=agg);
 c3 = close(period=agg);
} else {
 o3 = o3[1];
 h3 = h3[1];
 l3 = l3[1];
 c3 = c3[1];
}

plot zh3 = if b3 then h3*(1+multiplier) else na;
plot zl3 = if b3 then l3*(1-multiplier) else na;
zh3.SetDefaultColor(GlobalColor("agg_lines"));
zl3.SetDefaultColor(GlobalColor("agg_lines"));
zh3.hidebubble();
zl3.hidebubble();
#----------------------
def b4 = (!isnan(close(period=agg)[-(n-4)]) and isnan(close(period=agg)[-(n-3)]));
def o4;
def h4;
def l4;
def c4;
if b4 then {
 o4 = open(period=agg);
 h4 = high(period=agg);
 l4 = low(period=agg);
 c4 = close(period=agg);
} else {
 o4 = o4[1];
 h4 = h4[1];
 l4 = l4[1];
 c4 = c4[1];
}

plot zh4 = if b4 then h4*(1+multiplier) else na;
plot zl4 = if b4 then l4*(1-multiplier) else na;
zh4.SetDefaultColor(GlobalColor("agg_lines"));
zl4.SetDefaultColor(GlobalColor("agg_lines"));
zh4.hidebubble();
zl4.hidebubble();
#----------------------
def b5 = (!isnan(close(period=agg)[-(n-5)]) and isnan(close(period=agg)[-(n-4)]));
def o5;
def h5;
def l5;
def c5;
if b5 then {
 o5 = open(period=agg);
 h5 = high(period=agg);
 l5 = low(period=agg);
 c5 = close(period=agg);
} else {
 o5 = o5[1];
 h5 = h5[1];
 l5 = l5[1];
 c5 = c5[1];
}

plot zh5 = if b5 then h5*(1+multiplier) else na;
plot zl5 = if b5 then l5*(1-multiplier) else na;
zh5.SetDefaultColor(GlobalColor("agg_lines"));
zl5.SetDefaultColor(GlobalColor("agg_lines"));
zh5.hidebubble();
zl5.hidebubble();
#----------------------
def b6 = (!isnan(close(period=agg)[-(n-6)]) and isnan(close(period=agg)[-(n-5)]));
def o6;
def h6;
def l6;
def c6;
if b6 then {
 o6 = open(period=agg);
 h6 = high(period=agg);
 l6 = low(period=agg);
 c6 = close(period=agg);
} else {
 o6 = o6[1];
 h6 = h6[1];
 l6 = l6[1];
 c6 = c6[1];
}

plot zh6 = if b6 then h6*(1+multiplier) else na;
plot zl6 = if b6 then l6*(1-multiplier) else na;
zh6.SetDefaultColor(GlobalColor("agg_lines"));
zl6.SetDefaultColor(GlobalColor("agg_lines"));
zh6.hidebubble();
zl6.hidebubble();
#----------------------
def b7 = (!isnan(close(period=agg)[-(n-7)]) and isnan(close(period=agg)[-(n-6)]));
def o7;
def h7;
def l7;
def c7;
if b7 then {
 o7 = open(period=agg);
 h7 = high(period=agg);
 l7 = low(period=agg);
 c7 = close(period=agg);
} else {
 o7 = o7[1];
 h7 = h7[1];
 l7 = l7[1];
 c7 = c7[1];
}

plot zh7 = if b7 then h7*(1+multiplier) else na;
plot zl7 = if b7 then l7*(1-multiplier) else na;
zh7.SetDefaultColor(GlobalColor("agg_lines"));
zl7.SetDefaultColor(GlobalColor("agg_lines"));
zh7.hidebubble();
zl7.hidebubble();

#----------------------



def b8 = (!isnan(close(period=agg)[-(n-8)]) and isnan(close(period=agg)[-(n-7)]));
def o8;
def h8;
def l8;
def c8;
if b8 then {
 o8 = open(period=agg);
 h8 = high(period=agg);
 l8 = low(period=agg);
 c8 = close(period=agg);
} else {
 o8 = o8[1];
 h8 = h8[1];
 l8 = l8[1];
 c8 = c8[1];
}

plot zh8 = if b8 then h8*(1+multiplier) else na;
plot zl8 = if b8 then l8*(1-multiplier) else na;
zh8.SetDefaultColor(GlobalColor("agg_lines"));
zl8.SetDefaultColor(GlobalColor("agg_lines"));
zh8.hidebubble();
zl8.hidebubble();
#----------------------
def b9 = (!isnan(close(period=agg)[-(n-9)]) and isnan(close(period=agg)[-(n-8)]));
def o9;
def h9;
def l9;
def c9;
if b9 then {
 o9 = open(period=agg);
 h9 = high(period=agg);
 l9 = low(period=agg);
 c9 = close(period=agg);
} else {
 o9 = o9[1];
 h9 = h9[1];
 l9 = l9[1];
 c9 = c9[1];
}

plot zh9 = if b9 then h9*(1+multiplier) else na;
plot zl9 = if b9 then l9*(1-multiplier) else na;
zh9.SetDefaultColor(GlobalColor("agg_lines"));
zl9.SetDefaultColor(GlobalColor("agg_lines"));
zh9.hidebubble();
zl9.hidebubble();
#----------------------
def b10 = (!isnan(close(period=agg)[-(n-10)]) and isnan(close(period=agg)[-(n-9)]));
def o10;
def h10;
def l10;
def c10;
if b10 then {
 o10 = open(period=agg);
 h10 = high(period=agg);
 l10 = low(period=agg);
 c10 = close(period=agg);
} else {
 o10 = o10[1];
 h10 = h10[1];
 l10 = l10[1];
 c10 = c10[1];
}

plot zh10 = if b10 then h10*(1+multiplier) else na;
plot zl10 = if b10 then l10*(1-multiplier) else na;
zh10.SetDefaultColor(GlobalColor("agg_lines"));
zl10.SetDefaultColor(GlobalColor("agg_lines"));
zh10.hidebubble();
zl10.hidebubble();

#----------------------

# colored column placements, bars after last bar
input offset = 3;
def spac = 2;
def x1 = (!isnan(close[offset+(0*spac)]) and isnan(close[(offset+(0*spac))-1]));
def x2 = (!isnan(close[offset+(1*spac)]) and isnan(close[(offset+(1*spac))-1]));
def x3 = (!isnan(close[offset+(2*spac)]) and isnan(close[(offset+(2*spac))-1]));
def x4 = (!isnan(close[offset+(3*spac)]) and isnan(close[(offset+(3*spac))-1]));
def x5 = (!isnan(close[offset+(4*spac)]) and isnan(close[(offset+(4*spac))-1]));
def x6 = (!isnan(close[offset+(5*spac)]) and isnan(close[(offset+(5*spac))-1]));
def x7 = (!isnan(close[offset+(6*spac)]) and isnan(close[(offset+(6*spac))-1]));
def x8 = (!isnan(close[offset+(7*spac)]) and isnan(close[(offset+(7*spac))-1]));
def x9 = (!isnan(close[offset+(8*spac)]) and isnan(close[(offset+(8*spac))-1]));
def x10 = (!isnan(close[offset+(9*spac)]) and isnan(close[(offset+(9*spac))-1]));

#----------------------

def c1h = if x1 then h1 else na;
def c1l = if x1 then l1 else na;
def c1ogrn = if x1 and o1<=c1 then o1 else na;
def c1cgrn = if x1 and o1<=c1 then c1 else na;
def c1ored = if x1 and o1>c1 then o1 else na;
def c1cred = if x1 and o1>c1 then c1 else na;
#AddChart(high = c1h, low = c1l, open = c1ogrn, close = c1cgrn, type = ChartType.CANDLE, growcolor = color.green);
# swap open/close data for green candle, so body is filled in
AddChart(high = c1h, low = c1l, open = c1cgrn, close = c1ogrn, type = ChartType.CANDLE, growcolor = color.green);
AddChart(high = c1h, low = c1l, open = c1ored, close = c1cred, type = ChartType.CANDLE, growcolor = color.red);

def c2h = if x2 then h2 else na;
def c2l = if x2 then l2 else na;
def c2ogrn = if x2 and o2<=c2 then o2 else na;
def c2cgrn = if x2 and o2<=c2 then c2 else na;
def c2ored = if x2 and o2>c2 then o2 else na;
def c2cred = if x2 and o2>c2 then c2 else na;
#AddChart(high = c2h, low = c2l, open = c2ogrn, close = c2cgrn, type = ChartType.CANDLE, growcolor = color.green);
AddChart(high = c2h, low = c2l, open = c2cgrn, close = c2ogrn, type = ChartType.CANDLE, growcolor = color.green);
AddChart(high = c2h, low = c2l, open = c2ored, close = c2cred, type = ChartType.CANDLE, growcolor = color.red);

def c3h = if x3 then h3 else na;
def c3l = if x3 then l3 else na;
def c3ogrn = if x3 and o3<=c3 then o3 else na;
def c3cgrn = if x3 and o3<=c3 then c3 else na;
def c3ored = if x3 and o3>c3 then o3 else na;
def c3cred = if x3 and o3>c3 then c3 else na;
AddChart(high = c3h, low = c3l, open = c3cgrn, close = c3ogrn, type = ChartType.CANDLE, growcolor = color.green);
AddChart(high = c3h, low = c3l, open = c3ored, close = c3cred, type = ChartType.CANDLE, growcolor = color.red);

def c4h = if x4 then h4 else na;
def c4l = if x4 then l4 else na;
def c4ogrn = if x4 and o4<=c4 then o4 else na;
def c4cgrn = if x4 and o4<=c4 then c4 else na;
def c4ored = if x4 and o4>c4 then o4 else na;
def c4cred = if x4 and o4>c4 then c4 else na;
AddChart(high = c4h, low = c4l, open = c4cgrn, close = c4ogrn, type = ChartType.CANDLE, growcolor = color.green);
AddChart(high = c4h, low = c4l, open = c4ored, close = c4cred, type = ChartType.CANDLE, growcolor = color.red);

def c5h = if x5 then h5 else na;
def c5l = if x5 then l5 else na;
def c5ogrn = if x5 and o5<=c5 then o5 else na;
def c5cgrn = if x5 and o5<=c5 then c5 else na;
def c5ored = if x5 and o5>c5 then o5 else na;
def c5cred = if x5 and o5>c5 then c5 else na;
AddChart(high = c5h, low = c5l, open = c5cgrn, close = c5ogrn, type = ChartType.CANDLE, growcolor = color.green);
AddChart(high = c5h, low = c5l, open = c5ored, close = c5cred, type = ChartType.CANDLE, growcolor = color.red);

def c6h = if x6 then h6 else na;
def c6l = if x6 then l6 else na;
def c6ogrn = if x6 and o6<=c6 then o6 else na;
def c6cgrn = if x6 and o6<=c6 then c6 else na;
def c6ored = if x6 and o6>c6 then o6 else na;
def c6cred = if x6 and o6>c6 then c6 else na;
AddChart(high = c6h, low = c6l, open = c6cgrn, close = c6ogrn, type = ChartType.CANDLE, growcolor = color.green);
AddChart(high = c6h, low = c6l, open = c6ored, close = c6cred, type = ChartType.CANDLE, growcolor = color.red);

def c7h = if x7 then h7 else na;
def c7l = if x7 then l7 else na;
def c7ogrn = if x7 and o7<=c7 then o7 else na;
def c7cgrn = if x7 and o7<=c7 then c7 else na;
def c7ored = if x7 and o7>c7 then o7 else na;
def c7cred = if x7 and o7>c7 then c7 else na;
AddChart(high = c7h, low = c7l, open = c7cgrn, close = c7ogrn, type = ChartType.CANDLE, growcolor = color.green);
AddChart(high = c7h, low = c7l, open = c7ored, close = c7cred, type = ChartType.CANDLE, growcolor = color.red);

def c8h = if x8 then h8 else na;
def c8l = if x8 then l8 else na;
def c8ogrn = if x8 and o8<=c8 then o8 else na;
def c8cgrn = if x8 and o8<=c8 then c8 else na;
def c8ored = if x8 and o8>c8 then o8 else na;
def c8cred = if x8 and o8>c8 then c8 else na;
AddChart(high = c8h, low = c8l, open = c8cgrn, close = c8ogrn, type = ChartType.CANDLE, growcolor = color.green);
AddChart(high = c8h, low = c8l, open = c8ored, close = c8cred, type = ChartType.CANDLE, growcolor = color.red);

def c9h = if x9 then h9 else na;
def c9l = if x9 then l9 else na;
def c9ogrn = if x9 and o9<=c9 then o9 else na;
def c9cgrn = if x9 and o9<=c9 then c9 else na;
def c9ored = if x9 and o9>c9 then o9 else na;
def c9cred = if x9 and o9>c9 then c9 else na;
AddChart(high = c9h, low = c9l, open = c9cgrn, close = c9ogrn, type = ChartType.CANDLE, growcolor = color.green);
AddChart(high = c9h, low = c9l, open = c9ored, close = c9cred, type = ChartType.CANDLE, growcolor = color.red);

def c10h = if x10 then h10 else na;
def c10l = if x10 then l10 else na;
def c10ogrn = if x10 and o10<=c10 then o10 else na;
def c10cgrn = if x10 and o10<=c10 then c10 else na;
def c10ored = if x10 and o10>c10 then o10 else na;
def c10cred = if x10 and o10>c10 then c10 else na;
AddChart(high = c10h, low = c10l, open = c10cgrn, close = c10ogrn, type = ChartType.CANDLE, growcolor = color.green);
AddChart(high = c10h, low = c10l, open = c10ored, close = c10cred, type = ChartType.CANDLE, growcolor = color.red);


#----------------------

def bubpr = max(h1,max(h2,max(h3,max(h4,max(h5,max(h6,max(h7,max(h8,max(h9,h10)))))))));
def aggmin =  agg/60000;
#def y = 0.001;
def y = 0.0;
addchartbubble(x2,bubpr*(1+y),
  (if aggmin < 60 then (aggmin + " m")
  else if aggmin < 1440 then ((aggmin/60) + " H")
  else if aggmin < 10080 then (aggmin/(60*24) + " D")
  else if agg == aggregationPeriod.WEEK then "W"
  else if agg == aggregationPeriod.MONTH then "M"
  else "") + "  bars"
, Color.yellow, yes);

#----------------------

addchartbubble(0 and x1,94.8,
bubpr + "\n" +
h1 + "\n" +
h2 + "\n" +
h3 + "\n" +
h4 + "\n" 
, color.cyan, yes);

#----------------------
#refs

# 4 MTF bars after last bar
# https://usethinkscript.com/threads/4-mtf-price-ranges-simulated-candles-after-last-bar-for-thinkorswim.13328/

# agg label
# https://usethinkscript.com/threads/need-help-adding-prices-for-major-indices.7308/#post-70581
#
 

Attachments

  • 00e-10 bars.JPG
    00e-10 bars.JPG
    70.3 KB · Views: 30
@halcyonguy can you please explain this indicator? Is it projecting future bars?

no, not guessing at future prices.

say you have the chart set to 15min bars.
if set to day, this will read ohlc prices from the past 10 days, and draw candles that represent them.
so you don't have to flick back and forth, between 2 different chart times, to check those candles.

looks like you have chart set to day. change it to hour or 15min and see what it does.
hmmm it doesnt seem to draw the horizontal lines correct on your chart.
 
Thread starter Similar threads Forum Replies Date
MatthewA Automating Aggregation Selection for ThinkorSwim Custom 3

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
475 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