Expected Move, Probability Cone For ThinkOrSwim

halcyonguy

Moderator - Expert
VIP
Lifetime
Expected moved, probability cone

enter a date and it draws a parabola and calculates an expected move, using this equation.
expected move = price * iv * ( sqrt( days to expire / 365))
http://www.nishatrades.com/blog/mat...ected-move-using-a-probability-analysis-chart


if the chart time is more than day, the date has to be,
..if week , then a monday
..if month, then the 1st trading day of the month

Ruby:
# expected_move_cone_01

# expected move parabola
# cone starts on last bar
# halcyonguy
# 22-04-09

# http://www.nishatrades.com/blog/mathematically-calculating-expected-move-using-a-probability-analysis-chart
# nisha trades , described std dev
# expected move = price * iv * ( sqrt( days to expire / 365))
#----------------------------------
def price = close;
def iv2 = imp_volatility();
def iv = round(iv2,2);

def na = double.nan;
def bn = barnumber();
def lastbn = HighestAll(If(IsNaN(price), 0, bn));
def endbn = highestall(bn);
def lastbar = if lastbn == bn then 1 else 0;
# def lastbar = !isnan(close[0]) and isnan(close[-1]);

# expansion area, bars after last bar to right edge of chart
def expan_bars = (endbn - lastbn );
def expan_area = if (bn >= lastbn and bn <= endbn) then 1 else 0;

def lastcls = if bn < lastbn then na else if bn == lastbn then price else lastcls[1];
def lastiv = if bn < lastbn then na else if bn == lastbn then iv else lastiv[1];

def newday = if getday() != getday()[1] then 1 else 0;

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

def chartagg = GetAggregationPeriod();
def chartmin = (chartagg / 1000) / 60;
def daybarqty = roundup(390 / chartmin, 0);
def daysperbar = 1/daybarqty;

# for EM formula, need a qty of days that starts at 0 and counts up to the qty of days to target date
def cone_days_cnt_up = if bn == 1 then na else if lastbar then 0 else cone_days_cnt_up[1] + daysperbar;

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

# date of a trading day
input target_date_yyyymmdd = 20220520;
def dat = target_date_yyyymmdd;
def is_target_date = if (GetYYYYMMDD() == dat and newday) then 1 else 0;

# mobius
def data = dat;
def year = Round(data/10000, 0);
def month = Round((data % 10000) / 100, 0);
def day = (data % 100);

#  this fixes the  CountTradingDays() error , when it was in a normal if-then
def dayz5;
if GetYYYYMMDD() > dat then {
 dayz5 = 0;
} else if lastbn == bn then {
 dayz5 = CountTradingDays(GetYYYYMMDD(), dat );
}  else {
 dayz5 = dayz5[1];
}

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

input vertical_line_target_date = yes;
addverticalline(vertical_line_target_date and is_target_date, "  " + (month + " / " + day), color.yellow);

input em_factor = 1.0;
def em = round(em_factor * lastcls * lastiv * ( sqrt(cone_days_cnt_up/365)), 2);
def em_per = round((em/lastcls)*100, 1);

# get EM value on lastbar, so it will be displayed in a label
def em2b = if bn == 1 then 0 else if is_target_date then em else em2b[1];
def em2 = if isNaN(close[-1000])  then em2b[-1000]   else Double.NaN;

# top half parabola
plot ztop = if expan_area then (lastcls + em) else na;
ztop.setdefaultcolor(color.yellow);

# bottom half parabola
plot zbot = if expan_area then (lastcls - em) else na;
zbot.setdefaultcolor(color.yellow);

input cone_horz_line = yes;
plot z2 = if (cone_horz_line and expan_area) then lastcls else na;
z2.setdefaultcolor(color.gray);

# -------------------------------------
# target date price bubbles
input show_price_bubbles = yes;
def vert = 0.99;
addchartbubble(show_price_bubbles and is_target_date, ztop, ztop , color.yellow, yes);
addchartbubble(show_price_bubbles and is_target_date, lastcls * vert, "$" + em + "\n" + em_per + "%" , color.yellow, yes);
addchartbubble(show_price_bubbles and is_target_date, zbot, zbot, color.yellow, no);

input show_date_bubble = yes;
addchartbubble(show_date_bubble and is_target_date, ztop*0.99, (month + "/" + day) , color.yellow, no);

# ===========================================
# labels
addlabel(1, "IV  " + iv, color.orange);

input iv_label = yes;
AddLabel(iv_label, " " , Color.black);

input chart_stats_labels = no;
AddLabel(chart_stats_labels, "chartmin " + chartmin, Color.MAGENTA);
AddLabel(chart_stats_labels, "bars per day " + daybarqty, Color.MAGENTA);

input show_labels = yes;
addLabel(show_labels, "target date: " + month + "/" + day + "/" + AsPrice(year), color.yellow);
addlabel(show_labels, "trading days to target date  " + dayz5, color.yellow);

addlabel(show_labels, "EM  " + "$" + em2 , color.orange);
#


WMT 30min 90day 400 expan bars
XneDDKo.jpg

hal_cone
 

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

Weekly IV Implied Move Probability Cone
Ruby:
# IV Implied Move Probability Cone
# Mobius
# V01.03.2021
####################################################
# mods by zoyd V04.09.2022
# Added weekly implied move
# Added realized volatility traces
# Added option for 0DTE (was SPY only)
# if series IV not available use Black-Scholes
# Recommended aggregation is 5 min and 12 RV samples
####################################################
# Credit for code snippet/weekly Implied move
# TheoTrade_Weely_Expected_Move
# Copyright TheoTrade LLC
# V08.11.2017
####################################################
input ShowBubbles = no;
input meanType = {default Daily, OpenRange};
input DTE0 = no;
input RealEq = {default RogersSatchell, YangZhang, Simple};
input RVlength = 12;
def c = close;
def x = BarNumber();
def nan = Double.NaN;
def active = SecondsFromTime(0930) >= 0 and
             SecondsTillTime(1000) <= 0;
def DOW = GetDayOfWeek(GetYYYYMMDD());

#get close from prev Friday
def Monday = DOW == 1;
def Friday = DOW == 5;
def FridayC = if Friday then close(period = AggregationPeriod.DAY) else FridayC[1];
def lastFridayC = if Monday then FridayC else lastFridayC[1];

def ORH = if active
          then high(period = AggregationPeriod.THIRTY_MIN)
          else ORH[1];
def ORL = if active
          then low(period = AggregationPeriod.THIRTY_MIN)
          else ORL[1];

def t = if SecondsFromTime(0930) > 0
        then SecondsTillTime(1600) / 23400
        else 1;
def DTE;

def IV = if !IsNaN(SeriesVolatility(series = 1))
         then SeriesVolatility(series = 1)
         else if IsNaN(SeriesVolatility(series = 1)) and
                 !IsNaN(SeriesVolatility(series = 2))
         then SeriesVolatility(series = 2)
         else if IsNaN(SeriesVolatility(series = 1)) and
                 IsNaN(SeriesVolatility(series = 2)) and
                !IsNaN(SeriesVolatility(series = 3))
         then SeriesVolatility(series = 3)
         else if !isnan(imp_volatility()) then imp_volatility() else IV[1];

if DOW == 1
{
    DTE = if DTE0 then t else 5 - DOW;
}
else if DOW == 2
{
    DTE = if DTE0 then 1 + t else 5 - DOW;
}
else if DOW == 3
{
    DTE = if DTE0 then t else 5 - DOW;
}
else if DOW == 4
{
    DTE = if DTE0 then 1 + t else 5 - DOW;
}
else if DOW == 5
{
    DTE = t;
}
else
{
    DTE = DTE[1];
}

def RTH = GetTime() >= RegularTradingStart(GetYYYYMMDD()) and
          GetTime() <= RegularTradingEnd(GetYYYYMMDD());
def x1 = if RTH and !RTH[1]
        then x
        else x1[1];

#borrowed from theo-daily weekly EM
#comment about bandwidth:
# " 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."
input em_skew_percent = 85;
input em_bandwidth = 100;

def ImpMove = if DTE > 0
              then (c * IV * Sqrt(DTE) / Sqrt(365)) * em_skew_percent / 100
              else (c * IV * 1 / Sqrt(365)) * em_skew_percent / 100 * em_bandwidth / 100;

def ImpMoveW = if Monday
              then imp_volatility(period = AggregationPeriod.DAY) * lastFridayC * Sqrt(6) / Sqrt(365) * em_skew_percent / 100 * em_bandwidth / 100
              else ImpMoveW[1];

def factor = AggregationPeriod.DAY/(GetAggregationPeriod()*RVlength);
def RVMove;
switch (RealEq) {
    case RogersSatchell:
        RVMove = expaverage(Sqrt(Sum(Log(high / close) * Log(high / open) + Log(low / close) * Log(low / open), RVlength)) * c * sqrt(factor),RVlength);
    case YangZhang:
        RVMove = expaverage(Sqrt(Sum(Sqr(Log(open / close[1])), RVlength) + Sum(1 / 2 *     Sqr(Log(high / low )), RVlength) -
Sum( (2 * Log(2) - 1) * Sqr(Log(close / open)), RVlength) ) * c * sqrt(factor),RVlength);
    case Simple:
        RVMove = expaverage(Sqrt(Sum(Sqr(Log(c / c[1])),RVLength)) * c * sqrt(factor), RVLength);
}
def RV_Y =  RVMove * Sqrt(365) / c ;
def meanW = if Monday then lastFridayC else if meanW[1] then meanW[1] else c;

