Implied or Expected Move Based on Weekly Options Indicator - Per the Picture, this can be used Intraday. If you trade options and don't have a way of knowing how the market it pricing them, you may be missing out!
Shared link: https://tos.mx/bbVk7y
The code below is WIP (work in progress). Implied Volatility Position Calculator.
Code:
# Weekly Options Implied Volatility Plotted intraday
# Mobius
# Chat Room Request
# 02.27.2016
declare Once_Per_Bar;
input series = 1;
input show_label = yes;
input Days_In_Contract = 0;
Assert(series > 0, "'series' must be positive: " + series);
def RTHopen = open(period = AggregationPeriod.Day);
def CurrentYear = GetYear();
def CurrentMonth = GetMonth();
def CurrentDOM = GetDayOfMonth(GetYYYYMMDD());
def Day1DOW1 = GetDayOfWeek(CurrentYear * 10000 + CurrentMonth * 100 + 1); # First DOM is this DOW
def FirstFridayDOM1 = if Day1DOW1 < 6
then 6 - Day1DOW1
else if Day1DOW1 == 6
then 7
else 6;
def SecondFridayDOM = FirstFridayDOM1 + 7;
def ThirdFridayDOM = FirstFridayDOM1 + 14;
def FourthFridayDOM = FirstFridayDOM1 + 21;
def RollDOM = FirstFridayDOM1 + 21; #14; changed to 21 to pick up all Fridays of the current month for weekly options
def ExpMonth1 = if RollDOM > CurrentDOM
then CurrentMonth + series - 1
else CurrentMonth + series;
def ExpMonth2 = if ExpMonth1 > 12
then ExpMonth1 - 12
else ExpMonth1;
def ExpYear = if ExpMonth1 > 12
then CurrentYear + 1
else CurrentYear;
def Day1DOW = GetDayOfWeek(ExpYear * 10000 + ExpMonth2 * 100 + 1);
def FirstFridayDOM = if Day1DOW < 6
then 6 - Day1DOW
else if Day1DOW == 6
then 7
else 6;
def ExpDOM = if currentDOM < FirstFridayDOM -1
then FirstFridayDOM1
else if between(currentDOM, FirstFridayDOM, SecondFridayDOM-1)
then SecondFridayDOM
else if between(currentDOM, SecondFridayDOM, ThirdFridayDOM-1)
then ThirdFridayDOM
else if between(currentDOM, ThirdFridayDOM, FourthFridayDOM-1)
then FourthFridayDOM
else FirstFridayDOM;
def NextFriday = DaysTillDate(ExpYear * 10000 + ExpMonth2 * 100 + ExpDOM);
def ExpirationDate = GetYYYYMMDD() + NextFriday;
def ExpData = (ExpirationDate / 1) + 1;
def yr = Round(GetYear() / 100, 0);
def yr2 = GetYear() - 2000;
def OptionDateString = ExpYear * 10000 + ExpMonth2 * 100 + ExpDOM + 1;
def ATMCprice = if isNaN(close(symbol = GetATMOption(GetUnderlyingSymbol(), OptionDateString, OptionClass.CALL)))
then ATMCprice[1]
else close(symbol = GetATMOption(GetUnderlyingSymbol(), OptionDateString, OptionClass.CALL));
def HPD = if Days_In_Contract == 0 #HPD = Holding Period Days
then NextFriday
else Days_In_Contract;
def t = HPD / 365;
def ClosedForm_IV_est = if isNaN(((ATMCprice[1] * Sqrt(2 * Double.Pi)) / (RTHopen * Sqrt(t))))
then ClosedForm_IV_est[1]
else ((ATMCprice * Sqrt(2 * Double.Pi)) / (RTHopen * Sqrt(t)));
def Intraday_IV = if ClosedForm_IV_est > 0 then ClosedForm_IV_est else double.nan;
def ImpMove = Round((close[1] * Intraday_IV / Sqrt(365)) / tickSize(), 0) * tickSize();
plot upper = RTHopen + ImpMove[1];
plot lower = RTHopen - ImpMove[1];
upper.SetStyle(Curve.Firm);
upper.SetDefaultColor(Color.Cyan);
lower.SetStyle(Curve.Firm);
lower.SetDefaultColor(Color.Cyan);
def ActualMove = close[1] - RTHopen;
AddLabel(show_label and IsOptionable(), "ATM Call option is " +
GetATMOption(GetUnderlyingSymbol(), OptionDateString, OptionClass.CALL) +
" Price = $" +
ATMCprice +
" Intraday IV = " +
AsPercent(ClosedForm_IV_est) +
" Implied Move = +- " +
AsDollars(ImpMove) +
" Actual Move = " +
AsDollars(ActualMove)
, if close > RTHopen then color.green else color.red);
# End Code Weekly Options
Shared link: https://tos.mx/bbVk7y
Scanner for Weekly Implied Move
Code:
# Weekly Implied Move Scan
# Mobius
# V02.02.2013
# Use on DAILY aggregation ONLY
def IV = if IsNaN(Imp_Volatility())
then IV[1]
else Imp_Volatility();
def c = if getDayOfWeek(getYYYYMMDD()) == 5
then close
else c[1];
def Fri_IV = if getDayOFWeek(getYYYYMMDD()) == 5
then IV
else Fri_IV[1];
def ImpliedMove = Round(((c * Fri_IV) / Sqrt(365)) / TickSize(), 0) * TickSize();
def Fri_IM = if getDayOfWeek(getYYYYMMDD()) == 5
then ImpliedMove
else Fri_IM[1];
# Comment out (#) the scan plot NOT wanted
plot upperIM = close crosses above (c + Fri_IM);
#plot lowerIM = close crosses below (c - Fri_IM);
Implied Move Label (with IV)
Code:
# IV and Implied Move Approximation Label
# Mobius
def IV = if IsNaN(Imp_Volatility(period = AggregationPeriod.DAY))
then IV[1]
else Imp_Volatility(period = AggregationPeriod.DAY);
def ImpliedMove = (open * IV) / Sqrt(365);
AddLabel(1, "IV = " + AsPercent(IV) + " Implied Move = " + AsDollars(ImpliedMove), color.white);
Implied Move for Different Series IV
Study plots the intraday implied volatility range with the mean as a user input of the previous close, todays open or the previous Friday. Fibonacci lines are also plotted for trading the range. The Fibonacci lines along with a cloud for the overall range can be turned on and off with user inputs.
Rich (BB code):
#- Mobius_ Implied Move For Different Series IV
#- Mobius
#- V01.03.2017
input show_label = yes;
input Series_IV = 1; #hint Series_IV: Series 1 is closest expirery.
input DefTime = {"Today", default "Yesterday", "Friday"};
input Label_Color_Choice = {default "pink", "cyan", "orange", "gray", "yellow", "red", "green", "dark_gray", "light_yellow", "white"};
input Show_Cloud = yes;
input Show_Fibs = yes;
assert(series_IV > 0, "'series' must be positive: " + series_IV);
def o = open;
def c = close;
def bar = barNumber();
def CurrentYear = getYear();
def CurrentMonth = getMonth();
def CurrentDOM = getDayOfMonth(getYyyyMmDd());
def Day1DOW1 = getDayOfWeek(CurrentYear * 10000 + CurrentMonth * 100 + 1);
def FirstFridayDOM1 = if Day1DOW1 < 6
then 6 - Day1DOW1
else if Day1DOW1 == 6
then 7
else 6;
def RollDOM = FirstFridayDOM1 + 14;
def ExpMonth1 = if RollDOM > CurrentDOM
then CurrentMonth + series_IV - 1
else CurrentMonth + series_IV;
def ExpMonth2 = if ExpMonth1 > 12
then ExpMonth1 - 12
else ExpMonth1;
def ExpYear = if ExpMonth1 > 12
then CurrentYear + 1
else CurrentYear;
def Day1DOW = getDayOfWeek(ExpYear * 10000 + ExpMonth2 * 100 + 1);
def FirstFridayDOM = if Day1DOW < 6
then 6 - Day1DOW
else if Day1DOW == 6
then 7
else 6;
def ExpDOM = FirstFridayDOM + 14;
def N3rdF = if IsNaN(c)
then Double.NaN
else daysTillDate(ExpYear * 10000 + ExpMonth2 * 100 + ExpDOM);
def CurrentDOW = GetDayOfWeek(GetYYYYMMDD());
def Fcbar = if CurrentDOW == 5 and SecondsTillTime(1600) == 0
then bar
else Fcbar[1];
def seriesIV = if isNaN(SeriesVolatility(series = Series_IV))
then seriesIV[1]
else SeriesVolatility(series = Series_IV);
def t;
def tBar;
def nDays;
switch (DefTime)
{
case Today:
t = if SecondsFromTime(0930) == 0
then o
else t[1];
tbar = if SecondsFromTime(0930) == 0
then bar
else double.nan;
case Yesterday:
t = if secondsTillTime(1600) == 0
then c
else t[1];
tbar = if secondsFromTime(1600) == 0
then bar
else double.nan;
case Friday:
t = if BarNumber() == Fcbar
then c
else t[1];
tbar = Fcbar;
}
if Series_IV == 1 and CurrentDOW == 1
{
nDays = 3;
}
else if Series_IV == 1 and CurrentDOW == 2
{
nDays = 2;
}
else if Series_IV == 1 and CurrentDOW == 3
{
nDays = 1;
}
else if Series_IV == 1 and CurrentDOW == 4
{
nDays = 2;
}
else if Series_IV == 1 and CurrentDOW == 5
{
nDays = 1;
}
else if Series_IV >= 2
{
nDays = N3rdF;
}
else
{
nDays = nDays[1];
}
def ImpMove = Round(((t * seriesIV * Sqrt(nDays)) / Sqrt(365)) / TickSize(), 0) * TickSize();
plot mean = if bar >= HighestAll(tBar)
then HighestAll(if isNaN(close[-1])
then t
else double.nan)
else double.nan;
mean.SetStyle(Curve.Long_Dash);
mean.SetLineWeight(2);
mean.SetDefaultColor(GetColor(Label_Color_Choice));
plot upper = if bar >= HighestAll(tBar)
then HighestAll(if isNaN(c[-1])
then t + ImpMove
else double.nan)
else Double.NaN;
upper.SetDefaultColor(GetColor(Label_Color_Choice));
upper.SetLineWeight(2);
upper.SetPaintingStrategy(PaintingStrategy.DASHES);
plot lower = if bar >= HighestAll(tBar)
then HighestAll(if isNaN(c[-1])
then t - ImpMove
else double.nan)
else Double.NaN;
lower.SetDefaultColor(GetColor(Label_Color_Choice));
lower.SetLineWeight(2);
lower.SetPaintingStrategy(PaintingStrategy.DASHES);
Addcloud(if Show_Cloud
then lower
else double.nan, upper, color.dark_gray, color.dark_gray);
plot upper236 = if bar >= HighestAll(tBar) and Show_Fibs
then HighestAll(if isNaN(close[-1])
then Round((((upper - mean) * .236) + mean) / TickSize(), 0) * TickSize()
else double.nan)
else double.nan;
upper236.SetStyle(Curve.Short_Dash);
upper236.SetDefaultColor(Color.dark_gray);
plot upper382 = if bar >= HighestAll(tBar) and Show_Fibs
then HighestAll(if isNaN(close[-1])
then Round((((upper - mean) * .382) + mean) / TickSize(), 0) * TickSize()
else double.nan)
else double.nan;
upper382.SetStyle(Curve.Short_Dash);
upper382.SetDefaultColor(Color.dark_gray);
plot upper50 = if bar >= HighestAll(tBar) and Show_Fibs
then HighestAll(if isNaN(close[-1])
then Round((((upper - mean) * .5) + mean) / TickSize(), 0) * TickSize()
else double.nan)
else double.nan;
upper50.SetStyle(Curve.Short_Dash);
upper50.SetDefaultColor(Color.dark_gray);
plot upper618 = if bar >= HighestAll(tBar) and Show_Fibs
then HighestAll(if isNaN(close[-1])
then Round((((upper - mean) * .618) + mean) / TickSize(), 0) * TickSize()
else double.nan)
else double.nan;
upper618.SetStyle(Curve.Short_Dash);
upper618.SetDefaultColor(Color.dark_gray);
plot upper786 = if bar >= HighestAll(tBar) and Show_Fibs
then HighestAll(if isNaN(close[-1])
then Round((((upper - mean) * .786) + mean) / TickSize(), 0) * TickSize()
else double.nan)
else double.nan;
upper786.SetStyle(Curve.Short_Dash);
upper786.SetDefaultColor(Color.dark_gray);
plot lower236 = if bar >= HighestAll(tBar) and Show_Fibs
then HighestAll(if isNaN(close[-1])
then Round((mean - (mean - lower) * .236) / TickSize(), 0) * TickSize()
else double.nan)
else double.nan;
lower236.SetStyle(Curve.Short_Dash);
lower236.SetDefaultColor(Color.dark_gray);
plot lower382 = if bar >= HighestAll(tBar) and Show_Fibs
then HighestAll(if isNaN(close[-1])
then Round((mean - (mean - lower) * .382) / TickSize(), 0) * TickSize()
else double.nan)
else double.nan;
lower382.SetStyle(Curve.Short_Dash);
lower382.SetDefaultColor(Color.dark_gray);
plot lower50 = if bar >= HighestAll(tBar) and Show_Fibs
then HighestAll(if isNaN(close[-1])
then Round((mean - (mean - lower) * .5) / TickSize(), 0) * TickSize()
else double.nan)
else double.nan;
lower50.SetStyle(Curve.Short_Dash);
lower50.SetDefaultColor(Color.dark_gray);
plot lower618 = if bar >= HighestAll(tBar) and Show_Fibs
then HighestAll(if isNaN(close[-1])
then Round((mean - (mean - lower) * .618) / TickSize(), 0) * TickSize()
else double.nan)
else double.nan;
lower618.SetStyle(Curve.Short_Dash);
lower618.SetDefaultColor(Color.dark_gray);
plot lower786 = if bar >= HighestAll(tBar) and Show_Fibs
then HighestAll(if isNaN(close[-1])
then Round((mean - (mean - lower) * .786) / TickSize(), 0) * TickSize()
else double.nan)
else double.nan;
lower786.SetStyle(Curve.Short_Dash);
lower786.SetDefaultColor(Color.dark_gray);
AddLabel(show_label, "Series " + Series_IV + " IV = " + AsPercent(seriesIV) +
" " + nDays + " Day(s) Remaining. " +
" Implied Move = " + AsDollars(ImpMove) +
" Starting Value = " + AsDollars(t), GetColor(Label_Color_Choice));
# End Code Implied Moves From Series IV
The code below is WIP (work in progress). Implied Volatility Position Calculator.
Code:
# Archive Name: Implied Volatility Position Calculator_JQ
# Archive Tab: Volatility
# Tos Name: IV_PositionCalc_JohnnyQuotron
#
# IV_PositionCalcV2_JohnnyQuotron
# Last modified 2018-03-25...adds chartBubbles and chart label defaults
# Code clones incorporates snippets from TDAmeritrade
#
# 2018-04-10 Adds mobius code for vertical earnings datelines
#hint: This study is a work in progress. It is an attempt to remind investors to adjust their position sizes when the volatility of the market changes and/or for the volatility of the security the investor is considering taking a position in.
#The study creates four labels describing suggested positions depending on the desires of the investor.
#The author has chosen a Benchmark Position size of 100 shares of SPY. This Benchmark is adjustable by the investor without altering the code. You may choose to display all four preconfigured labels or only a portion of them. The Author prefers that a chart of the Historical Volatility of the Benchmark Index and the Prospect Security be placed immediately above the subchart containing the labels. But you should do whatever works best for you and your style.
# This study pairs with a HV position calculator
declare lower;
input displayIVLabels = no; #Hint displayIVLabels: Display colored labels containing symbol_IV and IV for Benchmark and Symbol
input displayBenchmarkPosition = yes; #Hint displayBenchmarkPosition: Display label denoting Benchmark Symbol and share size
input Show_Unadjusted_Positions = yes; #hint Show_Unadjusted_Positions: Show label with position and share counts for Full, Half and Quarter positions of Prospect Security unadjusted for the Historical Volatility of either the Benchmark or the Prospect Security.
input Show_Adjusted_for_Bmk_IV = no; #Hint Show_Adjusted_for_Bmk_HV: Default no. Show label with position and share counts for Full, Half and Quarter positions for the Prospect Security adjusted for the Historical Volatility of the Benchmark.
input Show_Adjusted_for_Security_IV = yes; #Hint Show_Adjusted_for_Security_HV: Default yes. Show label with position and share counts for Full, Half and Quarter positions for the Prospect Security adjusted for the Historical Volatility of the Prospect Security.
input Show_Adjusted_for_Diff_in_IV = no; #Hint Show_Adjusted_for_Diff_in_HV: Default no. Show label with position and share counts for Full, Half and Quarter positions for the Prospect Security adjusted for the difference in Historical Volatility between the Benchmark or the Prospect Security.
#
# BEGIN BENCHMARK INDEX CODE
#
input Benchmark_Index = "SPY";
input Benchmark_shares = 100;
input displayEarningsLines = yes;
#
#
#
# Implied Volatility Code
#
#
plot Symbol_IV = 1 + imp_volatility();
Symbol_IV.SetDefaultColor(Color.pink);
plot Benchmark_IV = 1 + imp_volatility(Benchmark_Index);
Benchmark_IV.SetDefaultColor(Color.WHITE);
def Relative_IV = Symbol_IV / Benchmark_IV;
#
# Positions - Preparatory Math for Positions
#
def Benchmark_Close = close(Benchmark_Index);
def Prospect_Close = close;
def full_position_amount = Benchmark_Close * Benchmark_shares;
def full_position_shares = full_position_amount / Prospect_Close;
def half_position_shares = full_position_shares * 0.5;
def quarter_position_shares = full_position_shares * 0.25;
def Bmk_IV_adj_full_position_amount = full_position_amount / Benchmark_IV;
def Bmk_IV_adj_full_position_shares = Bmk_IV_adj_full_position_amount / Prospect_Close;
def Bmk_IV_adj_half_position_shares = Bmk_IV_adj_full_position_shares * 0.5;
def Bmk_IV_adj_quarter_position_shares = Bmk_IV_adj_full_position_shares * 0.25;
def Symbol_IV_adj_full_position_amount = full_position_amount / Symbol_IV;
def Symbol_IV_adj_full_position_shares = Symbol_IV_adj_full_position_amount / Prospect_Close;
def Symbol_IV_adj_half_position_shares = Symbol_IV_adj_full_position_shares * 0.5;
def Symbol_IV_adj_quarter_position_shares = Symbol_IV_adj_full_position_shares * 0.25;
def Relative_IV_adj_full_position_amount = full_position_amount / Relative_IV;
def Relative_IV_adj_full_position_shares = Relative_IV_adj_full_position_amount / Prospect_Close;
def Relative_IV_adj_half_position_shares = Relative_IV_adj_full_position_shares * 0.5;
def Relative_IV_adj_quarter_position_shares = Relative_IV_adj_full_position_shares * 0.25;
#
# Label and ChartBubble Code
#
addlabel (displayIVLabels, getsymbol() + " IV " + astext(Symbol_IV), color.pink);
addlabel (displayIVLabels, Benchmark_Index + " IV " + astext(Benchmark_IV), color.white);
AddLabel (displayBenchmarkPosition, " Benchmark Position: " + Benchmark_shares + " shares of " + Benchmark_Index + " = " + AsDollars (Round(full_position_amount, 0)) + " ", Color.white);
AddLabel(Show_Unadjusted_Positions, " Unadjusted " + GetSymbol() + " Positions | Full: " + RoundUp(full_position_shares, 0) + " shares | Half: " + RoundUp(half_position_shares, 0) + " shares | Qtr: " + RoundUp(quarter_position_shares, 0) + " shares ", Color.white );
AddLabel(Show_Adjusted_for_Bmk_IV, " Adjusted for " + Benchmark_Index + " Implied Volatility of " + AsText(Benchmark_IV) + " | Adjusted " + GetSymbol() + " Positions " + AsDollars (Round(Bmk_IV_adj_full_position_amount, 0)) + " | Full: " +
RoundUp(Bmk_IV_adj_full_position_shares, 0) + " shares | Half: " + RoundUp(Bmk_IV_adj_half_position_shares, 0) + " shares | Qtr: " + RoundUp(Bmk_iV_adj_quarter_position_shares, 0) + " shares ", Color.pink );
AddLabel(Show_Adjusted_for_Security_IV, " Adjusted for " + GetSymbol() + " Implied Volatility of " + AsText(Symbol_IV) +
" | Adjusted " + GetSymbol() + " Positions " + AsDollars (Round(Symbol_IV_adj_full_position_amount, 0)) + " | Full: " + RoundUp(Symbol_IV_adj_full_position_shares, 0) + " shares | Half: " + RoundUp(Symbol_IV_adj_half_position_shares, 0) + " shares | Qtr: " + RoundUp(Symbol_IV_adj_quarter_position_shares, 0) + " shares ", Color.pink );
AddLabel(Show_Adjusted_for_Diff_in_IV, " Adjusted for the Ratio (" + GetSymbol() + " IV. / " + Benchmark_Index + " IV.) " + AsText(Relative_IV) + " | Adjusted " + GetSymbol() + " Positions " + AsDollars (Round(Relative_IV_adj_full_position_amount, 0)) + " | Full: " + RoundUp(Relative_IV_adj_full_position_shares, 0) + " shares | Half: " + RoundUp(Relative_IV_adj_half_position_shares, 0) + " shares | Qtr: " + RoundUp(Relative_IV_adj_quarter_position_shares, 0) + " shares ", Color.pink );
Input Offset = 0;
def LastBar = !IsNaN(open) and IsNaN(open [-1] ) ;
Def BubbleLocation = LastBar[Offset];
def barNum = barNumber();
addchartbubble(BubbleLocation , benchmark_IV, Benchmark_Index + " IV " + astext(benchmark_IV) , color.white, no);
addchartbubble(BubbleLocation , symbol_IV, getsymbol() + " IV " + astext(symbol_IV) , color.pink, yes);
#
# End V1 Code
# Historic VS Implied Volatility At Earnings
# Mobius
# V01.2015
def isBefore = HasEarnings(EarningTime.BEFORE_MARKET);
def isAfter = HasEarnings(EarningTime.AFTER_MARKET);
def isUnspecified = HasEarnings() and !isBefore and !isAfter;
AddVerticalLine(isBefore and displayEarningsLines,
" Earn Before",
Color.yellow,
Curve.LONG_DASH);
AddVerticalLine(isAfter and displayEarningsLines,
" Earn After",
Color.yellow,
Curve.LONG_DASH);
AddVerticalLine(isUnspecified and displayEarningsLines,
" Earnings",
Color.yellow,
Curve.LONG_DASH);
#