Sigma Expected Movement For ThinkOrSwim

Author states:
Based on the VIX, this indicator shows the expected movement of a stock, ETF or index.
This indicator has two standard deviations that you can set for better guidance.
You can also adjust it for a result in one day, one week or one month.
R4Gvj1D.png


Hey @samer800 Looking for some assistance with converting this https://www.tradingview.com/script/5bmBkxJO-Sigma-Expected-Movement-D-W-M/
currently I have to manually input the levels which is time consuming. I have created one for /NQ, /ES, SPX, QQQ, IWM and AAPL. here is my SPY TOS version: http://tos.mx/zYfS7Gp Any assistance would be greatly appreciated.

1707459207947.png
 

Attachments

  • 1707459056827.png
    1707459056827.png
    581 KB · Views: 386
Last edited by a moderator:
Hey @samer800 Looking for some assistance with converting this https://www.tradingview.com/script/5bmBkxJO-Sigma-Expected-Movement-D-W-M/
currently I have to manually input the levels which is time consuming. I have created one for /NQ, /ES, SPX, QQQ, IWM and AAPL. here is my SPY TOS version: http://tos.mx/zYfS7Gp Any assistance would be greatly appreciated.

View attachment 20979
check the below
CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © seba34e
#indicator("Sigma Expected Movement [D/W/M]", overlay=true)
# Converted by Sam4Cok@Samer800    - 02/2024
input showTabel = yes;
input showLabel = yes;
input extendLeft = 10;
input extendRight = 2;
input symbol = "VIX";
input period = {default "DAY", "WEEK", "MONTH"}; # title="Period", options =
input FirstDeviation = 68; #, title = "First Deviation (%)")
input SecondDeviation = 90; #, title = "Second Deviation (%)")
input RoundToInteger = no; #(false, title = "Round to Integer", inline = "Round")
input Round = 5; #, title="", inline = "Round")


def na = Double.NaN;
def last = isNaN(close);
def n =  BarNumber();
def bar = if !last then n else bar[1];
def right = n == highestAll(bar + extendRight);
def left = n == highestAll(bar - extendLeft);

def operableDays; # = 0
switch (period) {
case "WEEK" :
    operableDays = 52;
case "MONTH" :
    operableDays = 12;
default :
    operableDays = 252;
}
def tickerid = close(Period = "Day")[1];
def vixID =  close(Symbol = symbol);
#//Geting data
def previousClose = if !isNaN(tickerid) then tickerid else previousClose[1];
def vixClose = if !isNaN(vixID) then vixID else vixClose[1];

def raizCuadrada = Sqrt(operableDays);
def d = vixClose / raizCuadrada;
def ME = previousClose * (d / 100);
def pME_sup = previousClose + ME;
def pME_inf = previousClose - ME;
def ME_inv = previousClose;
def pRangoUp1   = ME_inv + ((pME_sup - ME_inv) * (FirstDeviation / 100));
def pRangoDn1 = ME_inv + ((ME_inv - pME_sup) * (FirstDeviation / 100));
def pRangoUp2 =   ME_inv + ((pME_sup - ME_inv) * (SecondDeviation / 100));
def pRangoDn2 = ME_inv + ((ME_inv - pME_sup) * (SecondDeviation / 100));

Script RoundIT {
input RoundToInteger = no;
input value = close;
input round = 5;
    def yy1 = value % Round;
    def me = if RoundToInteger then
             if yy1 > round / 2 then value + (Round - yy1) else Value - yy1 else value;
    plot out = me;
}

def ME_sup = RoundIT(RoundToInteger, pME_sup, round);
def ME_inf = RoundIT(RoundToInteger, pME_inf, round);
def RangoUp1 = RoundIT(RoundToInteger, pRangoUp1, round);
def RangoDn1 = RoundIT(RoundToInteger, pRangoDn1, round);
def RangoUp2 = RoundIT(RoundToInteger, pRangoUp2, round);
def RangoDn2 = RoundIT(RoundToInteger, pRangoDn2, round);

plot line_inf = if left then ME_inf else
                if right then ME_inf[extendRight] else na;
plot line_sup = if right then ME_sup[extendRight] else
                if left then ME_sup else na;

plot line_inf1 = if right then RangoDn1[extendRight] else
                 if left then RangoDn1 else na;
plot line_sup1 = if right then RangoUp1[extendRight] else
                 if left then RangoUp1 else na;

plot line_inf2 = if right then RangoDn2[extendRight] else
                 if left then RangoDn2 else na;