plot mean;
switch (meanType)
    {
case Daily:
    mean = (Max(high(period = "DAY"), close(period = "DAY")[1]) +
                 Min(low(period = "DAY"), close(period = "DAY")[1])) / 2;
case OpenRange:
    mean = (ORH + ORL) / 2;
}
mean.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
mean.SetLineWeight(2);
mean.SetDefaultColor(Color.DARK_GRAY);

plot Upper = if RTH and x >= HighestAll(x1)
             then mean + Round(ImpMove / TickSize(), 0) * TickSize()
             else Double.NaN;
plot UpperW = if RTH and x >= HighestAll(x1)
             then meanW + Round(ImpMoveW / TickSize(), 0) * TickSize()
             else Double.NaN;
plot UpperRV = if RTH and x >= HighestAll(x1)
             then mean + Round(RVMove / TickSize(), 0) * TickSize()
             else Double.NaN;
Upper.SetPaintingStrategy(PaintingStrategy.LINE);
Upper.SetDefaultColor(Color.GRAY);
Upper.HideTitle();
UpperW.SetPaintingStrategy(PaintingStrategy.LINE);
UpperW.SetDefaultColor(Color.LIGHT_GRAY);
UpperW.HideTitle();
UpperRV.SetPaintingStrategy(PaintingStrategy.LINE);
UpperRV.SetDefaultColor(Color.LIGHT_ORANGE);
UpperRV.HideTitle();
AddChartBubble(ShowBubbles and x == HighestAll(x), Upper, "ImpMove", Upper.TakeValueColor());
AddChartBubble(ShowBubbles and x == HighestAll(x), UpperW, "IMWeekly", UpperW.TakeValueColor());
AddChartBubble(ShowBubbles and x == HighestAll(x), UpperRV, "RVMove", UpperRV.TakeValueColor());

plot MeanHigh = if RTH and x >= HighestAll(x1)
                then mean + Round((ImpMove * .682) / TickSize(), 0) * TickSize()
                else Double.NaN;
MeanHigh.SetPaintingStrategy(PaintingStrategy.LINE);
MeanHigh.SetDefaultColor(Color.DARK_GRAY);
MeanHigh.HideTitle();
MeanHigh.SetLineWeight(3);
AddChartBubble(ShowBubbles and x == HighestAll(x), MeanHigh, "ProbMove", MeanHigh.TakeValueColor());
AddCloud(Upper, MeanHigh, CreateColor(212, 175, 55), CreateColor(212, 175, 55));
plot Lower = if RTH and x >= HighestAll(x1)
             then mean - Round(ImpMove / TickSize(), 0) * TickSize()
             else Double.NaN;
plot LowerRV = if RTH and x >= HighestAll(x1)
             then mean - Round(RVMove / TickSize(), 0) * TickSize()
             else Double.NaN;
plot LowerW = if RTH and x >= HighestAll(x1)
             then meanW - Round(ImpMoveW / TickSize(), 0) * TickSize()
             else Double.NaN;
Lower.SetPaintingStrategy(PaintingStrategy.LINE);
Lower.SetDefaultColor(Color.GRAY);
Lower.HideTitle();
AddChartBubble(ShowBubbles and x == HighestAll(x), Lower, "ImpMove", Lower.TakeValueColor(), no);
LowerRV.SetPaintingStrategy(PaintingStrategy.LINE);
LowerRV.SetDefaultColor(Color.LIGHT_ORANGE);
LowerRV.HideTitle();
AddChartBubble(ShowBubbles and x == HighestAll(x), LowerRV, "RVMove", LowerRV.TakeValueColor(), no);
LowerW.SetPaintingStrategy(PaintingStrategy.LINE);
LowerW.SetDefaultColor(Color.LIGHT_GRAY);
LowerW.HideTitle();
AddChartBubble(ShowBubbles and x == HighestAll(x), LowerW, "IMWeekly", LowerW.TakeValueColor(), no);

plot MeanLow = if RTH and x >= HighestAll(x1)
               then mean - Round((ImpMove * .682) / TickSize(), 0) * TickSize()
               else Double.NaN;
MeanLow.SetPaintingStrategy(PaintingStrategy.LINE);
MeanLow.SetDefaultColor(Color.DARK_GRAY);
MeanLow.HideTitle();
MeanLow.SetLineWeight(3);
AddChartBubble(ShowBubbles and x == HighestAll(x), MeanLow, "ProbMove", MeanLow.TakeValueColor(), no);
AddCloud(Lower, MeanLow, CreateColor(212, 175, 55), CreateColor(212, 175, 55));

AddLabel(1, "IV = " + AsPercent(IV) +
          "  Todays IM = " + AsDollars(ImpMove) +
          "  PM = " + AsDollars(Round((ImpMove * .682) / TickSize(), 0) * TickSize()) +
          "  RV = " + AsPercent(RV_Y) +
          "  Daily RV = " + AsDollars(Round((RVMove) / TickSize(), 0) * TickSize()) +
          "  IMWeekly = " + AsDollars(Round((ImpMoveW) / TickSize(), 0) * TickSize()) + "        "  ,
         Color.LIGHT_GRAY);
# End Code IV Cone
 
Last edited:
Expected moved, probability cone

enter a date and it draws a parabola and calculates an expected move, using this equation.
expected move = price * iv * ( sqrt( days to expire / 365))
http://www.nishatrades.com/blog/mat...ected-move-using-a-probability-analysis-chart


if the chart time is more than day, the date has to be,
..if week , then a monday
..if month, then the 1st trading day of the month

Ruby:
# expected_move_cone_01

# expected move parabola
# cone starts on last bar
# halcyonguy
# 22-04-09

# http://www.nishatrades.com/blog/mathematically-calculating-expected-move-using-a-probability-analysis-chart
# nisha trades , described std dev
# expected move = price * iv * ( sqrt( days to expire / 365))
#----------------------------------
def price = close;
def iv2 = imp_volatility();
def iv = round(iv2,2);

def na = double.nan;
def bn = barnumber();
def lastbn = HighestAll(If(IsNaN(price), 0, bn));
def endbn = highestall(bn);
def lastbar = if lastbn == bn then 1 else 0;
# def lastbar = !isnan(close[0]) and isnan(close[-1]);

# expansion area, bars after last bar to right edge of chart
def expan_bars = (endbn - lastbn );
def expan_area = if (bn >= lastbn and bn <= endbn) then 1 else 0;

def lastcls = if bn < lastbn then na else if bn == lastbn then price else lastcls[1];
def lastiv = if bn < lastbn then na else if bn == lastbn then iv else lastiv[1];

def newday = if getday() != getday()[1] then 1 else 0;

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

def chartagg = GetAggregationPeriod();
def chartmin = (chartagg / 1000) / 60;
def daybarqty = roundup(390 / chartmin, 0);
def daysperbar = 1/daybarqty;

# for EM formula, need a qty of days that starts at 0 and counts up to the qty of days to target date
def cone_days_cnt_up = if bn == 1 then na else if lastbar then 0 else cone_days_cnt_up[1] + daysperbar;

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

# date of a trading day
input target_date_yyyymmdd = 20220520;
def dat = target_date_yyyymmdd;
def is_target_date = if (GetYYYYMMDD() == dat and newday) then 1 else 0;

# mobius
def data = dat;
def year = Round(data/10000, 0);
def month = Round((data % 10000) / 100, 0);
def day = (data % 100);

#  this fixes the  CountTradingDays() error , when it was in a normal if-then
def dayz5;
if GetYYYYMMDD() > dat then {
 dayz5 = 0;
} else if lastbn == bn then {
 dayz5 = CountTradingDays(GetYYYYMMDD(), dat );
}  else {
 dayz5 = dayz5[1];
}

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

input vertical_line_target_date = yes;
addverticalline(vertical_line_target_date and is_target_date, "  " + (month + " / " + day), color.yellow);

input em_factor = 1.0;
def em = round(em_factor * lastcls * lastiv * ( sqrt(cone_days_cnt_up/365)), 2);
def em_per = round((em/lastcls)*100, 1);

# get EM value on lastbar, so it will be displayed in a label
def em2b = if bn == 1 then 0 else if is_target_date then em else em2b[1];
def em2 = if isNaN(close[-1000])  then em2b[-1000]   else Double.NaN;

# top half parabola
plot ztop = if expan_area then (lastcls + em) else na;
ztop.setdefaultcolor(color.yellow);

# bottom half parabola
plot zbot = if expan_area then (lastcls - em) else na;
zbot.setdefaultcolor(color.yellow);

input cone_horz_line = yes;
plot z2 = if (cone_horz_line and expan_area) then lastcls else na;
z2.setdefaultcolor(color.gray);

# -------------------------------------
# target date price bubbles
input show_price_bubbles = yes;
def vert = 0.99;
addchartbubble(show_price_bubbles and is_target_date, ztop, ztop , color.yellow, yes);
addchartbubble(show_price_bubbles and is_target_date, lastcls * vert, "$" + em + "\n" + em_per + "%" , color.yellow, yes);
addchartbubble(show_price_bubbles and is_target_date, zbot, zbot, color.yellow, no);

input show_date_bubble = yes;
addchartbubble(show_date_bubble and is_target_date, ztop*0.99, (month + "/" + day) , color.yellow, no);

# ===========================================
# labels
addlabel(1, "IV  " + iv, color.orange);

input iv_label = yes;
AddLabel(iv_label, " " , Color.black);

input chart_stats_labels = no;
AddLabel(chart_stats_labels, "chartmin " + chartmin, Color.MAGENTA);
AddLabel(chart_stats_labels, "bars per day " + daybarqty, Color.MAGENTA);

