Standard Deviation Scan Label Watchlist for ThinkorSwim


New member
Would like to have the bars on the chart that shows the average SD per day, like in this picture.


Any help would be greatly appreciated.


  • r2OF4x6.png
    83.3 KB · Views: 134

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

I am trying to build a very simple scanner using the standard deviation channel …….. what I want it to do is when it crosses the 2nd deviation line "lower line " on a daily chart I want it to pop up on the scanner …I want stocks who crossed that day I run the scanner and who is still under the lower line on the deviation channel lately iv been getting who crossed few months ago in which im not interested in any help yall can give me to point me in the direction would be greatly appreciated
I have the following code, and I get an error when I use the bottom line. The error comes from the plot LowerLine1 command, but only if I have the alert present using pricetype.XXXX.

The point of the code is to get an alert when the mark crosses below the 1.8 standard deviation but it doesn't seem to be working once the alert is added.

Eventually I want to change it a bit more to become a scanner for stocks crossing below the 1.8 standard deviation, but that's once I get this kink worked out.

input price = close;
input deviation2 = 2.0;
input deviation1  = 1.8;
input fullRange = Yes;
input length = 21;

def regression;
def stdDeviation;
if (fullRange) {
    regression = InertiaAll(price);
    stdDeviation = StDevAll(price);
} else {
    regression = InertiaAll(price, length);
    stdDeviation = StDevAll(price, length);

plot UpperLine = regression + deviation2 * stdDeviation;
plot MiddleLine = regression;
plot LowerLine = regression - deviation2 * stdDeviation;


def regression1;
def stdDeviation1;
if (fullRange) {
    regression1 = InertiaAll(price);
    stdDeviation1 = StDevAll(price);
} else {
    regression1 = InertiaAll(price, length);
    stdDeviation1 = StDevAll(price, length);

plot UpperLine1 = regression1 + deviation1 * stdDeviation1;
plot MiddleLine1 = regression1;
plot LowerLine1 = regression1 - deviation1 * stdDeviation1;
Alert(pricetype.mark < UpperLine1, "BEARISH!", Alert.BAR, Sound.Bell);
Ok, thank you so much.

Side note for why I wanted to use mark was because I was planning on using longer term charts with something like 1day to 1 week aggregation period but I wanted to see about getting alerts on short aggregation periods.

So then I think I would just need something like close( period = AggregationPeriod.Hour) instead, right? Sorry, not at my thinkorswim computer, but I will test it later and let you know how it worked. I appreciate the help Ben.
Hi everyone, I searched on the forum but there was not result for my question. Maybe I could find it here .

Would that be possible to tweak this alert into a scanner ?

I would like to scan stocks with prices BELOW the Lowerline of the "StandardDevChannel" study (see picture below)

I tried but I don't have results so I guess I am not doing the correct settings.

I'm new in the script and tweaking world, don't be rude to me lol. Thank you:)
I believe this can be done. I might try first, changing the length, doing a few value such as 10,20,50,75,100,200. Also, I have noticed, that a lot of std trends hold up much stronger on a long term lengths compared to what you have right now. You have aggregation period as 1 minute, and length of 21 minutes(since aggregation period is how big every 1 length is). That means that is only scanning the past 21 minutes for this alert. If you change to larger aggregation periods and much larger lengths, you might get some results. I would recommend a length of 50x (or up to 200x or more) the aggregation period so that daily channels will be revealed for the past few hours. The length is the number of aggregation periods that it uses to calculate the channel, so if you have an aggregation period of 1 minute, a length of 21 will only see channels that have gone to lower than -2 std in the last 21 minutes, and this trend, from what I have observed is more valid over long time frames, such as, with lengths that are 90-100 days for recent market conditions(outliers when corona virus began completely changed a lot of sectors to be outside of the 2 std channel.I will try this the next day or two and post results as it is something I have been trying to do and for some reason I didn't think about using the built in stdchannel. Thank you for asking.
Also, don't worry about people being rude here. This is one of the most tolerative forums for what you might think are not smart questions. We are all here for the same reason, to learn thinkscript, and help each other get a few more percentages (or more) out of what we have currently. Anybody who treats you bad, ignore, be the bigger person and don't stoop to their level. I got your back if that's the case.
Hi how are you guys? I hope fine and safe. Can you help to set an alert in a standard deviation channel?? I want to set an alert in in the upperline, middle line and lower line, so when the price reach one , TOS just make a sound...

Thanks a lot

Hello All,

I have seen a few posts on Standard Deviations but nothing conclusive. I am looking for help to build a watchlist with alerts around standard deviations.

I have a watchlist of 200 tickers that I trade normally. I dont trade all of them but watch them on a regular basis.

I am on a Today/1 Minute chart for most of these and am looking to scalp them.

I would like to have two things
1) a Watchlist that would have the following columns
Ticker/Last//%change/Volume which are standard. Now for the custom columns,

2) An alert when any of the tickers on the watchlist reach 2-STD-LOW OR 2-STD-HIGH.

Wondering if one could guide me in here.

Thanks in advance.
It looks like you want more than just a watchlist column for the standard deviation indicator. For things like ORB (opening range breakout) we already posted it here. If you use the Search feature on the forum, you should also find other watchlist columns related to your request.
ProfessorAR15, whoops your right, i messed up, all you have to do is change RetlativeVolStDev to StandardDeviationChannel under the "study"

Here is the correct below for what you asked, please not that it will catch crossings, personally i prefer to use the is less than or equal to feature incase there are "jumps" "gaps" in price movement that will trick the scanner. just my personal opinion based of prior experiences with "crossing" on tos


Gogoisgone, know one knows what hi-1-std is or what study you are referring to.
I currently watch Linear Regression Line and, Standard Deviation lines for 1 and 2. Each Standard Deviation has a high and low. that is what meant when I say hi-1-std... 1 standard deviation high value. Hope this helps @XeoNoX
without a screenshot or very clear expination, know one can understand what you are looking at or trying to do or explain. I see quite a few linear regression studies in TOS, you have to be more specific as you can and pictures help alot, or else know one else knows what you are talking about .
you have to be specific, thats "StandardDevChannel". here is the scan you requested. You can change the words "is greater than or equal to" with anything in the box above that i had listed here to meet your needs.


def price = close;
def deviations = 2.0;
def fullRange = Yes;
def length = 21;

def regression;
def stdDeviation;
if (fullRange) {
    regression = InertiaAll(price);
    stdDeviation = stdevAll(price);
} else {
    regression = InertiaAll(price, length);
    stdDeviation = stdevAll(price, length);

def UpperLine = regression + deviations * stdDeviation;
def MiddleLine = regression;
def LowerLine = regression - deviations * stdDeviation;

plot scan = close is greater than or equal to lowerline;

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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