Auto Volatility Standard Deviation Levels for ThinkorSwim

BenTen

BenTen

Administrative
Staff
VIP
This indicator will plot volatility based standard deviation levels for the S&P 500 (SPY) and some futures instruments such as /ES, /NQ, and /RTY.

How does this work?

The standard deviation levels are based on the previous day closing value of $SPY and $VIX. The indicator was ported to ThinkorSwim from TradingView.

Here is a brief note from the developer for anyone trading futures:

For NQ, I use VXN closing price and for ES or RTY, I use VIX closing price.

No need to modify the code or change any value if you're going to use this on SPY chart. You will have to edit the script a bit if you want to get the previous day value of VXN instead of VIX.

To get a better understanding of this indicator, I recommend watching the video below.




Code:
# Volatility Based Standard Deviations
# Assembled by BenTen at UseThinkScript.com
# Converted from https://www.tradingview.com/script/vXGZ9DdQ-Volatility-based-Standarde-Deviation-and-Fib-Pivot-Points/

input aggregationPeriod = AggregationPeriod.DAY;
def SettlementPrice = close(period = aggregationPeriod)[1];
def VixClose = close("VIX", period = aggregationPeriod)[1];

def ZTable = 0.0625;
def SD = SettlementPrice * (VixClose / 100) * ZTable;

# Standard Deviation Calculation

plot usd1 = SettlementPrice + SD;
plot usd75 = SettlementPrice + (0.75 * SD);
plot usd5 = SettlementPrice + (0.5 * SD);
plot usd25 = SettlementPrice + (0.25 * SD);

plot dsd25 = SettlementPrice - (0.25 * SD);
plot dsd5 = SettlementPrice - (0.5 * SD);
plot dsd75 = SettlementPrice - (0.75 * SD);
plot dsd1 = SettlementPrice - SD;

usd1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
usd1.SetDefaultColor(Color.DOWNTICK);
usd75.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
usd75.SetDefaultColor(Color.DOWNTICK);
usd5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
usd5.SetDefaultColor(Color.DOWNTICK);
usd25.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
usd25.SetDefaultColor(Color.DOWNTICK);
dsd25.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
dsd25.SetDefaultColor(Color.UPTICK);
dsd5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
dsd5.SetDefaultColor(Color.UPTICK);
dsd75.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
dsd75.SetDefaultColor(Color.UPTICK);
dsd1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
dsd1.SetDefaultColor(Color.UPTICK);
 
Last edited:
G

gjervis

New member
2019 Donor
VIP
thanks Ben, so if i wanted to use this on AMZN, then i would replace the SPY to AMZN? or to any ticker i am looking at?
 
BenTen

BenTen

Administrative
Staff
VIP
@gjervis Not necessarily. By default, it will pull data from the current ticker you're looking at. The only time you need to adjust the ticker symbol in the script is if you want to use VXN instead of VIX.
 
BenTen

BenTen

Administrative
Staff
VIP
@TOSTrader I assume a better correlation. /NQ is the E-mini NASDAQ Futures, so it would work better if you use VXN (CBOE NASDAQ Volatility Index) with it. All up for interpretation, of course.
 
W

whats up

Member
VIP
@TOSTrader I assume a better correlation. /NQ is the E-mini NASDAQ Futures, so it would work better if you use VXN (CBOE NASDAQ Volatility Index) with it. All up for interpretation, of course.
hi ben i looked at the video more than 4 times very interesting,what i get out this is he keeps talking about the settlement price very important..
but i dont see it in the script.so i get it from volume profile,but when looking at other tickers like aapl fb we can get the settlement price.. but can not get the Standard deviations...is there a way we can get that on volume profile? thanks
 
BenTen

BenTen

Administrative
Staff
VIP
@whats up From the TradingView version, the settlement price is set to the closing price of VIX and SPY from the previous day.

I even talked to the original developer, and this is what he said:

You can enter SPY closing price and vix closing price at the end of the day. It will give standard deviation levels and Fib levels for next day.
Actually, in future, I'll change this indicator to take symbol price itself as well as vix price. But since I use different volatility prices for different assets, that's why I made it to enter manually. For example, for QQQ, you can use VXN closing price for better results.
 