input show_labels = yes;
addLabel(show_labels, "target date: " + month + "/" + day + "/" + AsPrice(year), color.yellow);
addlabel(show_labels, "trading days to target date  " + dayz5, color.yellow);

addlabel(show_labels, "EM  " + "$" + em2 , color.orange);
#


WMT 30min 90day 400 expan bars
XneDDKo.jpg

hal_cone
Is it possible to make this probability cone offset? In other words, can we chart what the probability cone would have looked like a certain number of days ago? This would allow for a contrast between the current probability cone and what the cone would have looked like say a week ago, or a month ago, etc.
 
Is it possible to make this probability cone offset? In other words, can we chart what the probability cone would have looked like a certain number of days ago? This would allow for a contrast between the current probability cone and what the cone would have looked like say a week ago, or a month ago, etc.

cone, ver2
can choose the start of cone, a start date or lastbar
can choose a target date


Ruby:
# expected_move_cone_02_date

# expected move parabola , ver2
# cone starts on last bar or a date
# halcyonguy
# 22-05-19

# http://www.nishatrades.com/blog/mathematically-calculating-expected-move-using-a-probability-analysis-chart
# nisha trades , described std dev
# expected move = price * iv * ( sqrt( days to expire / 365))
#----------------------------------
def price = close;
def iv2 = imp_volatility();
def iv = round(iv2,2);

def na = double.nan;
def bn = barnumber();
def lastbn = HighestAll(If(IsNaN(price), 0, bn));
def endbn = highestall(bn);
def lastbar = if lastbn == bn then 1 else 0;
# def lastbar = !isnan(close[0]) and isnan(close[-1]);

# expansion area, bars after last bar to right edge of chart
def expan_bars = (endbn - lastbn );
def expan_area = if (bn >= lastbn and bn <= endbn) then 1 else 0;

def lastcls = if bn < lastbn then na else if bn == lastbn then price else lastcls[1];
# replace lastiv with siv
#def lastiv = if bn < lastbn then na else if bn == lastbn then iv else lastiv[1];
def newday = if getday() != getday()[1] then 1 else 0;

#--------------------------------------------
def chartagg = GetAggregationPeriod();
def chartmin = (chartagg / 1000) / 60;
def daybarqty = roundup(390 / chartmin, 0);
def daysperbar = 1/daybarqty;

# --------------------------------------------
input start_bar = { default last_bar, date };

# pick a start date
# cone starts on first bar of a day
#input start_date_yyyymmdd = 20220504;
input start_date_yyyymmdd = 20211123;
def sdat = start_date_yyyymmdd;
def is_start_date = if (GetYYYYMMDD() == sdat and newday) then 1 else 0;

def start_date_price = if is_start_date then close else start_date_price[1];

def syear = Round(sdat/10000, 0);
def smonth = Round((sdat % 10000) / 100, 0);
def sday = (sdat % 100);

# --------------------------
def big = 99999;

# cone start bar, price
def sbar;
def sprice;
def sbn;
switch(start_bar) {
case last_bar:
 sbar = lastbar;
 sprice = lastcls;
 sbn = if bn == 1 then big else if lastbar then bn else sbn[1];
case date:
 sbar = is_start_date;
 sprice = start_date_price;
 sbn = if bn == 1 then big else if is_start_date then bn else sbn[1];
}

def siv = if bn == 1 then na else if bn == sbn then iv else siv[1];

# --------------------------------------------
# date of a trading day
input target_date_yyyymmdd = 20220622;
def tdat = target_date_yyyymmdd;
def is_target_date = if (GetYYYYMMDD() == tdat and newday) then 1 else 0;

# mobius
def tyear = Round(tdat/10000, 0);
def tmonth = Round((tdat % 10000) / 100, 0);
def tday = (tdat % 100);

#  this fixes the  CountTradingDays() error , when it was in a normal if-then
def dayz5;
if GetYYYYMMDD() > tdat then {
 dayz5 = 0;
#} else if lastbn == bn then {
# dayz5 = CountTradingDays(GetYYYYMMDD(), dat );
} else if sbar then {
 dayz5 = CountTradingDays(GetYYYYMMDD(), tdat );
}  else {
 dayz5 = dayz5[1];
}

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

input vertical_line_target_date = yes;
addverticalline(vertical_line_target_date and is_target_date, "  " + (tmonth + " / " + tday), color.yellow);

# for EM formula, need a qty of days that starts at 0 and counts up to the qty of days to target date
#def cone_days_cnt_up = if bn == 1 then na else if lastbar then 0 else cone_days_cnt_up[1] + daysperbar;
def cone_days_cnt_up = if bn == 1 then na else if sbar then 0 else cone_days_cnt_up[1] + daysperbar;


input em_factor = 1.0;
#def em = round(em_factor * lastcls * lastiv * ( sqrt(cone_days_cnt_up/365)), 2);
#def em_per = round((em/lastcls)*100, 1);
#def em = round(em_factor * sprice * lastiv * ( sqrt(cone_days_cnt_up/365)), 2);
def em = round(em_factor * sprice * siv * ( sqrt(cone_days_cnt_up/365)), 2);
def em_per = round((em/sprice)*100, 1);

# get EM value on lastbar, so it will be displayed in a label
def em2b = if bn == 1 then 0 else if is_target_date then em else em2b[1];
def em2 = if isNaN(close[-1000]) then em2b[-1000] else Double.NaN;


# top half parabola
#plot ztop = if expan_area then (lastcls + em) else na;
#plot ztop = if expan_area then (sprice + em) else na;
plot ztop = if bn >= sbn then (sprice + em) else na;
ztop.setdefaultcolor(color.yellow);

# bottom half parabola
#plot zbot = if expan_area then (lastcls - em) else na;
#plot zbot = if expan_area then (sprice - em) else na;
plot zbot = if bn >= sbn then (sprice - em) else na;
zbot.setdefaultcolor(color.yellow);

input cone_horz_line = yes;
#plot z2 = if (cone_horz_line and expan_area) then lastcls else na;
#plot z2 = if (cone_horz_line and expan_area) then sprice else na;
plot z2 = if (cone_horz_line and bn > sbn) then sprice else na;
z2.setdefaultcolor(color.gray);

# -------------------------------------
# target date price bubbles
input show_price_bubbles = yes;
def vert = 0.99;
addchartbubble(show_price_bubbles and is_target_date, ztop, ztop , color.yellow, yes);
#addchartbubble(show_price_bubbles and is_target_date, lastcls * vert, "$" + em + "\n" + em_per + "%" , color.yellow, yes);
addchartbubble(show_price_bubbles and is_target_date, sprice * vert, "$" + em + "\n" + em_per + "%" , color.yellow, yes);
addchartbubble(show_price_bubbles and is_target_date, zbot, zbot, color.yellow, no);

input show_date_bubble = yes;
addchartbubble(show_date_bubble and is_target_date, ztop*0.99, (tmonth + "/" + tday) , color.yellow, no);

# ===========================================
# labels
addlabel(1, "IV  " + iv, color.orange);

input iv_label = yes;
AddLabel(iv_label, " " , Color.black);

input chart_stats_labels = no;
AddLabel(chart_stats_labels, "chartmin " + chartmin, Color.MAGENTA);
AddLabel(chart_stats_labels, "bars per day " + daybarqty, Color.MAGENTA);

input show_labels = yes;
addLabel(show_labels, "start date: " + smonth + "/" + sday + "/" + AsPrice(syear), color.yellow);

addLabel(show_labels, "target date: " + tmonth + "/" + tday + "/" + AsPrice(tyear), color.yellow);
addlabel(show_labels, "trading days to target date  " + dayz5, color.yellow);

addlabel(show_labels, "EM  " + "$" + em2 , color.orange);
#


intc day
GHzDB6e.jpg
 
cone, ver2
can choose the start of cone, a start date or lastbar
can choose a target date


Ruby:
# expected_move_cone_02_date

# expected move parabola , ver2
# cone starts on last bar or a date
# halcyonguy
# 22-05-19

# http://www.nishatrades.com/blog/mathematically-calculating-expected-move-using-a-probability-analysis-chart
# nisha trades , described std dev
# expected move = price * iv * ( sqrt( days to expire / 365))
#----------------------------------
def price = close;
def iv2 = imp_volatility();
def iv = round(iv2,2);

def na = double.nan;
def bn = barnumber();
def lastbn = HighestAll(If(IsNaN(price), 0, bn));
def endbn = highestall(bn);
def lastbar = if lastbn == bn then 1 else 0;
# def lastbar = !isnan(close[0]) and isnan(close[-1]);

# expansion area, bars after last bar to right edge of chart
def expan_bars = (endbn - lastbn );
def expan_area = if (bn >= lastbn and bn <= endbn) then 1 else 0;

def lastcls = if bn < lastbn then na else if bn == lastbn then price else lastcls[1];
# replace lastiv with siv
#def lastiv = if bn < lastbn then na else if bn == lastbn then iv else lastiv[1];
def newday = if getday() != getday()[1] then 1 else 0;

#--------------------------------------------
def chartagg = GetAggregationPeriod();
def chartmin = (chartagg / 1000) / 60;
def daybarqty = roundup(390 / chartmin, 0);
def daysperbar = 1/daybarqty;

# --------------------------------------------
input start_bar = { default last_bar, date };

# pick a start date
# cone starts on first bar of a day
#input start_date_yyyymmdd = 20220504;
input start_date_yyyymmdd = 20211123;
def sdat = start_date_yyyymmdd;
def is_start_date = if (GetYYYYMMDD() == sdat and newday) then 1 else 0;

