Calculate expected move

indiciatorhead

New member
# Define input parameters
input period = "Daily";
input expiration = 1;

# Calculate implied volatility
def vol = ImpVolatility(period, expiration);

# Calculate expected move
def price = close;
def move = price * vol;

# Plot expected move
plot expectedMove = move;
expectedMove.SetDefaultColor(GetColor(7));
expectedMove.SetLineWeight(2);

# Add labels and formatting
AddLabel(yes, Concat("Expected Move: ", move), color = GetColor(7));
AddVerticalLine(Expiration(), color = GetColor(7), style = Curve.SHORT_DASH);
 
Solution
# Define input parameters
input period = "Daily";
input expiration = 1;

# Calculate implied volatility
def vol = ImpVolatility(period, expiration);

# Calculate expected move
def price = close;
def move = price * vol;

# Plot expected move
plot expectedMove = move;
expectedMove.SetDefaultColor(GetColor(7));
expectedMove.SetLineWeight(2);

# Add labels and formatting
AddLabel(yes, Concat("Expected Move: ", move), color = GetColor(7));
AddVerticalLine(Expiration(), color = GetColor(7), style = Curve.SHORT_DASH);


there are several things wrong.
i think the main thing is, you are not looking up the functions, so you don't know what are valid parameters for them.

i changed some things and have it plotting a line. not sure if it...
# Define input parameters
input period = "Daily";
input expiration = 1;

# Calculate implied volatility
def vol = ImpVolatility(period, expiration);

# Calculate expected move
def price = close;
def move = price * vol;

# Plot expected move
plot expectedMove = move;
expectedMove.SetDefaultColor(GetColor(7));
expectedMove.SetLineWeight(2);

# Add labels and formatting
AddLabel(yes, Concat("Expected Move: ", move), color = GetColor(7));
AddVerticalLine(Expiration(), color = GetColor(7), style = Curve.SHORT_DASH);


there are several things wrong.
i think the main thing is, you are not looking up the functions, so you don't know what are valid parameters for them.

i changed some things and have it plotting a line. not sure if it is what you expected.
added notes in the code to describe what is going on


valid agg period names
https://tlc.thinkorswim.com/center/reference/thinkScript/Constants/AggregationPeriod

imp_volatility ( symbol, period, priceType);
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Fundamentals/imp-volatility

AddVerticalLine ( visible, text, color, stroke);
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/AddVerticalLine



Code:
# expect_move_fix_00

#https://usethinkscript.com/threads/can-someone-please-help-correct-this-thanks.13742/
#can someone please help correct this? thanks
# indiciatorhead  12/17


# added this , to plot on a lower chart
declare lower;


# Define input parameters

# this is wrong. daily is not a valid period name
#input period = "Daily";
input period = "Day";
input expiration = 1;



# Calculate implied volatility
# wrong, ImpVolatility(p)   is a study, that has no parameters
#def vol = ImpVolatility(period, expiration);

# Imp_Volatility()  is a function that has 3 parameters.
# imp_volatility ( symbol, period, priceType )
# but expiration is not a parameter
def vol = Imp_Volatility(period = period);


# Calculate expected move
def price = close;
def move = price * vol;

# Plot expected move
plot expectedMove = move;
expectedMove.SetDefaultColor(GetColor(7));
expectedMove.SetLineWeight(2);

# Add labels and formatting
AddLabel(yes, Concat("Expected Move: ", move), color = GetColor(7));



# wrong , expiration isn't a function, so can't be used as the visible parameter
# there isn't any dates , so don't know where an expiration comes from
# there is no text defined
# not sure when this is to be drawn
# AddVerticalLine(Expiration(), color = GetColor(7), style = Curve.SHORT_DASH);


# ----------------------------------
# test stuff

#plot z = 0;

input show_bubbles = no;
addchartbubble(show_bubbles, move*0.999 ,
vol + " vol\n" +
move + " mov"
, color.yellow, no);

#

these might help give you some ideas

try loading this study
https://tlc.thinkorswim.com/center/...studies-library/O-Q/ProbabilityOfExpiringCone

take a look at this one
https://usethinkscript.com/threads/expected-move-probability-cone-for-thinkorswim.10891/#post-98640
 
Solution
there are several things wrong.
i think the main thing is, you are not looking up the functions, so you don't know what are valid parameters for them.

i changed some things and have it plotting a line. not sure if it is what you expected.
added notes in the code to describe what is going on


valid agg period names
https://tlc.thinkorswim.com/center/reference/thinkScript/Constants/AggregationPeriod

imp_volatility ( symbol, period, priceType);
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Fundamentals/imp-volatility

AddVerticalLine ( visible, text, color, stroke);
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/AddVerticalLine



Code:
# expect_move_fix_00

#https://usethinkscript.com/threads/can-someone-please-help-correct-this-thanks.13742/
#can someone please help correct this? thanks
# indiciatorhead  12/17


# added this , to plot on a lower chart
declare lower;


# Define input parameters

# this is wrong. daily is not a valid period name
#input period = "Daily";
input period = "Day";
input expiration = 1;



# Calculate implied volatility
# wrong, ImpVolatility(p)   is a study, that has no parameters
#def vol = ImpVolatility(period, expiration);

# Imp_Volatility()  is a function that has 3 parameters.
# imp_volatility ( symbol, period, priceType )
# but expiration is not a parameter
def vol = Imp_Volatility(period = period);


# Calculate expected move
def price = close;
def move = price * vol;

# Plot expected move
plot expectedMove = move;
expectedMove.SetDefaultColor(GetColor(7));
expectedMove.SetLineWeight(2);

# Add labels and formatting
AddLabel(yes, Concat("Expected Move: ", move), color = GetColor(7));



# wrong , expiration isn't a function, so can't be used as the visible parameter
# there isn't any dates , so don't know where an expiration comes from
# there is no text defined
# not sure when this is to be drawn
# AddVerticalLine(Expiration(), color = GetColor(7), style = Curve.SHORT_DASH);


# ----------------------------------
# test stuff

#plot z = 0;

input show_bubbles = no;
addchartbubble(show_bubbles, move*0.999 ,
vol + " vol\n" +
move + " mov"
, color.yellow, no);

#

these might help give you some ideas

try loading this study
https://tlc.thinkorswim.com/center/...studies-library/O-Q/ProbabilityOfExpiringCone

take a look at this one
https://usethinkscript.com/threads/expected-move-probability-cone-for-thinkorswim.10891/#post-98640
Can this be an upper chart plotting arrows at the peak levels calculated by x number of bars ago or by x number minutes, hours, days, etc ago?
 

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