Option Chain Column For ThinkOrSwim

HumbledTrader

New member
@rad14733 what your looking at is it, and yes you can do a custom column by editing the script in the custom extras custom 1-whatever amount they give you, in fact, what your looking at is real it is not mine to give as i need permission, but it slows the system and i have a decent computer i beleive

Yes Please if you can help?
 
here is an updated column study for the option chain. it checks if the option is a call or a put


Ruby:
# intextratio02

# option chain column study
#  Intrinsic/Extrinsic ratio

def stkcls = close(GetUnderlyingSymbol());
def strik = getstrike();

def intrin = if (!isput() and stkcls > strik) then round(stkcls - strik, 2)
 else if (isput() and stkcls < strik) then round(strik - stkcls, 2)
 else 0;

#extrinsic value
#time value = option price - Intrinsic value
def optprice = OptionPrice();

def extrin = round(optprice - intrin, 2);
def intextratio2 = round(intrin/extrin, 2);


# this shows just the ratio number
# to use this, remove # in front of plot, and add a # in front of the addlabel
#plot intextratio = intextratio2;

# test line to show several variables
addlabel(1, intrin + " / " + extrin + " = " + intextratio2, color.white);
#

this shows 3 values in the column. Intrinsic, Extrinsic, and the ratio
BoUJ6cp.jpg

#
@halcyonguy Thanks for the script. I am learning options and primary sell puts or covered calls for premiums. May I know how can I apply this ratio to help me with my options strategy? Thank u
 
@halcyonguy Thanks for the script. I am learning options and primary sell puts or covered calls for premiums. May I know how can I apply this ratio to help me with my options strategy? Thank u
i have no idea. you would have to reply to post #1, the original poster, @jdn717, and him how he intends to use the data. i'm just a guy who is trying to help people with their thinkscript requests.
 
Last edited:
Hello to all. I am trying to add a break even column into my options chart. The column will calculate the breakeven point for each option. My formula is not working because the price for the underlying stock is not what is being returned by "close". The close returns the price of the option for that row. Below as you can see on line 3 I entered the stock manually. This works for that stock. I need it to be more dynamic it needs to get the value from whats entered in the search box makes no sense to have to change the script every time I change stock symbol. The code below will display the underlying stock value now just to see if price value is correct. Once I confirm that i can move on.


Code:
def strikeprice = GetStrike();
def price = close("LW"); #issue here need to be value entered into search box
def premium = bid + (ask-bid)/2 ;

def totalprice = strikeprice + premium;
def totalpriceP = ((totalprice - price)/ price )* 100;

plot value = if isNaN(price) then 0.00 else price;
 
this isn't a scan, but i have this code in a column, in the option chain, to display the bid ask spread as a % number, and show different colors depending on which range it is in.

Code:
# add to a custom column in the option chain
# this code calcs a  bid/ask spread ratio to ask   (ask-bid)/ask
#  if % is 0  to 10 then gray background
#  if % is 10 to 20 then blue
#  if % is  > 20 then red

def lvl1 = 10;
def lvl2 = 20;
def per = Round("number" = ((ask - bid ) / ask) * 100, "numberOfDigits" = 0);
assignbackgroundColor( if per > lvl2 then color.red  else if per > lvl1 then color.blue else color.dark_gray );
plot ppp = per;

TD ameritrade
Watch "Customizing the Option Chain" on YouTube
Was hoping to try this out but it's showing Bid/Ask are highlighted in red and getting error no such variable.
 
Hi, i copied the script and paste into the custom code in the options chain, but it is showing NaN in the column. Not sure if I miss any step...

thanks
 
Try: ((close(priceType = "ask") - close(priceType = "bid")) / close(priceType = "ask")) in place of (ask - bid) / ask...

Edited to add: Nope... I've tried a few different things and would need to dig deeper...
 
Last edited:
it might be because it's after hours. it works for me during the day

Odd... Your code isn't throwing a code today but it was yesterday and the last time I had tried it... It does throw a NaN if you with extended hours disabled but works as expected with extended hours enabled... I have my custom column set to 1m timeframe...
 
Odd... Your code isn't throwing a code today but it was yesterday and the last time I had tried it... It does throw a NaN if you with extended hours disabled but works as expected with extended hours enabled... I have my custom column set to 1m timeframe...
sorry, i should have said, it worked the last time i looked at it.
i can look into it tonight and tomorrow.
 
Hi, i copied the script and paste into the custom code in the options chain, but it is showing NaN in the column. Not sure if I miss any step...

thanks

at 10pm ,
i compared the code in post #2 to what i have in my column. it is the same , except i now have round( , 1) , not ( , 0) .

i looked at a few option chains. it seems to be working.
when ALL strikes is selected, it takes my computer 8 seconds to load the column. ( i have an i7 , 16gb ram, cat5 wired)
it seems that if open interest is 0, it may show NaN or loading in the column.

3Y3L06n.jpg
 
I am trying to create a custom column in the Options Chain. I have everything working right except the reference to the option's "days until expiration"

Is there a proper way to refer to that?

For some reason my code will pull up numbers but not the days till expiration. I'm not sure where those numbers are coming from.

I think I'm close (and it's probably really obvious) but I can't figure it out for some reason.

Here is my test code:

Code:
def Days = GetDaysToExpiration ();
AddLabel (Yes, Days);

With this test code when I look up SPX options with 2 days to Expiration the cell says 3 or a bunch of random numbers lower on the options chain.
 
Is there a line of code that will let me add a custom column to only one side of the options chain rather than having it appear on both the Calls and Puts sides? Thanks , Steve
 
So this code tells me change in open interest but is there a way to know how many contracts(open interest) were closed?

Todays Open interest represents OI=OI[1]+volume[1]-closedOI

So is there a way to take yesterdays open interest at the beginning of the day and subtract that from end of the day open interest?
so OIchange=OI[start of day]-OI[end of day]

@HumbledTrader @XeoNoX It will help find out if the Market Makers are closing their bearish or bullish sentiment of the underlying since most contracts are written by market makers who have more intel than the average trader.
i export all this data into XLS & then run the formula to filter & see the % of increase by doing New OI - Old OI / Old OI, if its more than 90% trade. But seen most scenario no matter about this % if the stock trend is positive even if out put is 60% stock runs heavy. But winning rate is 80% based on this tracking via XLS.
 
hi @halcyonguy @rad14733, is there a scan/codes for scanning tickers with low option spread? I'm only interested in buying options with low spread. thanks!

i'm not sure, i don't scan. i look at a short list of sp100 stocks.
maybe putting this into the option hacker will work.
manually edit the code , change 2.0 to other #'s, for different %'s.

Code:
# scan for spreads < x% . drfault 2%
def spread_percent = 2.0;
def per = Round( ((ask - bid ) / ask) * 100,  0.1);
plot z = ( per <= spread_percent);

i'm not sure if bid and ask will work as is in a scan, or if pricetype will need to be used.

def BidPrice = close( priceType = PriceType.BID );

https://tlc.thinkorswim.com/center/reference/thinkScript/Constants/PriceType/PriceType-BID
 

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