Adding Standard Deviation & Color to watchlist, coding help please!


Staff member
What would be the original source for the standard deviations? For example, VWAP has its own 2 standard dev. Same goes for Bollinger Bands.
Just using the StandardDevChannel study within ToS, 21 length, while on a (30 day, 30 minute) chart. Within the study it has a upper, middle and lower line, I was hoping someone would be able to to figure it out if you could coincide the colors if it was 2 SD or more away.
Hi everyone,

I am trying to create a custom column in a watchlist that will tell me the price to reach the standard deviation line between 1 & -1

For context:

I trade off momentum using standard deviation, when the price action is above 3 standard deviations I short the price back to 1 standard deviation line

When the price action is below -3 standard deviations I go long back to -1 standard deviation line

on my watch lists I use the following scanner to tell me the price action for the 1 minute 1 day chart: this scan will show me tickers whose price action is outside the 1 & -1 standard deviation so I can play off the price action back into the trend intra day.


Using this scan as a watchlist I would like to create a custom column that will tell me the price back to the trend (either the standard deviation 1 or standard deviation -1)

what would be the best approach to accomplish this?

thank you for the help!
@Vincenzo You've pretty much explained the logic so now you just need to turn the logic into actionable code which can be partly accomplished using the Stock Hacker Scanner's Condition Wizard and then tweak further with manual code... Let the Condition Wizard do most of the work and then proceed from there... Live in the Thinkscript Learning Center the whole time and things should fall into place... That's the easiest way to learn... When I come up with a new idea I use the same methods because it reduces prototyping time and insures that simple mistakes aren't missed...
I need help in coding custom quotes column for my watchlist/marketwatch
Indicator Standard deviation channel -- I want to create 3 custom column for my watchlist/marketwatch
I try to edit the indicator code and add label and color
I only want to see the lower channel to turn green - else grey once price close below or at standardDev 2 (lower line) I will do it 3 times just edit the setting from StandDev to 3 and 4

Here is original code-

input price = close;
input deviations = 2.0;
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 + deviations * stdDeviation;
plot MiddleLine = regression;
plot LowerLine = regression - deviations * stdDeviation;


I modify to for custom column --- NEED HELP TO CORRECT IT

input price = close;
input deviations = 1.0;
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);

def LowerLine = regression - deviations * stdDeviation;

plot LowerLineBelow = if close < LowerLine then 1 else 0;

AssignBackgroundColor (if LowerLineBelow >= 1 then color.DARK_GREEN else color.LIGHT_GRAY);
@zamanib I can't get the script to work in a watchlist either. I can get a couple of triggers but most of the column just shows 'loading'
Last edited:
I believe the problem stems from InertiaAll() and StdDevAll()... On a Chart they look at a finite number of candles/bars but in a Custom Watchlist Column they could potentially look back to 1928... I would stick with just Inertia() and StdDev(), omitting the potentially offending code to see if that makes a difference...

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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