plot line_sup2 = if right then RangoUp2[extendRight] else
                 if left then RangoUp2 else na;

plot line_previousClose = if right then previousClose[extendRight] else
                          if left then previousClose else na;

line_inf1.SetStyle(Curve.SHORT_DASH);
line_sup1.SetStyle(Curve.SHORT_DASH);
line_inf2.SetStyle(Curve.MEDIUM_DASH);
line_sup2.SetStyle(Curve.MEDIUM_DASH);
line_inf.SetDefaultColor(Color.MAGENTA);
line_sup.SetDefaultColor(Color.MAGENTA);
line_inf1.SetDefaultColor(Color.YELLOW);
line_sup1.SetDefaultColor(Color.YELLOW);
line_inf2.SetDefaultColor(Color.CYAN);
line_sup2.SetDefaultColor(Color.CYAN);
line_inf.EnableApproximation();
line_sup.EnableApproximation();
line_inf1.EnableApproximation();
line_sup1.EnableApproximation();
line_inf2.EnableApproximation();
line_sup2.EnableApproximation();
line_previousClose.EnableApproximation();

#-- Labels
def meRound = Round(ME, 2);
def supRound = Round(ME_sup, 2);
def infRound = Round(ME_inf, 2);
def vixRound = Round(vixClose, 2);
def cloRound = Round(previousClose, 2);

AddLabel(showTabel, "Period:(" + period + ")", Color.WHITE);
AddLabel(showTabel, "EM:(±" + meRound + ")", Color.YELLOW);
AddLabel(showTabel, "Expected Movement Up:($" + supRound + ")", Color.GREEN);
AddLabel(showTabel, "Expected Movement DOWN:($" + infRound + ")", Color.RED);
AddLabel(showTabel, "VIX:($" + vixRound + ")", Color.WHITE);
AddLabel(showTabel, "Previous Close:($" + cloRound + ")", Color.WHITE);

AddChartBubble(showLabel and left, line_inf, Round(line_inf, 2), Color.MAGENTA, no);
AddChartBubble(showLabel and left, line_sup, Round(line_sup, 2), Color.MAGENTA);
AddChartBubble(showLabel and left, line_inf1, Round(line_inf1, 2), Color.YELLOW, no);
AddChartBubble(showLabel and left, line_sup1, Round(line_sup1, 2), Color.YELLOW);
AddChartBubble(showLabel and left, line_inf2, Round(line_inf2, 2), Color.CYAN, no);
AddChartBubble(showLabel and left, line_sup2, Round(line_sup2, 2), Color.CYAN);
AddChartBubble(showLabel and left, line_previousClose, Round(line_previousClose, 2), Color.GRAY);

#-- END Of CODE
 
@samer800 , This is a very interesting study. Thanks for taking the time to convert it. Could you possibly add some lower time frames to the script? Say like a 15 min, 30 min, and 60 min. I am hoping that these lower time frames will make the study more useful for scalping.
 
check the below
CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © seba34e
#indicator("Sigma Expected Movement [D/W/M]", overlay=true)
# Converted by Sam4Cok@Samer800    - 02/2024
input showTabel = yes;
input showLabel = yes;
input extendLeft = 10;
input extendRight = 2;
input symbol = "VIX";
input period = {default "DAY", "WEEK", "MONTH"}; # title="Period", options =
input FirstDeviation = 68; #, title = "First Deviation (%)")
input SecondDeviation = 90; #, title = "Second Deviation (%)")
input RoundToInteger = no; #(false, title = "Round to Integer", inline = "Round")
input Round = 5; #, title="", inline = "Round")


def na = Double.NaN;
def last = isNaN(close);
def n =  BarNumber();
def bar = if !last then n else bar[1];
def right = n == highestAll(bar + extendRight);
def left = n == highestAll(bar - extendLeft);

def operableDays; # = 0
switch (period) {
case "WEEK" :
    operableDays = 52;
case "MONTH" :
    operableDays = 12;
default :
    operableDays = 252;
}
def tickerid = close(Period = "Day")[1];
def vixID =  close(Symbol = symbol);
#//Geting data
def previousClose = if !isNaN(tickerid) then tickerid else previousClose[1];
def vixClose = if !isNaN(vixID) then vixID else vixClose[1];