def start_date_price = if is_start_date then close else start_date_price[1];

def syear = Round(sdat/10000, 0);
def smonth = Round((sdat % 10000) / 100, 0);
def sday = (sdat % 100);

# --------------------------
def big = 99999;

# cone start bar, price
def sbar;
def sprice;
def sbn;
switch(start_bar) {
case last_bar:
 sbar = lastbar;
 sprice = lastcls;
 sbn = if bn == 1 then big else if lastbar then bn else sbn[1];
case date:
 sbar = is_start_date;
 sprice = start_date_price;
 sbn = if bn == 1 then big else if is_start_date then bn else sbn[1];
}

def siv = if bn == 1 then na else if bn == sbn then iv else siv[1];

# --------------------------------------------
# date of a trading day
input target_date_yyyymmdd = 20220622;
def tdat = target_date_yyyymmdd;
def is_target_date = if (GetYYYYMMDD() == tdat and newday) then 1 else 0;

# mobius
def tyear = Round(tdat/10000, 0);
def tmonth = Round((tdat % 10000) / 100, 0);
def tday = (tdat % 100);

#  this fixes the  CountTradingDays() error , when it was in a normal if-then
def dayz5;
if GetYYYYMMDD() > tdat then {
 dayz5 = 0;
#} else if lastbn == bn then {
# dayz5 = CountTradingDays(GetYYYYMMDD(), dat );
} else if sbar then {
 dayz5 = CountTradingDays(GetYYYYMMDD(), tdat );
}  else {
 dayz5 = dayz5[1];
}

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

input vertical_line_target_date = yes;
addverticalline(vertical_line_target_date and is_target_date, "  " + (tmonth + " / " + tday), color.yellow);

# for EM formula, need a qty of days that starts at 0 and counts up to the qty of days to target date
#def cone_days_cnt_up = if bn == 1 then na else if lastbar then 0 else cone_days_cnt_up[1] + daysperbar;
def cone_days_cnt_up = if bn == 1 then na else if sbar then 0 else cone_days_cnt_up[1] + daysperbar;


input em_factor = 1.0;
#def em = round(em_factor * lastcls * lastiv * ( sqrt(cone_days_cnt_up/365)), 2);
#def em_per = round((em/lastcls)*100, 1);
#def em = round(em_factor * sprice * lastiv * ( sqrt(cone_days_cnt_up/365)), 2);
def em = round(em_factor * sprice * siv * ( sqrt(cone_days_cnt_up/365)), 2);
def em_per = round((em/sprice)*100, 1);

# get EM value on lastbar, so it will be displayed in a label
def em2b = if bn == 1 then 0 else if is_target_date then em else em2b[1];
def em2 = if isNaN(close[-1000]) then em2b[-1000] else Double.NaN;


# top half parabola
#plot ztop = if expan_area then (lastcls + em) else na;
#plot ztop = if expan_area then (sprice + em) else na;
plot ztop = if bn >= sbn then (sprice + em) else na;
ztop.setdefaultcolor(color.yellow);

# bottom half parabola
#plot zbot = if expan_area then (lastcls - em) else na;
#plot zbot = if expan_area then (sprice - em) else na;
plot zbot = if bn >= sbn then (sprice - em) else na;
zbot.setdefaultcolor(color.yellow);

input cone_horz_line = yes;
#plot z2 = if (cone_horz_line and expan_area) then lastcls else na;
#plot z2 = if (cone_horz_line and expan_area) then sprice else na;
plot z2 = if (cone_horz_line and bn > sbn) then sprice else na;
z2.setdefaultcolor(color.gray);

# -------------------------------------
# target date price bubbles
input show_price_bubbles = yes;
def vert = 0.99;
addchartbubble(show_price_bubbles and is_target_date, ztop, ztop , color.yellow, yes);
#addchartbubble(show_price_bubbles and is_target_date, lastcls * vert, "$" + em + "\n" + em_per + "%" , color.yellow, yes);
addchartbubble(show_price_bubbles and is_target_date, sprice * vert, "$" + em + "\n" + em_per + "%" , color.yellow, yes);
addchartbubble(show_price_bubbles and is_target_date, zbot, zbot, color.yellow, no);

input show_date_bubble = yes;
addchartbubble(show_date_bubble and is_target_date, ztop*0.99, (tmonth + "/" + tday) , color.yellow, no);

# ===========================================
# labels
addlabel(1, "IV  " + iv, color.orange);

input iv_label = yes;
AddLabel(iv_label, " " , Color.black);

input chart_stats_labels = no;
AddLabel(chart_stats_labels, "chartmin " + chartmin, Color.MAGENTA);
AddLabel(chart_stats_labels, "bars per day " + daybarqty, Color.MAGENTA);

input show_labels = yes;
addLabel(show_labels, "start date: " + smonth + "/" + sday + "/" + AsPrice(syear), color.yellow);

addLabel(show_labels, "target date: " + tmonth + "/" + tday + "/" + AsPrice(tyear), color.yellow);
addlabel(show_labels, "trading days to target date  " + dayz5, color.yellow);

addlabel(show_labels, "EM  " + "$" + em2 , color.orange);
#


intc day
GHzDB6e.jpg
Awesome! Thank you so much!
 
@halcyonguy
Any chance a watchlist column could be created for the probability cone to be converted to a watchlist column so it just show the upper and lower expected move depending on the expected move factor?
 
Last edited by a moderator:
Expected moved, probability cone

enter a date and it draws a parabola and calculates an expected move, using this equation.
expected move = price * iv * ( sqrt( days to expire / 365))
http://www.nishatrades.com/blog/mat...ected-move-using-a-probability-analysis-chart


if the chart time is more than day, the date has to be,
..if week , then a monday
..if month, then the 1st trading day of the month

Ruby:
# expected_move_cone_01

# expected move parabola
# cone starts on last bar
# halcyonguy
# 22-04-09

# http://www.nishatrades.com/blog/mathematically-calculating-expected-move-using-a-probability-analysis-chart
# nisha trades , described std dev
# expected move = price * iv * ( sqrt( days to expire / 365))
#----------------------------------
def price = close;
def iv2 = imp_volatility();
def iv = round(iv2,2);

def na = double.nan;
def bn = barnumber();
def lastbn = HighestAll(If(IsNaN(price), 0, bn));
def endbn = highestall(bn);
def lastbar = if lastbn == bn then 1 else 0;
# def lastbar = !isnan(close[0]) and isnan(close[-1]);

# expansion area, bars after last bar to right edge of chart
def expan_bars = (endbn - lastbn );
def expan_area = if (bn >= lastbn and bn <= endbn) then 1 else 0;

def lastcls = if bn < lastbn then na else if bn == lastbn then price else lastcls[1];
def lastiv = if bn < lastbn then na else if bn == lastbn then iv else lastiv[1];

def newday = if getday() != getday()[1] then 1 else 0;

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

def chartagg = GetAggregationPeriod();
def chartmin = (chartagg / 1000) / 60;
def daybarqty = roundup(390 / chartmin, 0);
def daysperbar = 1/daybarqty;

# for EM formula, need a qty of days that starts at 0 and counts up to the qty of days to target date
def cone_days_cnt_up = if bn == 1 then na else if lastbar then 0 else cone_days_cnt_up[1] + daysperbar;

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

# date of a trading day
input target_date_yyyymmdd = 20220520;
def dat = target_date_yyyymmdd;
def is_target_date = if (GetYYYYMMDD() == dat and newday) then 1 else 0;

# mobius
def data = dat;
def year = Round(data/10000, 0);
def month = Round((data % 10000) / 100, 0);
def day = (data % 100);

#  this fixes the  CountTradingDays() error , when it was in a normal if-then
def dayz5;
if GetYYYYMMDD() > dat then {
 dayz5 = 0;
} else if lastbn == bn then {
 dayz5 = CountTradingDays(GetYYYYMMDD(), dat );
}  else {
 dayz5 = dayz5[1];
}

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

input vertical_line_target_date = yes;
addverticalline(vertical_line_target_date and is_target_date, "  " + (month + " / " + day), color.yellow);

input em_factor = 1.0;
def em = round(em_factor * lastcls * lastiv * ( sqrt(cone_days_cnt_up/365)), 2);
def em_per = round((em/lastcls)*100, 1);

# get EM value on lastbar, so it will be displayed in a label
def em2b = if bn == 1 then 0 else if is_target_date then em else em2b[1];
def em2 = if isNaN(close[-1000])  then em2b[-1000]   else Double.NaN;

# top half parabola
plot ztop = if expan_area then (lastcls + em) else na;
ztop.setdefaultcolor(color.yellow);

# bottom half parabola
plot zbot = if expan_area then (lastcls - em) else na;
zbot.setdefaultcolor(color.yellow);

input cone_horz_line = yes;
plot z2 = if (cone_horz_line and expan_area) then lastcls else na;
z2.setdefaultcolor(color.gray);

# -------------------------------------
# target date price bubbles
input show_price_bubbles = yes;
def vert = 0.99;
addchartbubble(show_price_bubbles and is_target_date, ztop, ztop , color.yellow, yes);
addchartbubble(show_price_bubbles and is_target_date, lastcls * vert, "$" + em + "\n" + em_per + "%" , color.yellow, yes);
addchartbubble(show_price_bubbles and is_target_date, zbot, zbot, color.yellow, no);

input show_date_bubble = yes;
addchartbubble(show_date_bubble and is_target_date, ztop*0.99, (month + "/" + day) , color.yellow, no);

# ===========================================
# labels
addlabel(1, "IV  " + iv, color.orange);

