Implied Move Based on Weekly Options for ThinkorSwim

markos

Well-known member
VIP
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!

2MPSiiK.png


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);




#
 
I don't remember but I think this one came from Tastytrade as well. What I like about is is that it has the 1 and 2 standard dev for the dly, weekly, and monthly charts and i placed it below the chart but can be changed to go on the chart. Simply "declare upper:"

IV Rank & Implied Volatility for 1 & 2 SDV for Daily, Weekly and Monthly Charts

Code
Code:
declare lower;

#IVPercentile

def vol = imp_volatility();

input DisplayIVPercentile = yes;

input DisplayImpVolatility= yes;

input DisplayDaily1StandardDev = yes;

input DisplayWeekly1StandardDev = yes;

input DisplayMonthly1StandardDev = yes;

input DisplayDaily2StandardDev = yes;

input DisplayWeekly2StandardDev = yes;

input DisplayMonthly2StandardDev = yes;

input TimePeriod = 252;



def data = if !isNaN(vol) then vol else vol[-1];

def hi = highest(data, TimePeriod);

def lo = lowest(data, TimePeriod);

plot Percentile = (data - lo) / (hi - lo) * 100;

def lowend = Percentile < 25;

def highend = Percentile > 50;



#Labels

addlabel(DisplayIVPercentile , concat("IV Rank: ",aspercent(Percentile /100)), if lowend then color.red else if highend then color.green else color.yellow);



addlabel(DisplayImpVolatility, concat("ImpVolatility: ",aspercent(vol)), if lowend then color.red else if highend then color.green else color.yellow);



def ImpPts = (vol / Sqrt(252)) * close;

AddLabel(DisplayDaily1StandardDev , Concat("Daily 1 SD +/- $", Astext( ImpPts, NumberFormat.TWO_DECIMAL_PLACES)), if lowend then color.red else if highend then color.green else color.yellow); ;



def ImpPts2 = (vol / Sqrt(52)) * close;

AddLabel(DisplayWeekly1StandardDev, Concat("Weekly 1 SD +/- $", Astext( ImpPts2, NumberFormat.TWO_DECIMAL_PLACES)), if lowend then color.red else if highend then color.green else color.yellow); ;



def ImpPts3 = (vol / Sqrt(12)) * close;

AddLabel(DisplayMonthly1StandardDev, Concat("Monthly 1 SD +/- $", Astext( ImpPts3, NumberFormat.TWO_DECIMAL_PLACES)), if lowend then color.red else if highend then color.green else color.yellow); ;



def ImpPts4 = ImpPts * 2.09;

AddLabel(DisplayDaily2StandardDev , Concat("Daily 2 SD +/- $", Astext( ImpPts4, NumberFormat.TWO_DECIMAL_PLACES)), if lowend then color.red else if highend then color.green else color.yellow);



def ImpPts5 = ImpPts2 * 2.09;

AddLabel(DisplayWeekly2StandardDev , Concat("Weekly 2 SD +/- $", Astext( ImpPts5, NumberFormat.TWO_DECIMAL_PLACES)), if lowend then color.red else if highend then color.green else color.yellow);



def ImpPts6 = ImpPts3 * 2.09;

AddLabel(DisplayWeekly2StandardDev , Concat("Monthly 2 SD +/- $", Astext( ImpPts6, NumberFormat.TWO_DECIMAL_PLACES)), if lowend then color.red else if highend then color.green else color.yellow);



plot LowVol = 25;

plot HighVol = 50;



LowVol.SetDefaultColor(GetColor(5));

HighVol.SetDefaultColor(GetColor(6));

Here is another version I have. I can't make sense of the labels, but it plots the lines

Code:
# TheoTrade_Weely_Expected_Move
# Copyright TheoTrade LLC
# V08.11.2017
# Free for use. Header credits must be included when any form of the code included in # this package is used.
#
# User assumes all risk. Author not responsible for errors or use of tool.
# scripted by Todd Rind
#
# Thanks to all those who have freely shared ThinkScript concepts over the Web.
#
# The study is used to analyze the DAILY CLOSING performance of an equity against
# the expected move (EM) for any ticker.
# The study works for daily aggregation only.
# Best performance will be against ETF's due to the option and stock implied volatility
# typically being close. When looking at equities, earnings will cause a difference
# between volatility for options and stock. That is, option volatility may be
# elevated as compared to the stock volatility. Since option volatility cannont
# be accessed from ThinkScript, the script EM will be lower than the EM found
# in the option chain.
#
# NEW LOGIC
#
# Drawing line from previous close.
# Completed the daily calculations for inside EM.
# Turned the "dots" for the bars exceeding EM to RED.
# Added logic for "touches". The "dots" for touches are BLUE.
# Touches are a calculated bandwidth around the EM bars. EX:
# High touches occur when either the high or close is within the calculated
# bandwith of the EM. Default is 90% of EM.
#
# MINOR ISSUES TO MONITOR
#
# Remove the bars not marked with EM levels from the % occurance calculation.
# Fixed by making sure high & low bar > 1.
#
# Note sent to TOS Support about counter issues when checking day number-no response
# from TO. It appears that occasionally a bar out of view is used as the start.
# Seems to sometimes make Friday count one to many.
#
#-------------------- Header End ----------------------------

