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?
 

Shaco

New member
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
Thank you @halcyonguy. I've modified your codes and scan against my personal short list of stock, but get no result probably due to during after market hour. Will try tomorrow during market hour and see if this works.
Code:
# scan for spreads < x% . default 2%
def spread_percent = 2.0;
def BidPrice = close( priceType = PriceType.BID );
def AskPrice = close( priceType = PriceType.ask );
def per = Round( ((AskPrice - BidPrice ) / AskPrice) * 100,  0.1);
plot z = ( per <= spread_percent);
 
Last edited:

halcyonguy

Well-known member
VIP
Lifetime
Thank you @halcyonguy. I've modified your codes and scan against my personal short list of stock, but get no result probably due to during after market hour. Will try tomorrow during market hour and see if this works.
Code:
# scan for spreads < x% . default 2%
def spread_percent = 2.0;
def BidPrice = close( priceType = PriceType.BID );
def AskPrice = close( priceType = PriceType.BID );
def per = Round( ((AskPrice - BidPrice ) / AskPrice) * 100,  0.1);
plot z = ( per <= spread_percent);

look at this and see if it helps. it plots horizontal lines for bid and ask.
https://usethinkscript.com/threads/bid-ask-spread-lines-indicator-for-thinkorswim.1140/#post-8460
 

TOSTrader2020

New member
VIP
For my education, does the below code gives me trading previous day OI?
plot OI_NetChg = open_interest() - open_interest()[1];

and the below code gives me 2 trading days ago OI ?
plot OI_NetChg = open_interest() - open_interest()[2];

Thanks in advance.
 

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
Hi MerryDay, I put this piece of code "getdaystoexpiration()-1" in my watchlist column, I get this from the TOS platform but in the watchlist show's me a .0 after the day numbers. Is there a way to hide the .0 by code?
Scan and Watchlist Requests:
If you provide the watchlist code, there "may" be a way to hide the .0 lines. However, it "may" mess up your sorting capabilities.
 

erginvesting

New member
Is there a way to add a 'Mark Change" and Mark % Change" column in the option chain? These items are not in the list of available column headings. I saw this in a video where the person was using E-Trade.
 

Witstock

New member
Hi. I have no clue how to write a thinkscript yet but would like to contribute eventually so my apologies if I'm leeching:

  1. Question: Is there a way to add a custom column which shows the exact Bid/Ask difference (perhaps averaged out over X milliseconds so it's not seizure-inducing)?
  2. Bonus question: can the largest difference be highlighted somehow?
  3. Extra Bonus Question: Don't know what N/A means (not applicable or Not/Available I assume) and is there a way to red those out if I can't trade them?

I'm daytrading options and I have several weeklies open, quickly trying to scan the biggest differences in a 14 period on both calls and puts, between the bids and asks in order to quickly maximize the gains but I can't figure a simple way to accomplish this. I have Net Change up but it's not reflecting the prices accurately/fast enough (if that's what that is even supposed to do.)

I just want to quickly VISUALLY identify best Call and Put entries while up on the screen as I tend to have squirrel/ADHD moments and there's a heck of a lot going on.

Thanks!
 

Witstock

New member
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;
Hey Halyconguy Thank you for your work on these scripts.
I tried adding this to my options Chain trade window, both calls and puts weeklies etc. I'm testing it right now on OnDemand before market opens.
All this shows is "loading" in the columns.
Is this where I'd normally add/see this code? Is it only working during trading hours?

I'm trying to find a way to show options bid-ask spread in my options chain (percentage could work too) and have it color coded depending on how far apart the bid-ask spread size is so I can quickly make a selection to buy a call or a put. It would be a bigger bonus to avoid any strike prices that have o or N/A volume and a range of Open Interest (ie. dont color code OI with 0-1.) Is this possible? Thanks!
 

Witstock

New member
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
Update @Halyconguy:
I have this working now. I restarted my TOS platform and it's active at least on the live side in PM.
I haven't tested to see if it works when using OnDemand but will do so shortly.
Thanks again for all you've contributed to this site and for the benefit of others. I really appreciate it.