W

whats up

Member
VIP
@whats up From the TradingView version, the settlement price is set to the closing price of VIX and SPY from the previous day.

I even talked to the original developer, and this is what he said:
thanks i will try that
 
horserider

horserider

Well-known member
VIP
Maybe it is my eyes, but the video shows different spacing between the SD lines. This study the lines are always equally spaced. Is something in the calculations different?

What is ZTable ? def ZTable = 0.0625; Any idea where this value comes from?

Why not plot the settlementprice line (even if it is just yesterday's close)as the video points to its importance?
 
W

whats up

Member
VIP
Hi @horserider thanks for taking interest in this indicator SD lines on the video is diff bec i think he uses the .05and .07 levels Ben did the .25 .50 .75 and 1 which is fine but here is my question, what if we did the fb aapl settlement price on the volume profile 30min chart and then take the standard DV Channel on TOS measure the move? If you do spy on volume profile. it gives you same levels what ben posted.
 
N

Nomak

New member
2019 Donor
VIP
An interesting find Ben, I like it.

Question: Isn't the price settlement calculated a bit different from closed? I would probably manually enter that.
 
BenTen

BenTen

Administrative
Staff
VIP
@Nomak You're probably right about the settlement price vs. the closing price. If you choose to calculate the settlement price, then you would have to enter the value manually. I asked the developer from TradingView, and he said an alternative would be to use the closing price of both SPY and VIX, which you can automate.
 
Y

YAD

New member
VIP
@BenTen Is it possible to create a scanner for this study? Says secondary period not allowed. Looking for candle close to cross a selected settlement price on a 5 min candle.
 
BenTen

BenTen

Administrative
Staff
VIP
@YAD I don't think so, as pointed out by ToS, they don't support "secondary aggregation period" in their scanner. However, since these levels are static, try setting the scanner's timeframe to daily (D) to see if you can bypass that error.
 
T

tradebyday

Active member
@BenTen I am actually helping someone with a slightly tweaked version of this indicator. What I know about settlement price on ES and NQ (I will say exclusively as I am unsure in regards to other assets) settlement price is the average in the range of a 30 second candle from 2:14:30pm- 2:15:00pm EST. I have yet to see 30second candles in TOS so assuming they do not exist, is it possible to create a ' period = "DAY" [1] for the specific 1min candle of 2:14:00pm- 2:15:00pm EST to serve as a close estimation? It would work like a "previous day close" line but just more accurate to what the system is supposed to be
 
N

Nomak

New member
2019 Donor
VIP
Hey @tradebyday, if you go into chart settings > futures tab > Daily close dropdown > you will see "settlement"
 
T

tradebyday

Active member
@Nomak this actually does not do anything when referencing prior day close. That setting is only useful on larger time frames when looking at the "close" value posted for the candle, no impact on indicators. I am asking if it is possible to reference a prior day value that occurs at a specific time of day? I want to grab price at 4:14pm EST, and value at 4:15pm EST, then I will take an average of the two values to generate "settlement price" artificially so people do not have to enter it each time to utilize this style of indicator
 
technicallydreaming

technicallydreaming

Member
Really great indicator for S & P futures traders. A bit confused because it seemed in the video he was referring to every three lines crossed as a standard deviation, but maybe I am mistaken--I thought each line was one deviation. Regardless, the price often bounces off or forcefully passes through these levels.
 
F

freedom Traders

New member
VIP
You guys are awesome...I have been calculating this manually for the past 7 months every night.I think my chart is now complete and ready to test my strategy live. Thank you usethinkscript..great, the best trading community out here.
 
F

freedom Traders

New member
VIP
Really great indicator for S & P futures traders. A bit confused because it seemed in the video he was referring to every three lines crossed as a standard deviation, but maybe I am mistaken--I thought each line was one deviation. Regardless, the price often bounces off or forcefully passes through these levels.
From my own personal experience with this,refer and do your best to understand the belle curve and from there you will understand the deviation levels...
 

Similar threads

Top