def agg = GetAggregationPeriod();

def err_label = if agg == AggregationPeriod.DAY then
no
else
yes;

AddLabel(err_label, "Expected Move Study - Works with daily aggregation only.", Color.RED);

input em_skew_percent = 70;
input em_bandwidth = 100;
input touches_percent = 90;

input show_high_bubble = yes;
input show_low_bubble = yes;
input show_high_dots = yes;
input show_low_dots = yes;
input show_touches_high_dots=yes;
input show_touches_low_dots=yes;
input show_touches_daily=yes;

input show_em_calc = yes;
input show_highlow_detail = yes;
input show_highlow_daily = yes;
input show_highlow_daily_inside= yes;

#
# em_bandwith allow for narrow or wider ranges to be tested. 1.0 is normal.
# for 0.5 Std Dev, then em_bandwidth = 0.5 Entered in % changed to decimal.
# That is, allows for ajustment so that analysis can be made of Iron Fly expected #performance.

#
# suggest leaving start & expire static.
# start = 1 ==> Will pull EM data from previous bar. Assumed to be FRIDAY. CLOSING
# then expires next Friday ==> 6 days. Assumes
# calculating expected move on Saturday.
#
#
#
# Note - no longer allowing EM calculation days to change.
#
# input em_day_start = 1;
#input em_day_expire = 6;

#
# routine to force looking for the highest bar number
#

def barcount = BarNumber();
def lastbar = HighestAll(if IsNaN(high) then 0 else barcount);

def ivGapHi;
def expmove;
def high_bar;
def low_bar;
def em_close;
def weekcnt;
def touch_high_bar;
def touch_low_bar;

############ logic to check for holidays #########
#
# Change EM calculation on Monday (Day #1) or when last trading day
# was a Friday (Day #5) and the current day is Tuesday (Day #2).
#
# Continue assumption that EM is being calculated on a Saturday. 6 days
# to expire.
#
#

if GetDayOfWeek(GetYYYYMMDD()) == 1 or (getdayofweek(getYYYYMMDD()[1]) == 5 and getdayofweek(getyyyymmdd()) == 2)
then {

ivGapHi = imp_volatility()[1];

expmove = close[1] * ivGapHi * Sqrt(6) / Sqrt(365) * em_skew_percent / 100 * em_bandwidth / 100;

high_bar = close[1] + expmove;
touch_high_bar = close[1] + (expmove * touches_percent/100);
low_bar = close[1] - expmove;
touch_low_bar = close[1] - (expmove * touches_percent/100);
em_close = close[1];
weekcnt=weekcnt[1] + 1;

}
else {
ivGapHi = ivGapHi[1];
expmove = expmove[1];
high_bar = high_bar[1];
touch_high_bar = touch_high_bar[1];
low_bar = low_bar[1];
touch_low_bar= touch_low_bar[1];
em_close = em_close[1];
weekcnt = weekcnt[1];

}

#
# calculations for over EM
#

def peak = if high_bar > 1 and close > high_bar then 1 else 0;

def peakcnt = if peak then peakcnt[1] + 1 else peakcnt[1];
def peakamt = if peak then peakamt[1] + close - high_bar else peakamt[1];

#################### daily bar logic -- over EM
#
# Continue to monitor Friday's for count.

def fripeak = if high_bar > 1 and close > high_bar and GetDayOfWeek(GetYYYYMMDD()) == 5 then 1 else 0;
def fripeakcnt = if fripeak then fripeakcnt[1] + 1 else fripeakcnt[1];
def fripeakamt = if fripeak then fripeakamt[1] + close - high_bar else fripeakamt[1];

def thupeak = if high_bar > 1 and close > high_bar and GetDayOfWeek(GetYYYYMMDD()) == 4 then 1 else 0;
def thupeakcnt = if thupeak then thupeakcnt[1] + 1 else thupeakcnt[1];
def thupeakamt = if thupeak then thupeakamt[1] + close - high_bar else thupeakamt[1];

def wenpeak = if high_bar > 1 and close > high_bar and GetDayOfWeek(GetYYYYMMDD()) == 3 then 1 else 0;
def wenpeakcnt = if wenpeak then wenpeakcnt[1] + 1 else wenpeakcnt[1];
def wenpeakamt = if wenpeak then wenpeakamt[1] + close - high_bar else wenpeakamt[1];

def tuepeak = if high_bar > 1 and close > high_bar and GetDayOfWeek(GetYYYYMMDD()) == 2 then 1 else 0;
def tuepeakcnt = if tuepeak then tuepeakcnt[1] + 1 else tuepeakcnt[1];
def tuepeakamt = if tuepeak then tuepeakamt[1] + close - high_bar else tuepeakamt[1];

def monpeak = if high_bar > 1 and close > high_bar and GetDayOfWeek(GetYYYYMMDD()) == 1 then 1 else 0;
def monpeakcnt = if monpeak then monpeakcnt[1] + 1 else monpeakcnt[1];
def monpeakamt = if monpeak then monpeakamt[1] + close - high_bar else monpeakamt[1];

#
# calculations for under EM
#

def valley = if low_bar > 1 and close < low_bar then 1 else 0;

