Vanna Thinkscript

aeb

New member
VIP
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
    2024-01-08_16-26-54.jpg
    56 KB · Views: 222
  • F6u-WHZXYAA4DMS.jpg
    F6u-WHZXYAA4DMS.jpg
    55.1 KB · Views: 220

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

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

#https://usethinkscript.com/threads/vanna-thinkscript.17654/
#Vanna Thinkscript
#aeb  Jan 8, 2024  #2
# a thinkscript for Vanna?

# look at formulas on this page to figure out code
#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);
def diff2b = CountTradingDays(t, 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;

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

addchartbubble(0,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
    img2.JPG
    132.5 KB · Views: 123
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;
 
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.
1708455138044.png
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
407 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.
Back
Top