input iv_label = yes;
AddLabel(iv_label, " " , Color.black);

input chart_stats_labels = no;
AddLabel(chart_stats_labels, "chartmin " + chartmin, Color.MAGENTA);
AddLabel(chart_stats_labels, "bars per day " + daybarqty, Color.MAGENTA);

input show_labels = yes;
addLabel(show_labels, "target date: " + month + "/" + day + "/" + AsPrice(year), color.yellow);
addlabel(show_labels, "trading days to target date  " + dayz5, color.yellow);

addlabel(show_labels, "EM  " + "$" + em2 , color.orange);
#


WMT 30min 90day 400 expan bars
View attachment 14260
hal_cone
Hello,
EM always returns a $0 value for me. I picked a 7/14/2023 target date (6 days to target) but EM is $0. What am I doing wrong?
Thank you.
 
Expected moved, probability cone

enter a date and it draws a parabola and calculates an expected move, using this equation.
expected move = price * iv * ( sqrt( days to expire / 365))
http://www.nishatrades.com/blog/mat...ected-move-using-a-probability-analysis-chart


if the chart time is more than day, the date has to be,
..if week , then a monday
..if month, then the 1st trading day of the month

Ruby:
# expected_move_cone_01

# expected move parabola
# cone starts on last bar
# halcyonguy
# 22-04-09

# http://www.nishatrades.com/blog/mathematically-calculating-expected-move-using-a-probability-analysis-chart
# nisha trades , described std dev
# expected move = price * iv * ( sqrt( days to expire / 365))
#----------------------------------
def price = close;
def iv2 = imp_volatility();
def iv = round(iv2,2);

def na = double.nan;
def bn = barnumber();
def lastbn = HighestAll(If(IsNaN(price), 0, bn));
def endbn = highestall(bn);
def lastbar = if lastbn == bn then 1 else 0;
# def lastbar = !isnan(close[0]) and isnan(close[-1]);

# expansion area, bars after last bar to right edge of chart
def expan_bars = (endbn - lastbn );
def expan_area = if (bn >= lastbn and bn <= endbn) then 1 else 0;

def lastcls = if bn < lastbn then na else if bn == lastbn then price else lastcls[1];
def lastiv = if bn < lastbn then na else if bn == lastbn then iv else lastiv[1];

def newday = if getday() != getday()[1] then 1 else 0;

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

def chartagg = GetAggregationPeriod();
def chartmin = (chartagg / 1000) / 60;
def daybarqty = roundup(390 / chartmin, 0);
def daysperbar = 1/daybarqty;

# for EM formula, need a qty of days that starts at 0 and counts up to the qty of days to target date
def cone_days_cnt_up = if bn == 1 then na else if lastbar then 0 else cone_days_cnt_up[1] + daysperbar;

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

# date of a trading day
input target_date_yyyymmdd = 20220520;
def dat = target_date_yyyymmdd;
def is_target_date = if (GetYYYYMMDD() == dat and newday) then 1 else 0;

# mobius
def data = dat;
def year = Round(data/10000, 0);
def month = Round((data % 10000) / 100, 0);
def day = (data % 100);

#  this fixes the  CountTradingDays() error , when it was in a normal if-then
def dayz5;
if GetYYYYMMDD() > dat then {
 dayz5 = 0;
} else if lastbn == bn then {
 dayz5 = CountTradingDays(GetYYYYMMDD(), dat );
}  else {
 dayz5 = dayz5[1];
}

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

input vertical_line_target_date = yes;
addverticalline(vertical_line_target_date and is_target_date, "  " + (month + " / " + day), color.yellow);

input em_factor = 1.0;
def em = round(em_factor * lastcls * lastiv * ( sqrt(cone_days_cnt_up/365)), 2);
def em_per = round((em/lastcls)*100, 1);

# get EM value on lastbar, so it will be displayed in a label
def em2b = if bn == 1 then 0 else if is_target_date then em else em2b[1];
def em2 = if isNaN(close[-1000])  then em2b[-1000]   else Double.NaN;

# top half parabola
plot ztop = if expan_area then (lastcls + em) else na;
ztop.setdefaultcolor(color.yellow);

# bottom half parabola
plot zbot = if expan_area then (lastcls - em) else na;
zbot.setdefaultcolor(color.yellow);

input cone_horz_line = yes;
plot z2 = if (cone_horz_line and expan_area) then lastcls else na;
z2.setdefaultcolor(color.gray);

# -------------------------------------
# target date price bubbles
input show_price_bubbles = yes;
def vert = 0.99;
addchartbubble(show_price_bubbles and is_target_date, ztop, ztop , color.yellow, yes);
addchartbubble(show_price_bubbles and is_target_date, lastcls * vert, "$" + em + "\n" + em_per + "%" , color.yellow, yes);
addchartbubble(show_price_bubbles and is_target_date, zbot, zbot, color.yellow, no);

input show_date_bubble = yes;
addchartbubble(show_date_bubble and is_target_date, ztop*0.99, (month + "/" + day) , color.yellow, no);

# ===========================================
# labels
addlabel(1, "IV  " + iv, color.orange);

input iv_label = yes;
AddLabel(iv_label, " " , Color.black);

input chart_stats_labels = no;
AddLabel(chart_stats_labels, "chartmin " + chartmin, Color.MAGENTA);
AddLabel(chart_stats_labels, "bars per day " + daybarqty, Color.MAGENTA);

input show_labels = yes;
addLabel(show_labels, "target date: " + month + "/" + day + "/" + AsPrice(year), color.yellow);
addlabel(show_labels, "trading days to target date  " + dayz5, color.yellow);

addlabel(show_labels, "EM  " + "$" + em2 , color.orange);
#


WMT 30min 90day 400 expan bars
View attachment 14260
hal_cone
if one wanted a default of 45 days, how could they tweak the script? thanks in advance
 
This is an excellent series of thoughtful posts first started by halcyonguy. The exchange has resulted in many excellent ideas and scripts. I think a useful addition to the series would be the Probability of Touch cone. I cannot determine how to even start the scripting, but I can appreciate the value of seeing this super-imposed upon the ones above. Here are some benefits I think could benefit:
  1. Rather than have a single script of multiple cones, the combination of individual scripts could provide easy customization.
  2. Prob at expiration is definitely useful, but few of us are holding positions all the way to the full expiration. Graphically seeing prob of touch relative to expiration could better inform than expiration alone.
  3. A prob of touch cone that is based more on actual price movement / delta versus is potentially more statistically correct since it is not based on option pricing in the same way as expected move which is known to be overstated vs actual move.
  4. Probability of touch may show the potential risk points of assignments of short / spread positions that may not be appreciated under expiration cones only.
  5. Prob of touch would seem to provide than both a "risk zone" or "profit zone" by looking at the remaining time versus these cone lines. And it could inform our decision of the optimal DTE expiration etc.
  6. There was an excellent discussion on Prob of Touch this week in TOS / Schwab coaching if anyone has interest. In this discussion, I asked if a script existed for Prob of Touch and the moderator said none that he was aware of but suggested it might be possible to script it -
 
Weekly IV Implied Move Probability Cone
Ruby:
# IV Implied Move Probability Cone
# Mobius
# V01.03.2021
####################################################
# mods by zoyd V04.09.2022
# Added weekly implied move
# Added realized volatility traces
# Added option for 0DTE (was SPY only)
# if series IV not available use Black-Scholes
# Recommended aggregation is 5 min and 12 RV samples
####################################################
# Credit for code snippet/weekly Implied move
# TheoTrade_Weely_Expected_Move
# Copyright TheoTrade LLC
# V08.11.2017
####################################################
input ShowBubbles = no;
input meanType = {default Daily, OpenRange};
input DTE0 = no;
input RealEq = {default RogersSatchell, YangZhang, Simple};
input RVlength = 12;
def c = close;
def x = BarNumber();
def nan = Double.NaN;
def active = SecondsFromTime(0930) >= 0 and
             SecondsTillTime(1000) <= 0;
def DOW = GetDayOfWeek(GetYYYYMMDD());

#get close from prev Friday
def Monday = DOW == 1;
def Friday = DOW == 5;
def FridayC = if Friday then close(period = AggregationPeriod.DAY) else FridayC[1];
def lastFridayC = if Monday then FridayC else lastFridayC[1];

def ORH = if active
          then high(period = AggregationPeriod.THIRTY_MIN)
          else ORH[1];
def ORL = if active
          then low(period = AggregationPeriod.THIRTY_MIN)
          else ORL[1];

def t = if SecondsFromTime(0930) > 0
        then SecondsTillTime(1600) / 23400
        else 1;
def DTE;

def IV = if !IsNaN(SeriesVolatility(series = 1))
         then SeriesVolatility(series = 1)
         else if IsNaN(SeriesVolatility(series = 1)) and
                 !IsNaN(SeriesVolatility(series = 2))
         then SeriesVolatility(series = 2)
         else if IsNaN(SeriesVolatility(series = 1)) and
                 IsNaN(SeriesVolatility(series = 2)) and
                !IsNaN(SeriesVolatility(series = 3))
         then SeriesVolatility(series = 3)
         else if !isnan(imp_volatility()) then imp_volatility() else IV[1];

if DOW == 1
{
    DTE = if DTE0 then t else 5 - DOW;
}
else if DOW == 2
{
    DTE = if DTE0 then 1 + t else 5 - DOW;
}
else if DOW == 3
{
    DTE = if DTE0 then t else 5 - DOW;
}
else if DOW == 4
{
    DTE = if DTE0 then 1 + t else 5 - DOW;
}
else if DOW == 5
{
    DTE = t;
}
else
{
    DTE = DTE[1];
}

