• Get $40 off VIP by signing up for a free account! Sign Up

Trying to determine if an option is overvalued or undervalued.

ezrollin

Member
I'm trying to figure out if an option is overvalued or undervalued based on past prices and especially VS the stock's price.
I doubt I can add in a stocks price to a script that is used on an option chain screen.

So I'm just trying to start off looking at an average but I get errors like NaN.

Code:
def averagePrice = (close[5] + close[4] + close[3] + close[2] + close[1]) / 5.0;
plot data = averagePrice;

Is it factoring in weekend data so I need to check to make sure its NaN?
Thanks
 
I'm trying to figure out if an option is overvalued or undervalued based on past prices and especially VS the stock's price.
I doubt I can add in a stocks price to a script that is used on an option chain screen.

So I'm just trying to start off looking at an average but I get errors like NaN.

Code:
def averagePrice = (close[5] + close[4] + close[3] + close[2] + close[1]) / 5.0;
plot data = averagePrice;

Is it factoring in weekend data so I need to check to make sure its NaN?
Thanks

sorry, i don't have an answer.

there seems to be NAN errors for options data with volume errors or low numbers for open interest.

i tried a couple things , but wasn't able to trap and ignore the errors.
tested after market closed.

Code:
#cu10_test

# https://usethinkscript.com/threads/trying-to-determine-if-an-option-is-overvalued-or-undervalued.15847/
#Trying to determine if an option is overvalued or undervalued.
#ezrollin  Start dateToday at 7:23 AM

#I'm trying to figure out if an option is overvalued or undervalued based on past prices and especially VS the stock's price.
#I doubt I can add in a stocks price to a script that is used on an option chain screen.

#So I'm just trying to start off looking at an average but I get errors like NaN.


#def averagePrice = (close[5] + close[4] + close[3] + close[2] + close[1]) / 5.0;
#plot data = averagePrice;
#plot data = if isnan(averagePrice) then 0 else averagePrice;


# doesnt work.  plot still has NAN's
#def c1 = if isnan(close[1]) then 0 else close[1];
#def c2 = if isnan(close[2]) then 0 else close[2];
#def c3 = if isnan(close[3]) then 0 else close[3];
#def c4 = if isnan(close[4]) then 0 else close[4];
#def c5 = if isnan(close[5]) then 0 else close[5];

# doesnt work.  plot still has NAN's
def c1 = if isnan(volume[1]) then 0 else close[1];
def c2 = if isnan(volume[2]) then 0 else close[2];
def c3 = if isnan(volume[3]) then 0 else close[3];
def c4 = if isnan(volume[4]) then 0 else close[4];
def c5 = if isnan(volume[5]) then 0 else close[5];

def averagePrice = (c1 + c2 + c3 + c4 + c5) / 5;
plot data = averagePrice;
#

stock: AXP
X0Nc0Fp.jpg
 

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

sorry, i don't have an answer.

there seems to be NAN errors for options data with volume errors or low numbers for open interest.

i tried a couple things , but wasn't able to trap and ignore the errors.
tested after market closed.

Code:
#cu10_test

# https://usethinkscript.com/threads/trying-to-determine-if-an-option-is-overvalued-or-undervalued.15847/
#Trying to determine if an option is overvalued or undervalued.
#ezrollin  Start dateToday at 7:23 AM

#I'm trying to figure out if an option is overvalued or undervalued based on past prices and especially VS the stock's price.
#I doubt I can add in a stocks price to a script that is used on an option chain screen.

#So I'm just trying to start off looking at an average but I get errors like NaN.


#def averagePrice = (close[5] + close[4] + close[3] + close[2] + close[1]) / 5.0;
#plot data = averagePrice;
#plot data = if isnan(averagePrice) then 0 else averagePrice;


# doesnt work.  plot still has NAN's
#def c1 = if isnan(close[1]) then 0 else close[1];
#def c2 = if isnan(close[2]) then 0 else close[2];
#def c3 = if isnan(close[3]) then 0 else close[3];
#def c4 = if isnan(close[4]) then 0 else close[4];
#def c5 = if isnan(close[5]) then 0 else close[5];

# doesnt work.  plot still has NAN's
def c1 = if isnan(volume[1]) then 0 else close[1];
def c2 = if isnan(volume[2]) then 0 else close[2];
def c3 = if isnan(volume[3]) then 0 else close[3];
def c4 = if isnan(volume[4]) then 0 else close[4];
def c5 = if isnan(volume[5]) then 0 else close[5];

def averagePrice = (c1 + c2 + c3 + c4 + c5) / 5;
plot data = averagePrice;
#

stock: AXP
X0Nc0Fp.jpg
If you're seeing some columns with numbers and others with "NaN," it means that there are some periods within the lookback window where the data is missing or not available.

The "NaN" values occur when there is no valid data for a particular bar within the lookback window (in this case, the past five bars). This can happen if there was a gap in the data or if the data is simply not available for those periods.
 
If you're seeing some columns with numbers and others with "NaN," it means that there are some periods within the lookback window where the data is missing or not available.

The "NaN" values occur when there is no valid data for a particular bar within the lookback window (in this case, the past five bars). This can happen if there was a gap in the data or if the data is simply not available for those periods.

i know that. that is why i tried trapping for errors with isnan( )
 
@ezrollin if you are still looking...a couple of scripts in this link from shortthestrike should help.

Option Percent Change (http://tos.mx/PqPUFwW) can be changed to 5 days
Ruby:
def condition =(close - close[3])/close[3];
AddLabel(condition,Round(condition*100,0)+"%",if condition >= 0.5 then color.green else if condition <= -0.5 then color.red else color.white);

My guess is the Premium Percent of Underlying (http://tos.mx/6c3ceCk) script can probably be incorporated into the Option Percent Change script to accomplish what you are looking for.
Ruby:
def condition = ((close/close(getUnderlyingSymbol())));
#plot condition = if signal <= 0.04 then 1 else 0;

#def condition =(close - close[1])/close[1];
AddLabel(condition,Round(condition*100,0)+"%",if condition >= 0.5 then color.green else if condition <= -0.5 then color.red else color.white);
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
285 Online
Create Post

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