I have a few questions/requests:
1. How would I make it so that the narrowest bid/ask spread is green? (I was able to make other values green but not highlight the best selection)
2. Is there a way to color code (only during active trading hours) calls and puts that have ZERO volume as maybe a dark red? In PM/AH there's zero volume so it would conflict with the other colors visibility.
3. Any way to hide colors for all options strikes that are OTM?
 
Last edited:

Witstock

New member
@Halyconguy: FYI the color coding for bid-ask spreading doesn't work when backtesting using the TOS OnDemand feature unfortunately. It just shows loading and I don't know why that might even be.
 

halcyonguy

Well-known member
VIP
Lifetime
@Halyconguy: FYI the color coding for bid-ask spreading doesn't work when backtesting using the TOS OnDemand feature unfortunately. It just shows loading and I don't know why that might even be.
thanks for checking. i never use ondemand.
i don't have any quick answers to your previous post. will think about them.
 

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
@Halyconguy: FYI the color coding for bid-ask spreading doesn't work when backtesting using the TOS OnDemand feature unfortunately. It just shows loading and I don't know why that might even be.
Unfortunately, this does not seem to be available with the TOS OnDemand feature.
 

Witstock

New member
Heres one i use for V:OI. It blacks out the (in my opinion ) irrelevant data.

Code:
#Column for Volume to OI (open interest)
def x = (volume / open_interest)*100;
AddLabel(yes,  + Round(x , 0) + "%",color.black);
assignBackgroundColor (if  x > 150 and volume is greater than 100 then color.orange else if x > 75 and volume is greater than 90 then color.LIGHT_GRAY else  if x >= 0 then color.black else color.black);
Hi. What exactly is determined by looking at this and how could it be used? I've been trying to wrap my brain around this but I have some learning disabilities. I understand OI and Volume - is this "telling" someone that volume is picking up or decreasing from the previous day's OI (as OI is always calculated from the previous day) and that people are accumulating positions at a certain strike? Is the % increase or decrease a good thing or bad thing (generally speaking - not investment advice of course)? Thanks!
 

halcyonguy

Well-known member
VIP
Lifetime
For my education, does the below code gives me trading previous day OI?
plot OI_NetChg = open_interest() - open_interest()[1];

and the below code gives me 2 trading days ago OI ?
plot OI_NetChg = open_interest() - open_interest()[2];

Thanks in advance.
no. subtracting one from another would give you the difference between those 2 values.

use an offset of 1 , [1] , will read a value from a variable, from 1 bar earlier.
this will read open interest from the previous bar.
def x = open_interest()[1];

this will read a value from 2 bars earlier.
def y = open_interest()[2];

https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Fundamentals/open-interest
 
Was hoping to try this out but it's showing Bid/Ask are highlighted in red and getting error no such variable.
this is a awesome idea, for me though the % amount on a spread becomes to wide to trade on some of the higher prices even at 10%, is it possible to convert this over in so it can give in .$ about meaning most of spreads i look for are .50 or less

im just looking for the option column to show the spread in Penny or Dollar amount, the percentage amount of the spreads are sometimes way to wide as you get into higher bid n ask prices
 
Last edited by a moderator:
You are asking how to subtract ask from bid?
plot spread = ask - bid ;
I been playing with the Spread code a bit im stuck on line3 and line 4 anyone can figure out what im doing wrong here? Also tryng to ge tthe digits to show as .40, .50 or 1.25 etc... where it is showing 0.4 0.5 etc... and its not turning red above .50 everything id green

Code:
plot spread = ask - bid ;
def Penny = .50;
def Penny = .51;
def Penny = Round("number" = ((ask - bid ) / ask) * 100, "numberOfDigits" = 3);
assignbackgroundColor( if .50 > Penny then color.red  else if .50 < Penny then color.Dark_Gray else color.dark_green );
 

Similar threads

Top