here's a simple 3x standard deviation channel watchlist column i put together – it changes colors depending on where a stock's close is. if it's above the regression line, labels signal when it's above a deviation. if it's below the regression line, labels signal when it's below another deviation. just note the timeframe you want is set at the top of the watchlist code window.
colors can be tweaked how you like. right now it signals anything above (green) or below (red) a 2nd deviation – everything else is gray.
Code:
#
# 3x standard deviation watchlist column
# @rough__sleeper
#
def price = close;
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 onedeviationUP = regression + 1 * stdDeviation;
def onedeviationDOWN = regression - 1 * stdDeviation;
def twodeviationUP = regression + 2 * stdDeviation;
def twodeviationDOWN = regression - 2 * stdDeviation;
def threedeviationUP = regression + 3 * stdDeviation;
def threedeviationDOWN = regression - 3 * stdDeviation;
AddLabel(1,
if close > threedeviationUP then " 3 Dev Up "
else if close < threedeviationDOWN then " 3 Dev Dn "
else if close > twodeviationUP then " 2 Dev Up "
else if close < twodeviationDOWN then " 2 Dev Dn "
else if close > onedeviationUP then " 1 Dev Up "
else if close < onedeviationDOWN then " 1 Dev Dn "
else if close > regression then " Reg Up "
else if close < regression then " Reg Dn "
else " "
,
Color.Black
);
#AssignBackgroundColor(if close > regression then Color.LIME else if close < regression then color.PINK else Color.BLACK);
AssignBackgroundColor(if close > twodeviationUP then Color.GREEN else if close < twodeviationDOWN then color.RED else if close > regression then Color.GRAY else if close < regression then color.GRAY else Color.BLACK);
Having a hard time figuring out how to script Standard Dev breakout on the watchlist column. Need a color to light up to indicate that the price has broken out from the upper line on the Standard Dev channel.
The inertiaAll function is a problem when used in labels, scans, watchlist, conditional orders, etc....
When using fullrange functions (ie: InertiaAll, HighestAll, etc...), a length is not provided so the plot calculation assumes the length (fullrange) of the chart.
When you attempt to use the fullrange inertiaAll function in a label, a watchlist, or a scan there is no 'plot'. So there is no "length of the chart" to assume.
Therefore, you need to provide a length. If looking to match up to your fullrange chart results, change the length setting to equal the number of bars on your chart.
Not sure what you are trying to achieve.
Your post doesn't have enough information for anyone to be able to assist you.
To make sure your post gets the attention and assistance it deserves, here are a few directions to keep in mind:
Include a screenshot of your chart and a shared chart link. This will help others understand the context of your question and allow them to replicate the conditions that you are describing.
Annotate your image, highlighting the confluence that you're trying to achieve, along with a more detailed written explanation. This will help others understand your question even better and give them more specific information to work with.
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.
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.