• Get $30 off VIP with code SUMMER30. Ends July 27. Happy trading!

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
 

perseverance_trading1

New member
VIP
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!
 

J007RMC

Well-known member
2019 Donor
Chart will turn grey and display upper/lower bb limits by positive/negative numerical values

Code:
#Out of Bounds
def sDev = StDev(close, 21);
def MidLine = Average(close, 21);
def UpperBand = MidLine + 2 * sDev;
def LowerBand = MidLine - 2 * sDev;
plot OOB = if close > UpperBand then Round(close - UpperBand, 2) else if close < LowerBand then Round(close - LowerBand, 2) else Double.NaN;
AssignBackgroundColor(if !isnan(oob) then color.white else color.gray);
OOB.assignvalueColor(if !isnan(oob) then color.black else color.gray);

Sound alerts script.

https://tos.mx/Pd1xADc
 
Last edited by a moderator:

Similar threads

Top