def valleycnt = if valley then valleycnt[1] + 1 else valleycnt[1];
def valleyamt = if valley then valleyamt[1] + low_bar - close else valleyamt[1];

#################### daily bar logic -- uner EM
#
# Continue to monitor Friday's for count.

def frivalley = if low_bar > 1 and close < low_bar and GetDayOfWeek(GetYYYYMMDD()) == 5 then 1 else 0;
def frivalleycnt = if frivalley then frivalleycnt[1] + 1 else frivalleycnt[1];
def frivalleyamt = if frivalley then frivalleyamt[1] + low_bar - close else frivalleyamt[1];

def thuvalley = if low_bar > 1 and close < low_bar and GetDayOfWeek(GetYYYYMMDD()) == 4 then 1 else 0;
def thuvalleycnt = if thuvalley then thuvalleycnt[1] + 1 else thuvalleycnt[1];
def thuvalleyamt = if thuvalley then thuvalleyamt[1] + low_bar - close else thuvalleyamt[1];

def wenvalley = if low_bar > 1 and close < low_bar and GetDayOfWeek(GetYYYYMMDD()) == 3 then 1 else 0;
def wenvalleycnt = if wenvalley then wenvalleycnt[1] + 1 else wenvalleycnt[1];
def wenvalleyamt = if wenvalley then wenvalleyamt[1] + low_bar - close else wenvalleyamt[1];

def tuevalley = if low_bar > 1 and close < low_bar and GetDayOfWeek(GetYYYYMMDD()) == 2 then 1 else 0;
def tuevalleycnt = if tuevalley then tuevalleycnt[1] + 1 else tuevalleycnt[1];
def tuevalleyamt = if tuevalley then tuevalleyamt[1] + low_bar - close else tuevalleyamt[1];

def monvalley = if low_bar > 1 and close < low_bar and GetDayOfWeek(GetYYYYMMDD()) == 1 then 1 else 0;
def monvalleycnt = if monvalley then monvalleycnt[1] + 1 else monvalleycnt[1];
def monvalleyamt = if monvalley then monvalleyamt[1] + low_bar - close else monvalleyamt[1];

#
# Calc within for iron fly
#
#

def monpeakin = if high_bar > 1 and close < high_bar and close >= em_close and GetDayOfWeek(GetYYYYMMDD()) == 1 then 1 else 0;
def monpeakcntin = if monpeakin then monpeakcntin[1] + 1 else monpeakcntin[1];
def monpeakamtin = if monpeakin then monpeakamtin[1] + close - em_close else monpeakamtin[1];

def monvalleyin = if low_bar > 1 and close > low_bar and close < em_close and GetDayOfWeek(GetYYYYMMDD()) == 1 then 1 else 0;
def monvalleycntin = if monvalleyin then monvalleycntin[1] + 1 else monvalleycntin[1];
def monvalleyamtin = if monvalleyin then monvalleyamtin[1] + em_close - close else monvalleyamtin[1];

def tuepeakin = if high_bar > 1 and close < high_bar and close >= em_close and GetDayOfWeek(GetYYYYMMDD()) == 2 then 1 else 0;
def tuepeakcntin = if tuepeakin then tuepeakcntin[1] + 1 else tuepeakcntin[1];
def tuepeakamtin = if tuepeakin then tuepeakamtin[1] + close - em_close else tuepeakamtin[1];

def tuevalleyin = if low_bar > 1 and close > low_bar and close < em_close and GetDayOfWeek(GetYYYYMMDD()) == 2 then 1 else 0;
def tuevalleycntin = if tuevalleyin then tuevalleycntin[1] + 1 else tuevalleycntin[1];
def tuevalleyamtin = if tuevalleyin then tuevalleyamtin[1] + em_close - close else tuevalleyamtin[1];

def wenpeakin = if high_bar > 1 and close < high_bar and close >= em_close and GetDayOfWeek(GetYYYYMMDD()) == 3 then 1 else 0;
def wenpeakcntin = if wenpeakin then wenpeakcntin[1] + 1 else wenpeakcntin[1];
def wenpeakamtin = if wenpeakin then wenpeakamtin[1] + close - em_close else
wenpeakamtin[1];

def wenvalleyin = if low_bar > 1 and close > low_bar and close < em_close and GetDayOfWeek(GetYYYYMMDD()) == 3 then 1 else 0;
def wenvalleycntin = if wenvalleyin then wenvalleycntin[1] + 1 else wenvalleycntin[1];
def wenvalleyamtin = if wenvalleyin then wenvalleyamtin[1] + em_close - close else wenvalleyamtin[1];

def thupeakin = if high_bar > 1 and close < high_bar and close >= em_close and GetDayOfWeek(GetYYYYMMDD()) == 4 then 1 else 0;
def thupeakcntin = if thupeakin then thupeakcntin[1] + 1 else thupeakcntin[1];
def thupeakamtin = if thupeakin then thupeakamtin[1] + close - em_close else
thupeakamtin[1];

def thuvalleyin = if low_bar > 1 and close > low_bar and close < em_close and GetDayOfWeek(GetYYYYMMDD()) == 4 then 1 else 0;
def thuvalleycntin = if thuvalleyin then thuvalleycntin[1] + 1 else thuvalleycntin[1];
def thuvalleyamtin = if thuvalleyin then thuvalleyamtin[1] + em_close - close else thuvalleyamtin[1];