def RTH = GetTime() >= RegularTradingStart(GetYYYYMMDD()) and
          GetTime() <= RegularTradingEnd(GetYYYYMMDD());
def x1 = if RTH and !RTH[1]
        then x
        else x1[1];

#borrowed from theo-daily weekly EM
#comment about bandwidth:
# " 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."
input em_skew_percent = 85;
input em_bandwidth = 100;

def ImpMove = if DTE > 0
              then (c * IV * Sqrt(DTE) / Sqrt(365)) * em_skew_percent / 100
              else (c * IV * 1 / Sqrt(365)) * em_skew_percent / 100 * em_bandwidth / 100;

def ImpMoveW = if Monday
              then imp_volatility(period = AggregationPeriod.DAY) * lastFridayC * Sqrt(6) / Sqrt(365) * em_skew_percent / 100 * em_bandwidth / 100
              else ImpMoveW[1];

def factor = AggregationPeriod.DAY/(GetAggregationPeriod()*RVlength);
def RVMove;
switch (RealEq) {
    case RogersSatchell:
        RVMove = expaverage(Sqrt(Sum(Log(high / close) * Log(high / open) + Log(low / close) * Log(low / open), RVlength)) * c * sqrt(factor),RVlength);
    case YangZhang:
        RVMove = expaverage(Sqrt(Sum(Sqr(Log(open / close[1])), RVlength) + Sum(1 / 2 *     Sqr(Log(high / low )), RVlength) -
Sum( (2 * Log(2) - 1) * Sqr(Log(close / open)), RVlength) ) * c * sqrt(factor),RVlength);
    case Simple:
        RVMove = expaverage(Sqrt(Sum(Sqr(Log(c / c[1])),RVLength)) * c * sqrt(factor), RVLength);
}
def RV_Y =  RVMove * Sqrt(365) / c ;
def meanW = if Monday then lastFridayC else if meanW[1] then meanW[1] else c;

plot mean;
switch (meanType)
    {
case Daily:
    mean = (Max(high(period = "DAY"), close(period = "DAY")[1]) +
                 Min(low(period = "DAY"), close(period = "DAY")[1])) / 2;
case OpenRange:
    mean = (ORH + ORL) / 2;
}
mean.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
mean.SetLineWeight(2);
mean.SetDefaultColor(Color.DARK_GRAY);

plot Upper = if RTH and x >= HighestAll(x1)
             then mean + Round(ImpMove / TickSize(), 0) * TickSize()
             else Double.NaN;
plot UpperW = if RTH and x >= HighestAll(x1)
             then meanW + Round(ImpMoveW / TickSize(), 0) * TickSize()
             else Double.NaN;
plot UpperRV = if RTH and x >= HighestAll(x1)
             then mean + Round(RVMove / TickSize(), 0) * TickSize()
             else Double.NaN;
Upper.SetPaintingStrategy(PaintingStrategy.LINE);
Upper.SetDefaultColor(Color.GRAY);
Upper.HideTitle();
UpperW.SetPaintingStrategy(PaintingStrategy.LINE);
UpperW.SetDefaultColor(Color.LIGHT_GRAY);
UpperW.HideTitle();
UpperRV.SetPaintingStrategy(PaintingStrategy.LINE);
UpperRV.SetDefaultColor(Color.LIGHT_ORANGE);
UpperRV.HideTitle();
AddChartBubble(ShowBubbles and x == HighestAll(x), Upper, "ImpMove", Upper.TakeValueColor());
AddChartBubble(ShowBubbles and x == HighestAll(x), UpperW, "IMWeekly", UpperW.TakeValueColor());
AddChartBubble(ShowBubbles and x == HighestAll(x), UpperRV, "RVMove", UpperRV.TakeValueColor());

plot MeanHigh = if RTH and x >= HighestAll(x1)
                then mean + Round((ImpMove * .682) / TickSize(), 0) * TickSize()
                else Double.NaN;
MeanHigh.SetPaintingStrategy(PaintingStrategy.LINE);
MeanHigh.SetDefaultColor(Color.DARK_GRAY);
MeanHigh.HideTitle();
MeanHigh.SetLineWeight(3);
AddChartBubble(ShowBubbles and x == HighestAll(x), MeanHigh, "ProbMove", MeanHigh.TakeValueColor());
AddCloud(Upper, MeanHigh, CreateColor(212, 175, 55), CreateColor(212, 175, 55));
plot Lower = if RTH and x >= HighestAll(x1)
             then mean - Round(ImpMove / TickSize(), 0) * TickSize()
             else Double.NaN;
plot LowerRV = if RTH and x >= HighestAll(x1)
             then mean - Round(RVMove / TickSize(), 0) * TickSize()
             else Double.NaN;
plot LowerW = if RTH and x >= HighestAll(x1)
             then meanW - Round(ImpMoveW / TickSize(), 0) * TickSize()
             else Double.NaN;
Lower.SetPaintingStrategy(PaintingStrategy.LINE);
Lower.SetDefaultColor(Color.GRAY);
Lower.HideTitle();
AddChartBubble(ShowBubbles and x == HighestAll(x), Lower, "ImpMove", Lower.TakeValueColor(), no);
LowerRV.SetPaintingStrategy(PaintingStrategy.LINE);
LowerRV.SetDefaultColor(Color.LIGHT_ORANGE);
LowerRV.HideTitle();
AddChartBubble(ShowBubbles and x == HighestAll(x), LowerRV, "RVMove", LowerRV.TakeValueColor(), no);
LowerW.SetPaintingStrategy(PaintingStrategy.LINE);
LowerW.SetDefaultColor(Color.LIGHT_GRAY);
LowerW.HideTitle();
AddChartBubble(ShowBubbles and x == HighestAll(x), LowerW, "IMWeekly", LowerW.TakeValueColor(), no);

plot MeanLow = if RTH and x >= HighestAll(x1)
               then mean - Round((ImpMove * .682) / TickSize(), 0) * TickSize()
               else Double.NaN;
MeanLow.SetPaintingStrategy(PaintingStrategy.LINE);
MeanLow.SetDefaultColor(Color.DARK_GRAY);
MeanLow.HideTitle();
MeanLow.SetLineWeight(3);
AddChartBubble(ShowBubbles and x == HighestAll(x), MeanLow, "ProbMove", MeanLow.TakeValueColor(), no);
AddCloud(Lower, MeanLow, CreateColor(212, 175, 55), CreateColor(212, 175, 55));

AddLabel(1, "IV = " + AsPercent(IV) +
          "  Todays IM = " + AsDollars(ImpMove) +
          "  PM = " + AsDollars(Round((ImpMove * .682) / TickSize(), 0) * TickSize()) +
          "  RV = " + AsPercent(RV_Y) +
          "  Daily RV = " + AsDollars(Round((RVMove) / TickSize(), 0) * TickSize()) +
          "  IMWeekly = " + AsDollars(Round((ImpMoveW) / TickSize(), 0) * TickSize()) + "        "  ,
         Color.LIGHT_GRAY);
# End Code IV Cone
According to the TradingVolaity guys, YangZhang is the most accurate and can be run on 1m with 2 days data. Has anyone back tested this?
 
Can this be used for 0DTE?
I built a simple close - close, open - close, or both (average) for 0DTE, its very simple but plots daily expected quartiles.

#Methods procedures and processes described herein are trade secrets of Buyer Group International Inc and are protected under the appropirate Trade Seceret Act of the US Co

declare once_per_bar;
declare upper;

#input close = close;
#input open = open;
input labels = yes;
input Ann = yes;
input VolType = {default series, implied};
input sym = "SPX";
input Type = {default both, close, open};
input rank1 = .25;
input rank2 = .5;
input rank3 = .75;
input rank4 = 1.0;
input projected = yes;

#Complex variables

def len = 20;
def Strike_Spread = .5;
def DayToExpiry = 1;
def Series_IV = 1;
def Agg = GetAggregationPeriod();
def AggDay = AggregationPeriod.DAY;
def nan = Double.NaN;
def impIV = imp_volatility(sym, Agg);
def SIV = SeriesVolatility(series = Series_IV);
def S = close; #Spot price

def year = AggregationPeriod.YEAR;
#def RIV = imp_volatility(sym, year)[1];
def RIV = imp_volatility(sym, AggDay)[365];


def IV;
switch (VolType) {
case "implied":
IV = impIV;
case "series":
IV = SIV;
}


def SDayC = if GetAggregationPeriod() < AggregationPeriod.DAY then close(period = AggDay)[1] else close(period = Agg)[1]; #yesterdays close
def SDayO = if GetAggregationPeriod() != AggregationPeriod.DAY then open(period = AggDay)[0] else open(period = AggDay)[0]; #today's open

#def move = IV / 15.9 * S; #252 trading days
#def move = IV / 19.1 * S; #365 actual days

def move = if Ann then IV / 19.1 * S else IV / 15.9 * S; #365 actual days #19.1
def closeD = close(period = AggDay);
def closeLog = Log(close[1] / close[2]);
def SDev = stdev(closeLog, len)* Sqrt(len / (len – 1));
def m= SDev * close[1];
#def spike = (close[0] – close[1]) / m;


def IVUp1;
def IVUp2;
def IVUp3;
def IVUp4;

def IVDw1;
def IVDw2;
def IVDw3;
def IVDw4;

def v = rank1;
def x = rank2;
def y = rank3;
def z = rank4;

