ThinkorSwim Bollinger Band Watchlist Column

Steve2286

New member
2019 Donor
Anyone have a watchlist column that would alert when price crosses the upper or lower band?
Thanks
 
You are in luck. I had to pay someone to code this. It's very helpful for me.

Good luck!

Code:
input price = close;
input displace = 0;
input length = 20;
input Num_Dev_Dn = -1.0;
input Num_Dev_up = 1.0;
input averageType = AverageType.simple;

def sDev = stdev(data = price[-displace], length = length);

def MidLine = MovingAverage(averageType, data = price[-displace], length = length);
def LowerBand = MidLine + num_Dev_Dn * sDev;
plot UpperBand = MidLine + num_Dev_Up * sDev;
def aboveUpperBand = close > UpperBand;
def almostToUpperBand = close < UpperBand and close > UpperBand ;

UpperBand.AssignValueColor(if aboveUpperBand or almostToUpperBand then Color.BLACK else Color.WHITE);
AssignBackgroundColor(if aboveUpperBand then Color.GREEN else if almostToUpperBand then Color.YELLOW else Color.BLACK);

You might check out post #5 here as well which is even more functionality.

I think what someone posted here is even better (post #5) https://usethinkscript.com/threads/colored-candles-based-on-bollinger-bands.1265/

Cheers!
 

Similar threads

Top