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.
 
T

TOSTrader

New member
VIP
@BenTen what is the pro/cons of using vxn or vix etc?
 
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

New 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

New 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

New 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.
 
Top