switch (Type) {
case "close":
IVUp1 = SDayC + move * v;
IVUp2 = SDayC + move * x;
IVUp3 = SDayC + move * y;
IVUp4 = SDayC + move * z;

IVDw1 = SDayC - move * v;
IVDw2 = SDayC - move * x;
IVDw3 = SDayC - move * y;
IVDw4 = SDayC - move * z;
case "open":
IVUp1 = SDayC + move * v;
IVUp2 = SDayC + move * x;
IVUp3 = SDayC + move * y;
IVUp4 = SDayC + move * z;

IVDw1 = SDayC - move * v;
IVDw2 = SDayC - move * x;
IVDw3 = SDayC - move * y;
IVDw4 = SDayC - move * z;
case "both":

IVUp1 = (SDayC + SDayO) / 2 + move * v;
IVUp2 = (SDayC + SDayO) / 2 + move * x;
IVUp3 = (SDayC + SDayO) / 2 + move * y;
IVUp4 = (SDayC + SDayO) / 2 + move * z;

IVDw1 = (SDayC + SDayO) / 2 - move * v;
IVDw2 = (SDayC + SDayO) / 2 - move * x;
IVDw3 = (SDayC + SDayO) / 2 - move * y;
IVDw4 = (SDayC + SDayO) / 2 - move * z;
}


AddLabel(labels, "Today's IV: " + Round(impIV * 100, 2) + " Realize IV: " + Round(RIV * 100, 1) + " Move: $" + Round(move, 2) + " UpMove: $" + Round(IVUp1, 2) + " DwMove: $" + Round(IVDw1, 2), Color.LIME);
#AddCloud(if projected then upperbound else nan, up3, Color.DARK_RED, Color.PLUM);
#AddCloud(if projected then lowerbound else nan, dw3, Color.DARK_GREEN, Color.LIGHT_GREEN);

#def wmove = MovingAverage(wavg, moved, len);
#plot up11 = SDayO + wmove;
#plot dw11 = SDayO - wmove;

plot VolTrigger = (IVUp1 + IVDw1) / 2;
VolTrigger.SetDefaultColor(color.magenta);
VolTrigger.SetStyle(Curve.SHORT_DASH);# PaintingStrategy(PaintingStrategy.DASHES);

plot mu1 = if VolTrigger <> 0 then IVUp1 else nan;
plot mu2 = if projected then IVUp2 else nan;
plot mu3 = if projected then IVUp3 else nan;
plot mu4 = if projected then IVUp4 else nan;
mu1.SetPaintingStrategy(PaintingStrategy.DASHES);
mu2.SetPaintingStrategy(PaintingStrategy.DASHES);
mu3.SetPaintingStrategy(PaintingStrategy.DASHES);
mu4.SetPaintingStrategy(PaintingStrategy.DASHES);


plot md1 = if VolTrigger <> 0 then IVDw1 else nan;
plot md2 = if projected then IVDw2 else nan;
plot md3 = if projected then IVDw3 else nan;
plot md4 = if projected then IVDw4 else nan;
md1.SetPaintingStrategy(PaintingStrategy.DASHES);
md2.SetPaintingStrategy(PaintingStrategy.DASHES);
md3.SetPaintingStrategy(PaintingStrategy.DASHES);
md4.SetPaintingStrategy(PaintingStrategy.DASHES);

mu1.SetDefaultColor(color.light_GREEN);
mu2.SetDefaultColor(color.light_GREEN);
mu3.SetDefaultColor(color.light_GREEN);
mu4.SetDefaultColor(color.light_GREEN);
md1.SetDefaultColor(color.violet);
md2.SetDefaultColor(color.violet);
md3.SetDefaultColor(color.violet);
md4.SetDefaultColor(color.violet);
 
def lastbar = if lastbn == bn then 1 else 0; # def lastbar = !isnan(close[0]) and isnan(close[-1]); # expansion area, bars after last bar to right edge of chart def expan_bars = (endbn - lastbn ); def expan_area = if (bn >= lastbn and bn <= endbn) then 1 else 0; def lastcls = if bn < lastbn then na else if bn == lastbn then price else lastcls[1]; # replace lastiv with siv #def lastiv = if bn < lastbn then na else if bn == lastbn then iv else lastiv[1]; def newday = if getday() != getday()[1] then 1 else 0; #-------------------------------------------- def chartagg = GetAggregationPeriod(); def chartmin = (chartagg / 1000) / 60; def daybarqty = roundup(390 / chartmin, 0); def daysperbar = 1/daybarqty; # -------------------------------------------- input start_bar = { default last_bar, date }; # pick a start date # cone starts on first bar of a day #input start_date_yyyymmdd = 20220504; input start_date_yyyymmdd = 20211123; def sdat = start_date_yyyymmdd; def is_start_date = if (GetYYYYMMDD() == sdat and newday) then 1 else 0; def start_date_price = if is_start_date then close else start_date_price[1]; def syear = Round(sdat/10000, 0); def smonth = Round((sdat % 10000) / 100, 0); def sday = (sdat % 100); # -------------------------- def big = 99999; # cone start bar, price def sbar; def sprice; def sbn; switch(start_bar) { case last_bar: sbar = lastbar; sprice = lastcls; sbn = if bn == 1 then big else if lastbar then bn else sbn[1]; case date: sbar = is_start_date; sprice = start_date_price; sbn = if bn == 1 then big else if is_start_date then bn else sbn[1]; } def siv = if bn == 1 then na else if bn == sbn then iv else siv[1]; # -------------------------------------------- # date of a trading day input target_date_yyyymmdd = 20220622; def tdat = target_date_yyyymmdd; def is_target_date = if (GetYYYYMMDD() == tdat and newday) then 1 else 0; # mobius def tyear = Round(tdat/10000, 0); def tmonth = Round((tdat % 10000) / 100, 0); def tday = (tdat % 100); # this fixes the CountTradingDays() error , when it was in a normal if-then def dayz5; if GetYYYYMMDD() > tdat then { dayz5 = 0; #} else if lastbn == bn then { # dayz5 = CountTradingDays(GetYYYYMMDD(), dat ); } else if sbar then { dayz5 = CountTradingDays(GetYYYYMMDD(), tdat ); } else { dayz5 = dayz5[1]; } # ------------------------------------- input vertical_line_target_date = yes; addverticalline(vertical_line_target_date and is_target_date, " " + (tmonth + " / " + tday), color.yellow); # for EM formula, need a qty of days that starts at 0 and counts up to the qty of days to target date #def cone_days_cnt_up = if bn == 1 then na else if lastbar then 0 else cone_days_cnt_up[1] + daysperbar; def cone_days_cnt_up = if bn == 1 then na else if sbar then 0 else cone_days_cnt_up[1] + daysperbar; input em_factor = 1.0; #def em = round(em_factor * lastcls * lastiv * ( sqrt(cone_days_cnt_up/365)), 2); #def em_per = round((em/lastcls)*100, 1); #def em = round(em_factor * sprice * lastiv * ( sqrt(cone_days_cnt_up/365)), 2); def em = round(em_factor * sprice * siv * ( sqrt(cone_days_cnt_up/365)), 2); def em_per = round((em/sprice)*100, 1); # get EM value on lastbar, so it will be displayed in a label def em2b = if bn == 1 then 0 else if is_target_date then em else em2b[1]; def em2 = if isNaN(close[-1000]) then em2b[-1000] else Double.NaN; # top half parabola #plot ztop = if expan_area then (lastcls + em) else na; #plot ztop = if expan_area then (sprice + em) else na; plot ztop = if bn >= sbn then (sprice + em) else na; ztop.setdefaultcolor(color.yellow); # bottom half parabola #plot zbot = if expan_area then (lastcls - em) else na; #plot zbot = if expan_area then (sprice - em) else na; plot zbot = if bn >= sbn then (sprice - em) else na; zbot.setdefaultcolor(color.yellow); input cone_horz_line = yes; #plot z2 = if (cone_horz_line and expan_area) then lastcls else na; #plot z2 = if (cone_horz_line and expan_area) then sprice else na; plot z2 = if (cone_horz_line and bn > sbn) then sprice else na; z2.setdefaultcolor(color.gray); # ------------------------------------- # target date price bubbles input show_price_bubbles = yes; def vert = 0.99; addchartbubble(show_price_bubbles and is_target_date, ztop, ztop , color.yellow, yes); #addchartbubble(show_price_bubbles and is_target_date, lastcls * vert, "$" + em + "\n" + em_per + "%" , color.yellow, yes); addchartbubble(show_price_bubbles and is_target_date, sprice * vert, "$" + em + "\n" + em_per + "%" , color.yellow, yes); addchartbubble(show_price_bubbles and is_target_date, zbot, zbot, color.yellow, no); input show_date_bubble = yes; addchartbubble(show_date_bubble and is_target_date, ztop*0.99, (tmonth + "/" + tday) , color.yellow, no); # =========================================== # labels addlabel(1, "IV " + iv, color.orange); input iv_label = yes; AddLabel(iv_label, " " , Color.black); input chart_stats_labels = no; AddLabel(chart_stats_labels, "chartmin " + chartmin, Color.MAGENTA); AddLabel(chart_stats_labels, "bars per day " + daybarqty, Color.MAGENTA); input show_labels = yes; addLabel(show_labels, "start date: " + smonth + "/" + sday + "/" + AsPrice(syear), color.yellow); addLabel(show_labels, "target date: " + tmonth + "/" + tday + "/" + AsPrice(tyear), color.yellow); addlabel(show_labels, "trading days to target date " + dayz5, color.yellow); addlabel(show_labels, "EM " + "$" + em2 , color.orange); #
Lots of errors when loaded -
Expected double
Wrong type cast: different types after then and else: double vs interface com.devexperts.tos.thinkscript.script.ScriptLogic$UnknownType
Wrong type cast: different types after then and else: interface com.devexperts.tos.thinkscript.script.ScriptLogic$UnknownType vs double
Expected double at 103:6
Expected double at 109:6
Expected double at 115:6
No such variable: lastbn at 1:18
No such variable: bn at 1:28
No such variable: endbn at 5:19
No such variable: lastbn at 5:27
No such variable: bn at 6:22
No such variable: lastbn at 6:28
No such variable: bn at 6:39
No such variable: endbn at 6:45
No such variable: bn at 8:18
No such variable: lastbn at 8:23
No such variable: na at 8:35
No such variable: bn at 8:46
No such variable: lastbn at 8:52
 