def fripeakin = if high_bar > 1 and close < high_bar and close >= em_close and GetDayOfWeek(GetYYYYMMDD()) == 5 then 1 else 0;
def fripeakcntin = if fripeakin then fripeakcntin[1] + 1 else fripeakcntin[1];
def fripeakamtin = if fripeakin then fripeakamtin[1] + close - em_close else fripeakamtin[1];

def frivalleyin = if low_bar > 1 and close > low_bar and close < em_close and GetDayOfWeek(GetYYYYMMDD()) == 5 then 1 else 0;
def frivalleycntin = if frivalleyin then frivalleycntin[1] + 1 else frivalleycntin[1];
def frivalleyamtin = if frivalleyin then frivalleyamtin[1] + em_close - close else frivalleyamtin[1];

#
# touches calculations
#
# testing to determine if high or close was within touches% of highbar
# or
# if low or close was within touches% of lowbar
#

def touchpeak = if high_bar > 1 and ((high < high_bar and high >= touch_high_bar) or (close < high_bar and close >= touch_high_bar)) then 1 else 0;
def touchpeakcnt = if touchpeak then touchpeakcnt[1] + 1 else touchpeakcnt[1];

def touchvalley = if low_bar > 1 and ((low > low_bar and low <= touch_low_bar) or (close > low_bar and close <= touch_low_bar)) then 1 else 0;
def touchvalleycnt = if touchvalley then touchvalleycnt[1] + 1 else touchvalleycnt[1];

#
# touches detail
#

def montouchpeakin = if high_bar > 1 and ((high < high_bar and high >= touch_high_bar) or (close < high_bar and close >= touch_high_bar)) and GetDayOfWeek(GetYYYYMMDD()) == 1 then 1 else 0;
def montouchpeakcntin = if montouchpeakin then montouchpeakcntin[1] + 1 else montouchpeakcntin[1];

def montouchvalleyin = if low_bar > 1 and ((low > low_bar and low <= touch_low_bar) or (close > low_bar and close <= touch_low_bar)) and GetDayOfWeek(GetYYYYMMDD()) == 1 then 1 else 0;
def montouchvalleycntin = if montouchvalleyin then montouchvalleycntin[1] + 1 else montouchvalleycntin[1];

def tuetouchpeakin = if high_bar > 1 and ((high < high_bar and high >= touch_high_bar) or (close < high_bar and close >= touch_high_bar)) and GetDayOfWeek(GetYYYYMMDD()) == 2 then 1 else 0;
def tuetouchpeakcntin = if tuetouchpeakin then tuetouchpeakcntin[1] + 1 else tuetouchpeakcntin[1];

def tuetouchvalleyin = if low_bar > 1 and ((low > low_bar and low <= touch_low_bar) or (close > low_bar and close <= touch_low_bar)) and GetDayOfWeek(GetYYYYMMDD()) == 2 then 1 else 0;
def tuetouchvalleycntin = if tuetouchvalleyin then tuetouchvalleycntin[1] + 1 else tuetouchvalleycntin[1];

def wentouchpeakin = if high_bar > 1 and ((high < high_bar and high >= touch_high_bar) or (close < high_bar and close >= touch_high_bar)) and GetDayOfWeek(GetYYYYMMDD()) == 3 then 1 else 0;
def wentouchpeakcntin = if wentouchpeakin then wentouchpeakcntin[1] + 1 else wentouchpeakcntin[1];

def wentouchvalleyin = if low_bar > 1 and ((low > low_bar and low <= touch_low_bar) or (close > low_bar and close <= touch_low_bar)) and GetDayOfWeek(GetYYYYMMDD()) == 3 then 1 else 0;
def wentouchvalleycntin = if wentouchvalleyin then wentouchvalleycntin[1] + 1 else wentouchvalleycntin[1];

def thutouchpeakin = if high_bar > 1 and ((high < high_bar and high >= touch_high_bar) or (close < high_bar and close >= touch_high_bar)) and GetDayOfWeek(GetYYYYMMDD()) == 4 then 1 else 0;
def thutouchpeakcntin = if thutouchpeakin then thutouchpeakcntin[1] + 1 else thutouchpeakcntin[1];

def thutouchvalleyin = if low_bar > 1 and ((low > low_bar and low <= touch_low_bar) or (close > low_bar and close <= touch_low_bar)) and GetDayOfWeek(GetYYYYMMDD()) == 4 then 1 else 0;
def thutouchvalleycntin = if thutouchvalleyin then thutouchvalleycntin[1] + 1 else thutouchvalleycntin[1];

def fritouchpeakin = if high_bar > 1 and ((high < high_bar and high >= touch_high_bar) or (close < high_bar and close >= touch_high_bar)) and GetDayOfWeek(GetYYYYMMDD()) == 5 then 1 else 0;
def fritouchpeakcntin = if fritouchpeakin then fritouchpeakcntin[1] + 1 else fritouchpeakcntin[1];