def raizCuadrada = Sqrt(operableDays);
def d = vixClose / raizCuadrada;
def ME = previousClose * (d / 100);
def pME_sup = previousClose + ME;
def pME_inf = previousClose - ME;
def ME_inv = previousClose;
def pRangoUp1   = ME_inv + ((pME_sup - ME_inv) * (FirstDeviation / 100));
def pRangoDn1 = ME_inv + ((ME_inv - pME_sup) * (FirstDeviation / 100));
def pRangoUp2 =   ME_inv + ((pME_sup - ME_inv) * (SecondDeviation / 100));
def pRangoDn2 = ME_inv + ((ME_inv - pME_sup) * (SecondDeviation / 100));

Script RoundIT {
input RoundToInteger = no;
input value = close;
input round = 5;
    def yy1 = value % Round;
    def me = if RoundToInteger then
             if yy1 > round / 2 then value + (Round - yy1) else Value - yy1 else value;
    plot out = me;
}

def ME_sup = RoundIT(RoundToInteger, pME_sup, round);
def ME_inf = RoundIT(RoundToInteger, pME_inf, round);
def RangoUp1 = RoundIT(RoundToInteger, pRangoUp1, round);
def RangoDn1 = RoundIT(RoundToInteger, pRangoDn1, round);
def RangoUp2 = RoundIT(RoundToInteger, pRangoUp2, round);
def RangoDn2 = RoundIT(RoundToInteger, pRangoDn2, round);

plot line_inf = if left then ME_inf else
                if right then ME_inf[extendRight] else na;
plot line_sup = if right then ME_sup[extendRight] else
                if left then ME_sup else na;

plot line_inf1 = if right then RangoDn1[extendRight] else
                 if left then RangoDn1 else na;
plot line_sup1 = if right then RangoUp1[extendRight] else
                 if left then RangoUp1 else na;

plot line_inf2 = if right then RangoDn2[extendRight] else
                 if left then RangoDn2 else na;
plot line_sup2 = if right then RangoUp2[extendRight] else
                 if left then RangoUp2 else na;

plot line_previousClose = if right then previousClose[extendRight] else
                          if left then previousClose else na;

line_inf1.SetStyle(Curve.SHORT_DASH);
line_sup1.SetStyle(Curve.SHORT_DASH);
line_inf2.SetStyle(Curve.MEDIUM_DASH);
line_sup2.SetStyle(Curve.MEDIUM_DASH);
line_inf.SetDefaultColor(Color.MAGENTA);
line_sup.SetDefaultColor(Color.MAGENTA);
line_inf1.SetDefaultColor(Color.YELLOW);
line_sup1.SetDefaultColor(Color.YELLOW);
line_inf2.SetDefaultColor(Color.CYAN);
line_sup2.SetDefaultColor(Color.CYAN);
line_inf.EnableApproximation();
line_sup.EnableApproximation();
line_inf1.EnableApproximation();
line_sup1.EnableApproximation();
line_inf2.EnableApproximation();
line_sup2.EnableApproximation();
line_previousClose.EnableApproximation();

#-- Labels
def meRound = Round(ME, 2);
def supRound = Round(ME_sup, 2);
def infRound = Round(ME_inf, 2);
def vixRound = Round(vixClose, 2);
def cloRound = Round(previousClose, 2);

AddLabel(showTabel, "Period:(" + period + ")", Color.WHITE);
AddLabel(showTabel, "EM:(±" + meRound + ")", Color.YELLOW);
AddLabel(showTabel, "Expected Movement Up:($" + supRound + ")", Color.GREEN);
AddLabel(showTabel, "Expected Movement DOWN:($" + infRound + ")", Color.RED);
AddLabel(showTabel, "VIX:($" + vixRound + ")", Color.WHITE);
AddLabel(showTabel, "Previous Close:($" + cloRound + ")", Color.WHITE);

AddChartBubble(showLabel and left, line_inf, Round(line_inf, 2), Color.MAGENTA, no);
AddChartBubble(showLabel and left, line_sup, Round(line_sup, 2), Color.MAGENTA);
AddChartBubble(showLabel and left, line_inf1, Round(line_inf1, 2), Color.YELLOW, no);
AddChartBubble(showLabel and left, line_sup1, Round(line_sup1, 2), Color.YELLOW);
AddChartBubble(showLabel and left, line_inf2, Round(line_inf2, 2), Color.CYAN, no);
AddChartBubble(showLabel and left, line_sup2, Round(line_sup2, 2), Color.CYAN);
AddChartBubble(showLabel and left, line_previousClose, Round(line_previousClose, 2), Color.GRAY);

#-- END Of CODE
Is there a way to manually select the VIX ? I am looking to see if I can use this on non US exchanges....
 

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
350 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