Lots of errors when loaded -
Expected double
Wrong type cast: different types after then and else: double vs interface com.devexperts.tos.thinkscript.script.ScriptLogic$UnknownType
Wrong type cast: different types after then and else: interface com.devexperts.tos.thinkscript.script.ScriptLogic$UnknownType vs double
Expected double at 103:6
Expected double at 109:6
Expected double at 115:6
No such variable: lastbn at 1:18
No such variable: bn at 1:28
No such variable: endbn at 5:19
No such variable: lastbn at 5:27
No such variable: bn at 6:22
No such variable: lastbn at 6:28
No such variable: bn at 6:39
No such variable: endbn at 6:45
No such variable: bn at 8:18
No such variable: lastbn at 8:23
No such variable: na at 8:35
No such variable: bn at 8:46
No such variable: lastbn at 8:52

There is something wrong with your cutting and pasting.
Every line of script needs to be a separate line.

Compare @halcyonguy script layout to what you cut & pasted.
Yours is one long run-on sentence and cannot be deciphered by ToS.

Follow these instructions to cut & paste:
https://usethinkscript.com/threads/how-to-import-existing-thinkscript-code-on-thinkorswim.10/
 
This is an excellent series of thoughtful posts first started by halcyonguy. The exchange has resulted in many excellent ideas and scripts. I think a useful addition to the series would be the Probability of Touch cone. I cannot determine how to even start the scripting, but I can appreciate the value of seeing this super-imposed upon the ones above. Here are some benefits I think could benefit:
  1. Rather than have a single script of multiple cones, the combination of individual scripts could provide easy customization.
  2. Prob at expiration is definitely useful, but few of us are holding positions all the way to the full expiration. Graphically seeing prob of touch relative to expiration could better inform than expiration alone.
  3. A prob of touch cone that is based more on actual price movement / delta versus is potentially more statistically correct since it is not based on option pricing in the same way as expected move which is known to be overstated vs actual move.
  4. Probability of touch may show the potential risk points of assignments of short / spread positions that may not be appreciated under expiration cones only.
  5. Prob of touch would seem to provide than both a "risk zone" or "profit zone" by looking at the remaining time versus these cone lines. And it could inform our decision of the optimal DTE expiration etc.
  6. There was an excellent discussion on Prob of Touch this week in TOS / Schwab coaching if anyone has interest. In this discussion, I asked if a script existed for Prob of Touch and the moderator said none that he was aware of but suggested it might be possible to script it -
Watched the video. Markets abhore lack of structure and balance. The pullbacks are to establish balance at those levels with delta hedging creating the structure (gex).

The gap will be closed, eventually. The markets have all time highs, with little resistance or support, so if the currency markets (bond markets/auctions) cause gaps, you can expect this type of behavior each and every time, creating structure and balance.
 
# expected_move_cone_01 .
Is it possible to input a x days , to be added to current day, rather than a fixed/target date ?
If so can you pls send the code ? Thanks in advance.
 
I built a simple close - close, open - close, or both (average) for 0DTE, its very simple but plots daily expected quartiles.

#Methods procedures and processes described herein are trade secrets of Buyer Group International Inc and are protected under the appropirate Trade Seceret Act of the US Co

declare once_per_bar;
declare upper;

#input close = close;
#input open = open;
input labels = yes;
input Ann = yes;
input VolType = {default series, implied};
input sym = "SPX";
input Type = {default both, close, open};
input rank1 = .25;
input rank2 = .5;
input rank3 = .75;
input rank4 = 1.0;
input projected = yes;

#Complex variables

def len = 20;
def Strike_Spread = .5;
def DayToExpiry = 1;
def Series_IV = 1;
def Agg = GetAggregationPeriod();
def AggDay = AggregationPeriod.DAY;
def nan = Double.NaN;
def impIV = imp_volatility(sym, Agg);
def SIV = SeriesVolatility(series = Series_IV);
def S = close; #Spot price

def year = AggregationPeriod.YEAR;
#def RIV = imp_volatility(sym, year)[1];
def RIV = imp_volatility(sym, AggDay)[365];


def IV;
switch (VolType) {
case "implied":
IV = impIV;
case "series":
IV = SIV;
}


def SDayC = if GetAggregationPeriod() < AggregationPeriod.DAY then close(period = AggDay)[1] else close(period = Agg)[1]; #yesterdays close
def SDayO = if GetAggregationPeriod() != AggregationPeriod.DAY then open(period = AggDay)[0] else open(period = AggDay)[0]; #today's open

#def move = IV / 15.9 * S; #252 trading days
#def move = IV / 19.1 * S; #365 actual days

def move = if Ann then IV / 19.1 * S else IV / 15.9 * S; #365 actual days #19.1
def closeD = close(period = AggDay);
def closeLog = Log(close[1] / close[2]);
def SDev = stdev(closeLog, len)* Sqrt(len / (len – 1));
def m= SDev * close[1];
#def spike = (close[0] – close[1]) / m;


def IVUp1;
def IVUp2;
def IVUp3;
def IVUp4;

def IVDw1;
def IVDw2;
def IVDw3;
def IVDw4;

def v = rank1;
def x = rank2;
def y = rank3;
def z = rank4;

switch (Type) {
case "close":
IVUp1 = SDayC + move * v;
IVUp2 = SDayC + move * x;
IVUp3 = SDayC + move * y;
IVUp4 = SDayC + move * z;

IVDw1 = SDayC - move * v;
IVDw2 = SDayC - move * x;
IVDw3 = SDayC - move * y;
IVDw4 = SDayC - move * z;
case "open":
IVUp1 = SDayC + move * v;
IVUp2 = SDayC + move * x;
IVUp3 = SDayC + move * y;
IVUp4 = SDayC + move * z;

IVDw1 = SDayC - move * v;
IVDw2 = SDayC - move * x;
IVDw3 = SDayC - move * y;
IVDw4 = SDayC - move * z;
case "both":

IVUp1 = (SDayC + SDayO) / 2 + move * v;
IVUp2 = (SDayC + SDayO) / 2 + move * x;
IVUp3 = (SDayC + SDayO) / 2 + move * y;
IVUp4 = (SDayC + SDayO) / 2 + move * z;

IVDw1 = (SDayC + SDayO) / 2 - move * v;
IVDw2 = (SDayC + SDayO) / 2 - move * x;
IVDw3 = (SDayC + SDayO) / 2 - move * y;
IVDw4 = (SDayC + SDayO) / 2 - move * z;
}


AddLabel(labels, "Today's IV: " + Round(impIV * 100, 2) + " Realize IV: " + Round(RIV * 100, 1) + " Move: $" + Round(move, 2) + " UpMove: $" + Round(IVUp1, 2) + " DwMove: $" + Round(IVDw1, 2), Color.LIME);
#AddCloud(if projected then upperbound else nan, up3, Color.DARK_RED, Color.PLUM);
#AddCloud(if projected then lowerbound else nan, dw3, Color.DARK_GREEN, Color.LIGHT_GREEN);

#def wmove = MovingAverage(wavg, moved, len);
#plot up11 = SDayO + wmove;
#plot dw11 = SDayO - wmove;

plot VolTrigger = (IVUp1 + IVDw1) / 2;
VolTrigger.SetDefaultColor(color.magenta);
VolTrigger.SetStyle(Curve.SHORT_DASH);# PaintingStrategy(PaintingStrategy.DASHES);

plot mu1 = if VolTrigger <> 0 then IVUp1 else nan;
plot mu2 = if projected then IVUp2 else nan;
plot mu3 = if projected then IVUp3 else nan;
plot mu4 = if projected then IVUp4 else nan;
mu1.SetPaintingStrategy(PaintingStrategy.DASHES);
mu2.SetPaintingStrategy(PaintingStrategy.DASHES);
mu3.SetPaintingStrategy(PaintingStrategy.DASHES);
mu4.SetPaintingStrategy(PaintingStrategy.DASHES);


plot md1 = if VolTrigger <> 0 then IVDw1 else nan;
plot md2 = if projected then IVDw2 else nan;
plot md3 = if projected then IVDw3 else nan;
plot md4 = if projected then IVDw4 else nan;
md1.SetPaintingStrategy(PaintingStrategy.DASHES);
md2.SetPaintingStrategy(PaintingStrategy.DASHES);
md3.SetPaintingStrategy(PaintingStrategy.DASHES);
md4.SetPaintingStrategy(PaintingStrategy.DASHES);

mu1.SetDefaultColor(color.light_GREEN);
mu2.SetDefaultColor(color.light_GREEN);
mu3.SetDefaultColor(color.light_GREEN);
mu4.SetDefaultColor(color.light_GREEN);
md1.SetDefaultColor(color.violet);
md2.SetDefaultColor(color.violet);
md3.SetDefaultColor(color.violet);
md4.SetDefaultColor(color.violet);

How is the VolTrigger used?
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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