def fritouchvalleyin = if low_bar > 1 and ((low > low_bar and low <= touch_low_bar) or (close > low_bar and close <= touch_low_bar)) and GetDayOfWeek(GetYYYYMMDD()) == 5 then 1 else 0;
def fritouchvalleycntin = if fritouchvalleyin then fritouchvalleycntin[1] + 1 else fritouchvalleycntin[1];

plot spxhigh = if high_bar < 1 then Double.NaN else high_bar;

spxhigh.SetDefaultColor(Color.GREEN);
spxhigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
spxhigh.SetLineWeight(2);

plot spxlow = if low_bar < 1 then Double.NaN else low_bar;

spxlow.SetDefaultColor(Color.RED);
spxlow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
spxlow.SetLineWeight(2);

plot spxzero = if em_close < 1 then Double.Nan else em_close;

spxzero.setdefaultcolor(color.black);
spxzero.setpaintingstrategy(paintingstrategy.horizontal);
spxzero.setlineweight(2);

#
# Mark peaks & valleys with dots
#

plot peakArrow = if peak and show_high_dots then high else double.nan;

peakArrow.SetStyle(curve.POINTS);
peakArrow.SetLineWeight(3);
peakArrow.AssignValueColor(color.red);

plot valleyArrow = if valley and show_low_dots then low else double.nan;
valleyArrow.setstyle(curve.pointS);
valleyArrow.setlineweight(3);
valleyarrow.assignvalueColor(color.red);

plot touchpeakArrow = if touchpeak and show_touches_high_dots then high else double.nan;

touchpeakArrow.SetStyle(curve.POINTS);
touchpeakArrow.SetLineWeight(3);
touchpeakArrow.AssignValueColor(color.blue);

plot touchvalleyArrow = if touchvalley and show_touches_low_dots then low else double.nan;

touchvalleyArrow.SetStyle(curve.POINTS);
touchvalleyArrow.SetLineWeight(3);
touchvalleyArrow.AssignValueColor(color.blue);

#AddLabel(yes,"Warning-No Holiday Adjustment & Percent Occurance Calc Slightly #Understated (<1%)");
AddLabel(show_em_calc, "Last IV = " + ivGapHi);
AddLabel(show_em_calc, "Last EM = " + expmove);
AddLabel(show_em_calc, "Last High Bar = " + high_bar);
AddLabel(show_em_calc, "Last Low Bar = " + low_bar);
AddLabel(show_em_calc, "EM Skew%/Std Dev Adj(%)/Touches% = " + em_skew_percent + "/" + em_bandwidth + "/" + touches_percent);
AddLabel(show_highlow_detail, "Over EM Cnt/Avg=" + peakcnt + "/" + if peakcnt > 0 then peakamt / peakcnt else 0);
AddLabel(show_highlow_detail, "Over EM % " + if lastbar > 0 then peakcnt / lastbar * 100 else 0);
AddLabel(show_highlow_detail, "Under EM Cnt/Avg=" + valleycnt + "/" + if valleycnt > 0 then valleyamt / valleycnt else 0);
AddLabel(show_highlow_detail, "Under EM % " + if lastbar > 0 then valleycnt / lastbar * 100 else 0);
AddLabel(show_highlow_detail, "Bars=" + lastbar + " Weeks=" + weekcnt);

AddLabel(show_highlow_daily, "Mon Over EM Cnt/Avg=" + monpeakcnt + "/" + if monpeakamt > 0 then monpeakamt/monpeakcnt else 0);
AddLabel(show_highlow_daily, "Mon Under EM Cnt/Avg=" + monvalleycnt + "/" + if monvalleyamt > 0 then monvalleyamt/monvalleycnt else 0);

AddLabel(show_highlow_daily, "Tue Over EM Cnt/Avg=" + tuepeakcnt + "/" + if tuepeakamt > 0 then tuepeakamt/tuepeakcnt else 0);
AddLabel(show_highlow_daily, "Tue Under EM Cnt/Avg=" + tuevalleycnt + "/" + if tuevalleyamt > 0 then tuevalleyamt/tuevalleycnt else 0);

AddLabel(show_highlow_daily, "Wen Over EM Cnt/Avg=" + wenpeakcnt + "/" + if wenpeakamt > 0 then wenpeakamt/wenpeakcnt else 0);
AddLabel(show_highlow_daily, "Wen Under EM Cnt/Avg=" + wenvalleycnt + "/" + if wenvalleyamt > 0 then wenvalleyamt/wenvalleycnt else 0);

AddLabel(show_highlow_daily, "Thu Over EM Cnt/Avg=" + thupeakcnt + "/" + if thupeakamt > 0 then thupeakamt/thupeakcnt else 0);
AddLabel(show_highlow_daily, "Thu Under EM Cnt/Avg=" + thuvalleycnt + "/" + if thuvalleyamt > 0 then thuvalleyamt/thuvalleycnt else 0);

AddLabel(show_highlow_daily, "Fri Over EM Cnt/Avg=" + fripeakcnt + "/" + if fripeakamt > 0 then fripeakamt/fripeakcnt else 0);
AddLabel(show_highlow_daily, "Fri Under EM Cnt/Avg=" + frivalleycnt + "/" + if frivalleyamt > 0 then frivalleyamt/frivalleycnt else 0);

