# index_major_stocks_trends
#https://usethinkscript.com/threads/dot-indicator-for-thinkorswim.20362/
#Dot Indicator for ThinkorSwim
def na = double.nan;
def bn = barnumber();
# symbols
input sym1 = "AAPL";
input sym2 = "MSFT";
input sym3 = "NVDA";
input sym4 = "AMZN";
input sym5 = "GOOGL";
input sym6 = "META";
# close prices
def c1 = close(sym1);
def c2 = close(sym2);
def c3 = close(sym3);
def c4 = close(sym4);
def c5 = close(sym5);
def c6 = close(sym6);
# directions
def d1 = if c1 > c1[1] then 1 else if c1 < c1[1] then -1 else 0;
def d2 = if c2 > c2[1] then 1 else if c2 < c2[1] then -1 else 0;
def d3 = if c3 > c3[1] then 1 else if c3 < c3[1] then -1 else 0;
def d4 = if c4 > c4[1] then 1 else if c4 < c4[1] then -1 else 0;
def d5 = if c5 > c5[1] then 1 else if c5 < c5[1] then -1 else 0;
def d6 = if c6 > c6[1] then 1 else if c6 < c6[1] then -1 else 0;
input min_qty = 4;
# sum of directions
def upcnt = (d1>0)+(d2>0)+(d3>0)+(d4>0)+(d5>0)+(d6>0);
def dwncnt = (d1<0)+(d2<0)+(d3<0)+(d4<0)+(d5<0)+(d6<0);
def isgrn = upcnt >= min_qty;
def isred = dwncnt >= min_qty;
def y = 0.008;
# up = cyan dot below bars
plot zup = if isgrn then (low*(1-y)) else na;
zup.SetPaintingStrategy(PaintingStrategy.POINTS);
#zup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zup.SetDefaultColor(Color.cyan);
zup.setlineweight(3);
zup.hidebubble();
# down = purple dot above bars
plot zdwn = if isred then (high*(1+y)) else na;
zdwn.SetPaintingStrategy(PaintingStrategy.POINTS);
#zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zdwn.SetDefaultColor(Color.magenta);
zdwn.setlineweight(3);
zdwn.hidebubble();
input test1_close = no;
addchartbubble(test1_close, low*0.99,
c1 + "\n" +
c2 + "\n" +
c3 + "\n" +
c4 + "\n" +
c5 + "\n" +
c6 + "\n"
, color.yellow, no);
input test2_dir = no;
addchartbubble(test2_dir, low*0.99,
upcnt + " U\n" +
dwncnt + " D\n" +
d1 + "\n" +
d2 + "\n" +
d3 + "\n" +
d4 + "\n" +
d5 + "\n" +
d6 + "\n"
, color.yellow, no);
#