# Vanna Thinkscript

#### aeb

##### New member
Could someone help me code a thinkscript for Vanna? I know it can be done because I've seen it (pictures below) but when trying to use chatgpt to help me, it has gotten me nowhere. The thinkscript was coded from the formula in the pictures.

#### Attachments

• 2024-01-08_16-26-54.jpg
56 KB · Views: 273
• F6u-WHZXYAA4DMS.jpg
55.1 KB · Views: 270

Legit I been wanting to see if anyone here can code something for vanna and gamma! I would love to have this information on my think or swim

Could someone help me code a thinkscript for Vanna? I know it can be done because I've seen it (pictures below) but when trying to use chatgpt to help me, it has gotten me nowhere. The thinkscript was coded from the formula in the pictures.

EDIT -----------

i think this is the right formulas.
i looked at that ref web page below, and changed my study. now it plots something.

i see spartan.ts posted a study, so maybe go with that...

-----------------------------------

k isn't defined in formula image. i think it is strike

Code:
``````#vanna_00

#Vanna Thinkscript
#aeb  Jan 8, 2024  #2
# a thinkscript for Vanna?

#https://financetrainingcourse.com/education/2014/06/vega-volga-and-vanna-the-volatility-greeks/

declare lower;

def na = double.nan;
def bn = barnumber();

# ref sym  .SPY240216C484

# dates
# expiry date    YYYYMMDD
input expire_date = 20240216;

# current date
#  if tb > expire date , in  CountTradingDays()  then error.  add if then to fix value of t
def tb = GetYYYYMMDD();
def t = if isnan(close) then t[1] else tb;

# experiment with 2 ways to count days.   use diff2
#   T-t  , days till expire
def diff1b = DaysTillDate(expire_date);

# fraction of year , /365  or  /252
def diff1 = diff1b/365;
def diff2 = diff2b/252;

def iv = imp_volatility();

#  k  - strike
def k = 486;

# dividend rate ,  0
def q = 0;

# risk free rate ??
def r = .27;

def s = close;

#  based on ref web page,  (t_exp - t)   should be  (t_exp - t)/365 , a fraction of a year
#def d1 = (log(s/k) + (r - q + (power(iv,2)/2)) * (t_exp - t)) / (iv * sqrt(t_exp - t));
def d1 = (log(s/k) + (r - q + (power(iv,2)/2)) * (diff2)) / (iv * sqrt(diff2));

def n1 = exp(-(power(d1,2))/2) / (2 * double.pi);

#def vanna = Sqrt(t_exp - t) * n1 * (1-d1);
def vanna = Sqrt(diff2) * n1 * (1-d1);

plot z = vanna;

plot z0 = 0;

#------------------------------

d1 + "\n" +
n1 + "\n" +
vanna + "\n" +
diff1b + "\n" +
diff2b + "\n" +
diff1 + "\n" +
diff2
, color.yellow, yes);

#``````

this page seems to list the same formula image and might explain the numbers.
https://financetrainingcourse.com/education/2014/06/vega-volga-and-vanna-the-volatility-greeks/

#### Attachments

• img2.JPG
132.5 KB · Views: 197
Last edited:
Could someone help me code a thinkscript for Vanna? I know it can be done because I've seen it (pictures below) but when trying to use chatgpt to help me, it has gotten me nowhere. The thinkscript was coded from the formula in the pictures.
can find it with search

Code:
``````def Under =
Close(GetunderlyingSymbol());
def Strike =
GetStrike();
def DTE =
GetDaysToExpiration() / 365;
def Rate =
GetInterestRate() * 0.01;
def Div =
if !isNaN(GetDividend()) then GetDividend()
else Div[1];
def Yield =
if Div then Div / Under
else 0;
def IV =
Imp_Volatility(GetUnderlyingSymbol());
def Pi =
Double.Pi; #3.14
def e =
2.718281828; #Euler's number (sort of like Pi)
def D1 =
(Log(Under/Strike) + (rate - yield + (Power(IV,2) / 2)) * DTE) / (IV * Sqrt(DTE));
def N1D1 =
power(e,-(power(D1,2)/2)) * (1 / (2 * Pi));
def Van =
SqRt(DTE) * N1D1 * (1 - D1); #assumes 0 dividend

plot Vanna = Van * -1;``````

This would be much more useful as a per strike bar chart... like the Gamma Exposure chart on

can find it with search

Code:
``````def Under =
Close(GetunderlyingSymbol());
def Strike =
GetStrike();
def DTE =
GetDaysToExpiration() / 365;
def Rate =
GetInterestRate() * 0.01;
def Div =
if !isNaN(GetDividend()) then GetDividend()
else Div[1];
def Yield =
if Div then Div / Under
else 0;
def IV =
Imp_Volatility(GetUnderlyingSymbol());
def Pi =
Double.Pi; #3.14
def e =
2.718281828; #Euler's number (sort of like Pi)
def D1 =
(Log(Under/Strike) + (rate - yield + (Power(IV,2) / 2)) * DTE) / (IV * Sqrt(DTE));
def N1D1 =
power(e,-(power(D1,2)/2)) * (1 / (2 * Pi));
def Van =
SqRt(DTE) * N1D1 * (1 - D1); #assumes 0 dividend

plot Vanna = Van * -1;``````

The problem with this formula is it doesn't scale correctly when paired with gamma (like in my original post). I'm sure it is just a matter of tweaking one or two things but can't figure it out.

The problem with this formula is it doesn't scale correctly when paired with gamma (like in my original post). I'm sure it is just a matter of tweaking one or two things but can't figure it out.
View attachment 21118
Either left axis one of them, or real_size, or use a normalized scale.

you may also want to change it from line to histogram bars in the study's settings.

87k+ Posts
253 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?