AddLabel(show_highlow_daily_inside, "Mon Within EM High Cnt/Avg=" + monpeakcntin + "/" + if monpeakamtin > 0 then monpeakamtin/monpeakcntin else 0);
AddLabel(show_highlow_daily_inside, "Mon Within EM Low Cnt/Avg=" + monvalleycntin + "/" + if monvalleyamtin > 0 then monvalleyamtin/monvalleycntin else 0);

AddLabel(show_highlow_daily_inside, "Tue Within EM High Cnt/Avg=" + tuepeakcntin + "/" + if tuepeakamtin > 0 then tuepeakamtin/tuepeakcntin else 0);
AddLabel(show_highlow_daily_inside, "Tue Within EM Low Cnt/Avg=" + tuevalleycntin + "/" + if tuevalleyamtin > 0 then tuevalleyamtin/tuevalleycntin else 0);

AddLabel(show_highlow_daily_inside, "Wen Within EM High Cnt/Avg=" + wenpeakcntin + "/" + if wenpeakamtin > 0 then wenpeakamtin/wenpeakcntin else 0);
AddLabel(show_highlow_daily_inside, "Wen Within EM Low Cnt/Avg=" + wenvalleycntin + "/" + if wenvalleyamtin > 0 then wenvalleyamtin/wenvalleycntin else 0);

AddLabel(show_highlow_daily_inside, "Thu Within EM High Cnt/Avg=" + thupeakcntin + "/" + if thupeakamtin > 0 then thupeakamtin/thupeakcntin else 0);
AddLabel(show_highlow_daily_inside, "Thu Within EM Low Cnt/Avg=" + thuvalleycntin + "/" + if thuvalleyamtin > 0 then thuvalleyamtin/thuvalleycntin else 0);

AddLabel(show_highlow_daily_inside, "Fri Within EM High Cnt/Avg=" + fripeakcntin + "/" + if fripeakamtin > 0 then fripeakamtin/fripeakcntin else 0);
AddLabel(show_highlow_daily_inside, "Fri Within EM Low Cnt/Avg=" + frivalleycntin + "/" + if frivalleyamtin > 0 then frivalleyamtin/frivalleycntin else 0);

AddLabel(show_touches_daily, "Mon Touches EM High/Low/Tot Cnt=" + montouchpeakcntin + "/" + montouchvalleycntin + "/" + (montouchpeakcntin+montouchvalleycntin));
AddLabel(show_touches_daily, "Tue Touches EM High/Low/Tot Cnt=" + tuetouchpeakcntin + "/" + tuetouchvalleycntin + "/" + (tuetouchpeakcntin+tuetouchvalleycntin));
AddLabel(show_touches_daily, "Wen Touches EM High/Low/Tot Cnt=" + wentouchpeakcntin + "/" + wentouchvalleycntin + "/" + (wentouchpeakcntin+wentouchvalleycntin));
AddLabel(show_touches_daily, "Thu Touches EM High/Low/Tot Cnt=" + thutouchpeakcntin + "/" + thutouchvalleycntin + "/" + (thutouchpeakcntin+thutouchvalleycntin));
AddLabel(show_touches_daily, "Fri Touches EM High/Low/Tot Cnt=" + fritouchpeakcntin + "/" + fritouchvalleycntin + "/" + (fritouchpeakcntin+fritouchvalleycntin));
AddLabel(show_touches_daily, "Total Touches EM High/Low/Tot Cnt=" + touchpeakcnt + "/" + touchvalleycnt + "/" + (touchpeakcnt+touchvalleycnt));

#
# diagnostic bubbles
#

AddChartBubble(peak and show_high_bubble, high + 1, "Peak Cnt=" + peakcnt + " Over Amt=" + (close - high_bar) + " Cum Over Amt=" + peakamt + " Highbar=" + high_bar, Color.WHITE);

AddChartBubble(valley and show_low_bubble, low - 1, "Valley Cnt=" + valleycnt + " Under Amt=" + (low_bar - close) + " Cum Under Amt=" + valleyamt + " Valleybar=" + low_bar, Color.WHITE);

#
# check em calc's
#

#AddChartBubble(yes, high + 1, "bar " + BarNumber() + "D=" + getdayofweek(getyyyymmdd()) + "Hbar " + high_bar + "iv " + imp_volatility() + " close " + close + " em " + expmove + " Lbar " + low_bar + " EMClose " + em_close, Color.WHITE);

#
# daily bar diagnostic section
#

#peak

#AddChartBubble(fripeak, high + 1, "Fri Over Count=" + fripeakcnt + "Fri Over Amt=" + (close - high_bar) + "Cum Fri Over Amt=" + fripeakamt + " Highbar=" + high_bar, color.white);
#AddChartBubble(thupeak, high + 1, "Thu Over Count=" + thupeakcnt + "Thu Over Amt=" + (close - high_bar) + "Cum Thu Over Amt=" + thupeakamt + " Highbar=" + high_bar, color.white);
#AddChartBubble(wenpeak, high + 1, "Wen Over Count=" + wenpeakcnt + "Wen Over Amt=" + (close - high_bar) + "Cum Wen Over Amt=" + wenpeakamt + " Highbar=" + high_bar, color.white);
#AddChartBubble(tuepeak, high + 1, "Tue Over Count=" + tuepeakcnt + "Tue Over Amt=" + (close - high_bar) + "Cum Tue Over Amt=" + tuepeakamt + " Highbar=" + high_bar, color.white);
#AddChartBubble(monpeak, high + 1, "Mon Over Count=" + monpeakcnt + "Mon Over Amt=" + (close - high_bar) + "Cum Mon Over Amt=" + monpeakamt + " Highbar=" + high_bar, color.white);

