Saturday, April 28, 2012

thinkscript included: hiv delta

hiv delta is the difference between historical and implied volatility. implied volatility is a calculation of the underlying equity volatility based on the pricing of options. historical volatility is a calcuation of volatility based on the actual equity pricing over a recent period (20 bars by default.) if you are trying to decide if options are richly priced then you might want to compare the iv with hv. so the idea of my hivdelta study is to give you that comparison as a single histogram study instead of two separate line graphs. here's a picture of sdi_hivdelta in action:

SPY Weekly Chart With sdi_hivdelta.
bright green bars represent where implied minus historical was greater than zero and increasing. dark green bars represent where implied minus historical was greater than zero and decreasing. vice-versa for the red/dark-red bars.

as an option trader i want to be selling options nearly most of the time. this is because i perceive theta-burn on the obligee side of the options contract to be a trading edge. occasionally i want to be a put buyer near a complacent market top. it looks to me like the red/green transitions are the times to be buying a put. what do you think?


here's the code:

#############
#sdi_hivdelta - difference between historical and implied volatility
#hint: plots the histogram of the difference between historical and implied volatility. the idea is that options are richly priced when iv exceeds hv and selling options is the more advantageous strategy. source:
http://www.smalldoginvestor.com rev: 1.0

declare lower;
input mode = { "histMinusImp", default "impMinusHist"};
#hint mode: select which way to perform the difference calculation.
input length = 20;
#hint length: number of bars to perform historicalVolatility calculation

def ihDelta = historicalVolatility(length)- impVolatility();

plot hid = if mode == mode.impMinusHist then -ihDelta else ihDelta;
hid.setPaintingStrategy(paintingStrategy.HISTOGRAM);
hid.setlineWeight(5);
hid.assignValueColor(
  if hid < 0 and hid <= hid[1] then color.RED
  else if hid < 0 and hid > hid[1] then color.DARK_RED
  else if hid >= 0 and hid >= hid[1] then color.GREEN
  else color.DARK_GREEN
);
#############

11 comments:

  1. Al, Wonderful....Very nice ToS presentation of Volatility Skew!
    Thank you very much.

    Drew

    ReplyDelete
  2. Hi,

    Great site! I'm trying to find an email address to contact you on to ask if you would please consider adding a link to my website. I'd really appreciate if you could email me back.

    Thanks and have a great day!

    ReplyDelete
  3. shoot me an email at: support@smallDogInvestor.com

    ReplyDelete
  4. What if you don't know how to use the code, any simpler explanation? Great job!

    ReplyDelete
  5. Green bars indicate hedging. Option are traders bracing for a reversal.
    Red bars indicate complacency.
    Does that help?

    ReplyDelete
  6. Hi Allen,

    This is great! I successfully copied the code to TOS.

    Do the green bars mean that premium is rising or getting expensive when compared to historical volitility? So green might be a good time to sell options and red might be a good time to buy options?

    Thanks,
    Steve

    ReplyDelete
  7. Steve, Yes to the first question. After some years of trading options I almost always want to engage in premium selling. The green/red distinction may be more one of strategy i.e. green for credit spreads, red for trade debit spreads.

    ReplyDelete
  8. Hi Allen

    Finding your website/blog was like finding gold! Great content and thanks so much for sharing your knowledge.
    As for the histogram, I reversed the colors so that it shows red as being a good time to sell credits and green for buying debits (to match how ToS indicates a credit or debit spread/options). Does that make sense?

    ReplyDelete
  9. Can you please use the same code but have it just plot lines and have HV be adjustable?

    thanks

    ReplyDelete
    Replies
    1. kevin, i think the modifications you seek are already available. go to the 'edit studies' dialogue and click the gear icon next to the sdi_hivdelta study. from the 'sdi_hivdelta customizing' dialogue you can alter the appearance by selecting a different pattern from the 'draw as' drop-down-menu. also, you can alter the length, the number of bars used for the HV, from that same customizing dialogue.

      Delete