# valley

#AddChartBubble(monvalley, high + 1, "Mon Under Count=" + monvalleycnt + "Mon Under Amt=" + (low_bar - close) + "Cum Mon Under Amt=" + monvalleyamt + " Lowbar=" + low_bar, color.white);
#AddChartBubble(tuevalley, high + 1, "Tue Under Count=" + tuevalleycnt + "Tue Under Amt=" + (low_bar - close) + "Cum Tue Under Amt=" + tuevalleyamt + " Lowbar=" + low_bar, color.white);

#AddChartBubble(wenvalley, high + 1, "Wen Under Count=" + wenvalleycnt + "Wen Under Amt=" + (low_bar - close) + "Cum Wen Under Amt=" + wenvalleyamt + " Lowbar=" + low_bar, color.white);
#AddChartBubble(thuvalley, high + 1, "Thu Under Count=" + thuvalleycnt + "Thu Under Amt=" + (low_bar - close) + "Cum Thu Under Amt=" + thuvalleyamt + " Lowbar=" + low_bar, color.white);
#AddChartBubble(frivalley, high + 1, "Fri Under Count=" + frivalleycnt + "Fri Under Amt=" + (low_bar - close) + "Cum Fri Under Amt=" + frivalleyamt + " Lowbar=" + low_bar, color.white);

# touches

#AddChartBubble(touchpeak, high + 1, "Close=" +close + " High=" + high + " High_bar=" + high_bar + " Touches%=" + touches_percent + " EM=" + expmove + "EMclose=" + em_close +" High_Touch_Bar=" + touch_high_bar, Color.WHITE);

#AddChartBubble(touchvalley, low - 1, "Close=" + close + " Low=" + low + " Low_bar=" + low_bar + " Touches%=" + touches_percent + " EM=" + expmove + " Emclose=" + em_close+" Low_Touch_Bar=" + touch_low_bar, Color.WHITE);
 
EvanBStock: For anyone familiar with mobius Expected move. Here is a watchlist column for it with Labels saying whether it is above or below (or reversing back into EM) This only uses t the weekly expected from from the previous weeks close. http://tos.mx/rlKbIh

Code:
# Mobius_
# Implied Move For Various Times based on the Series IV
# Mobius
# V01.03.2017

input show_label = yes;
input nDays = 4; #hint nDays: Days left in series.
input Series_IV = 1; #hint Series_IV: Series 1 is closest expirery.
input defClose = {default "Friday"};
input ShowLabels = yes;
input show252day = no;
input show365day = no;
input show1day = yes;
input Label_Color_Choice = {default "pink", "cyan", "orange", "gray", "yellow", "red", "green", "dark_gray", "light_yellow", "white"};

def CurrentDOW = GetDayOfWeek(GetYYYYMMDD());
def cbar = if CurrentDOW == 5
           then BarNumber()
           else cbar[1];
def c = if BarNumber() == cbar
        then close(period = AggregationPeriod.DAY)
        else c[1];
def t;
switch (defClose) {

case Friday:
    t = if BarNumber() == cbar
        then close(period = AggregationPeriod.DAY)
        else c[1];
}
def IV = if IsNaN(imp_volatility(period = AggregationPeriod.DAY))
         then IV[1]
         else imp_volatility(period = AggregationPeriod.DAY);
def seriesIV = SeriesVolatility(series = Series_IV);
def ImpMove = (((t * seriesIV * Sqrt(nDays)) / Sqrt(365)) / TickSize()) * TickSize();
def ImpMove252 = (((t * seriesIV * Sqrt(nDays)) / Sqrt(252)) / TickSize()) * TickSize();
def ImpMove365 = (((t * seriesIV * Sqrt(nDays)) / Sqrt(365)) / TickSize()) * TickSize();
def ImpMove1 = Round(((t * seriesIV * Sqrt(1)) / Sqrt(365)) / TickSize(), 0) * TickSize();
def LastBar= if !IsNaN(close) and IsNaN(close[-1])
             then barnumber()
             else Double.NaN;
def upline = if !IsNaN(close) and IsNaN(close[-1])
             then t + ImpMove
             else if IsNaN(close)
                  then upline[1]
                  else Double.NaN;
def upper = if BarNumber() >= HighestAll(lastBar) and
                 BarNumber() <= HighestAll(lastBar) + nDays
              then upline
              else Double.NaN;
  

def lowline = if !IsNaN(close) and IsNaN(close[-1])
              then t - ImpMove
              else if IsNaN(close)
                   then lowline[1]
                   else Double.NaN;
def lower = if BarNumber() >= HighestAll(lastBar) and
                 BarNumber() <= HighestAll(lastBar) + nDays
              then lowline
              else Double.NaN;
 

def emu = close > upper;
def emub = high > upper and close < upper;
def emd = close < lower;
def emdb = low < lower and close > lower;
plot scan = emu or emub or emd or emdb;

# End Code Implied Moves From Series IV

AssignBackgroundColor(
if scan and
emu then Color.lime else
if emd then color.light_red else
if emdb then color.dark_red else
if emub then color.dark_green else color.black);

 addlabel(yes,

if emu then "Abv" else
if emd then "Blw" else
if emub then "RDn" else
if emdb then "RUp" else "In");
 
@maddy sorry I missed this. It tells me how much the options market expects a stock to move. Per the math they are supposed to be corect 68% of the time at 1 standard deviation. @BenTen or someone else that day trades would have to help further.
 
This is pretty genius

Code:
# Archive Name: Historical Vs. Series IV_Mobius
# Archive Section: Volatility   
# Suggested Tos Name: Historical_vs_SeriesIV_Mobius
# Archive Date: 5.05.2018
# Archive Notes:

# Historical Vs. Series IV
# Mobius
# Chat Room Request 05.01.2018

#14:21 Mobius: On the above study - Make sure the series is set to cover the options period   On equities that #have weekly options if your looking for the monthly you'd want to set it to 2.  Some now have more than #even weekly so be aware that you may be comparing apples to watermelons

declare lower;

input length = 20;
input basis = {default Annual, Monthly, Weekly, Daily};
input Series_IV = 1;
def ap = GetAggregationPeriod();

Assert(ap >= AggregationPeriod.MIN, "Study can only be calculated for time-aggregated charts: " + ap);

def barsPerDay = (RegularTradingEnd(GetYYYYMMDD()) - RegularTradingStart(GetYYYYMMDD())) / ap;
def barsPerYear =
if ap > AggregationPeriod.WEEK then 12
else if ap == AggregationPeriod.WEEK then 52
else if ap >= AggregationPeriod.DAY then 252 * AggregationPeriod.DAY / ap
else 252 * barsPerDay;

def basisCoeff;
switch (basis) {
case Annual:
basisCoeff = 1;
case Monthly:
basisCoeff = 12;
case Weekly:
basisCoeff = 52;
case Daily:
basisCoeff = 252;
}

def clLog = Log(close / close[1]);
plot HV = StDev(clLog, length) * Sqrt(barsPerYear / basisCoeff * length / (length - 1));
HV.SetDefaultColor(GetColor(0));
def IV = if isNaN(SeriesVolatility(series = Series_IV))
then IV[1]
else SeriesVolatility(series = Series_IV);
plot S_IV = IV;
AddLabel(1, "Historical IV = " + HV, hv.TakeValueColor());
AddLabel(1, "Series IV = " + IV, S_IV.TakeValueColor());

# End of Code  #  added by JQ for Archive
 
I am looking to build a scanner that populates which stocks are trading below or above their weekly expected moves. I have a study that plots this for me however when I try to make a custom scanner with that study I get the error message that it is too complex.
did you fix the error?
 
Last edited by a moderator:
Solved the problem! Saved the updated code seen above as a study, then created a custom scanner study. Make sure to set the aggregate period to day.
 
I'm also trying to figure out how to show the expected moves on intraday chart using the daily aggregation. IF you find out how to accomplish this, PLEASE let me know! I'm trying to figure out on my own and have not been successful as of yet. Thanks!
i use this by Mobius. not sure if it's what ur looking for. It shows expected moves on intraday. it also allows u to change the daily EM to weekly


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
 
i use this by Mobius. not sure if it's what ur looking for. It shows expected moves on intraday. it also allows u to change the daily EM to weekly


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
I saw that. How do you change it to weekly data?
 
@markos I would love to understand the inputs and outputs more. Would you mind writing a quick summary guide for a noob? Thanks.
The best way to learn to read charts and indicators is to apply them. Recommend you put it on your chart. Nothing beats personal experience ;) The only way you will know what the plots are doing, is to observe them on your charts and how they inter-relate with your other indicators.

Most indicators need tweaking depending on the timeframe, the market, the ticker.

No one can possibly know what tweaks will work best for you. It is up to you to play with the settings and see how the indicator lines up w/ your strategy and with your other indicators.

To determine if this indicator brings value, analyze it over different timeframes, across history and with multiple instruments.
 
Last edited:
The best way to learn to read charts and indicators is to apply them. Recommend you put it on your chart. Nothing beats personal experience ;) The only way you will know what works best for you is to play with the settings and see how the indicator line up w/ your strategy and with your other indicators. To determine if this indicator brings value, analyze it over different timeframes, across history and with multiple instruments.
Yup yup yup. Another thing was I was super weak on options a few weeks ago. After grinding a few weeks this indicator totally makes sense now. Sorry for being impatient and wanting spoons :)
 
I am looking to build a scanner that populates which stocks are trading below or above their weekly expected moves. I have a study that plots this for me however when I try to make a custom scanner with that study I get the error message that it is too complex.

The script is the 2nd one found here:
https://usethinkscript.com/threads/...ekly-options-for-thinkorswim.1449/#post-15354

how do you use this for trading? go long at lower level and short at upper? Or trade towards the levels?
 
Last edited by a moderator:

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
494 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