Options Vol/Open Interest For ThinkOrSwim

I'm trying to run this script but it doesn't appear to be working. I can't seem to find anything on web or in the manual that would indicate there is incorect code. I'm getting NO errors also. I'm also folowing the exact example in the manual.

input ticker = "SPY";
input expirationDate = 20200417;

plot data = close(GetNextITMOption(GetATMOption(ticker, expirationDate, OptionClass.CALL))) + close(GetNextOTMOption(GetATMOption(ticker, expirationDate, OptionClass.CALL)));

plot data2 = close(GetNextITMOption(GetATMOption(ticker, expirationDate, OptionClass.PUT))) + close(GetNextOTMOption(GetATMOption(ticker, expirationDate, OptionClass.PUT)));
 
you might have to wait till market opens again, sometimes options data becomes unavailable over the weekend at least it does on my RTD and googlefinance feeds
 
Oh I see. Yes I just created this script so I haven't run it while the market was open. Thanks. Hopefuly it will work when open.
 
@BenTen Is there anyway to post a word doc or PDF? I copied all the ThinkScript instructional data off the sight onto a Word document. I use this to reference and with it all being in once spot you can clt+F what you are looking for instead of searching the site. Additionally all the parts are hyperlinked if you wanted to go to that section of TOS learning center. It's 191 pages. There are still a few things I may add like the explanations of the different types of studies and what not.
 
Hi guys I need your help, I'm trying to get the value of the percentage of the volume of options with respect to the volume of the stock, example if I have the volume of options CCL 05/29 Call 18 = 30K and the volume of the stock at that moment is 15 million, then ((30K * 100) / 15000000) * 100 = 20%, what would be the code that is required to place it in the watchlist to get that porcentage value??, I appreciate your help, thanks
 
Ok so I am making a label that shows the overall change in open interest from the day before. I know open interest isn't reported until the following day and that is fine for this. This is what I came up with. Can someone please check my work or am I way off on this.
Code:
def OI = OpenInterest();
plot R = ((OI - OI[1]) - 1);
addlabel(yes, "Chg in OI:" + R, color.light_GRAY);
 
The ToS Options Hacker Module doesn't allow the using of custom scripts to scan against options related data.
Your scan requests can't be scripted into the scanner.
 
As the title implies, I basically want to create a custom study that multiplies the option price by volume and filters out options that don't fulfill this criteria. An example would be something like: (OptionPrice * 100) * Volume >= 250000.

I've messed around with the Volume and OptionPrice on ThinkScript to see if this could be possible but I've hit a roadblock. When using Volume, it seems that it's strictly filtering stock volume and not option volume... and OptionPrice seems to filter differently as well.
 
This is the best version of options volume integration I have found, as they found a way to not have to manually input the contracts, so you can look at any symbol and it automatically picks up the top 5,10,20 strikes for that symbol.

https://www.futurestrad3r.com/shop
spxvolume.png
 
Last edited:
@topmarx Has this indicator been useful for you? Do you use on it on futures or equities? I was looking exactly for something like this that visualizes the Time & Sales data. However it is nearly impossible to know the direction of the buy/sell of the call/put. As described in futurestrad3r article if it's on the Bid/Ask is how they make their assumption along with the price action. https://www.futurestrad3r.com/post/how-to-trade-using-our-option-volume-indicator
 
It would probably be WAY more useful to see which levels have the most call/put volume at... If we have lots of OTM puts and price goes UP, that's going to create squeezey environemnts.
 
I modified the code quite a bit and automated it to use the currently selected symbol... Just a heads up, this takes a minute to load because it looks through quite a lot of data.


Code:
# Put/Call
# 11.9.2019

declare lower;

def series = 1;
def Strike = Round(close(symbol = GetSymbol()) / .5, 0) * .5;
def CurrentYear = GetYear();
def CurrentMonth = GetMonth();
def CurrentDOM = GetDayOfMonth(GetYYYYMMDD());
def Day1DOW1 = GetDayOfWeek(CurrentYear * 10000 + CurrentMonth * 100 + 1);
def FirstFridayDOM1 = if Day1DOW1 < 6
                          then 6 - Day1DOW1
                          else if Day1DOW1 == 6
                          then 7
                          else 6;
def RollDOM = FirstFridayDOM1 + 14;
def ExpMonth1 = if RollDOM > CurrentDOM
                    then CurrentMonth + series - 1
                    else CurrentMonth + series;
def ExpMonth2 = if ExpMonth1 > 12
                    then ExpMonth1 - 12
                    else ExpMonth1;
def ExpYear = if ExpMonth1 > 12
                  then CurrentYear + 1
                  else CurrentYear;
def Day1DOW = GetDayOfWeek(ExpYear * 10000 + ExpMonth2 * 100 + 1);
def FirstFridayDOM = if Day1DOW < 6
                         then 6 - Day1DOW
                         else if Day1DOW == 6
                         then 7
                         else 6;
def ExpDOM = FirstFridayDOM + 14;
def date = ExpYear * 10000 + ExpMonth2 * 100 + ExpDOM + 1;

def PutTotal = fold index = -10 to 10 with s = 0 do s + volume(Concat(Concat(Concat(".", GetSymbol()), Concat(AsPrice(date - 20000001), "P")), index + Strike));
def CallTotal = fold i = -10 to 10 with r = 0 do r + volume(Concat(Concat(Concat(".", GetSymbol()), Concat(AsPrice(date - 20000001), "C")), i + Strike));


def CallVolume = if IsNaN(volume(symbol = GetATMOption(GetSymbol(), date, OptionClass.CALL)))
                     then CallVolume[1]
                     else volume(symbol = GetATMOption(GetSymbol(), date, OptionClass.CALL));


AddLabel(yes, (Concat("Ex date: ",
              Concat(ExpMonth2,
              Concat("/",
              Concat(ExpDOM,
              Concat("/",
              Concat(AsPrice(ExpYear), ""))))))), Color.WHITE);
AddLabel(1, "Strikes " + GetSymbol() + ": $" + Strike, Color.WHITE);
AddLabel(yes, Concat("ATM Put/Call Ratio ", Round(PutTotal / CallTotal, 2)), Color.WHITE);
AddLabel(yes, Concat("ATM Put Volume ", PutTotal), Color.WHITE);
AddLabel(yes, Concat("ATM Call Volume ", CallTotal), Color.WHITE);
def PV = if IsNaN(PutTotal)
            then PV[1]
            else PutTotal;
def CV = if IsNaN(CallTotal)
            then CV[1]
            else CallTotal;
plot ChangeRatio = if IsNaN(close) then Double.NaN else PV / CV;
ChangeRatio.AssignValueColor(if ChangeRatio > 1
                 then Color.GREEN
                 else Color.RED);
# End Study
 
@Zardoz0609 Thank you been trying to find something like this. Only thing it shows only labels, there are no lines or anything else? Is there supposed to be lines because having lines for calls puts) like the original pic people are trying to find on page 1 would be incredible helpful since I am visual person.

Also what time frame does this work on ? Thank you!
 
@axlerod I simplified the plot down to what I really wanted to see which was the days in which there was a significant rise in the p/c ratio (it can take a minute to load because it sorts through a lot of data). It wouldn’t be too difficult to put an average back in if you would like, but it made the graph look quite busy. Essentially what this does now is it looks at the put and call volume at +/- 5 strikes from the ATM strike for every single day shown on your chart. The P/C ratio and volume at the top is just for the current day, but the graph goes as far back as the chart you have pulled up.
 
@axlerod Additionally, here is a screen shot of what my plot looks like. Just realize the graph is just showing how many puts vs how many calls were purchased for a single day and not in any way a short interest indicator. So the big green humps just highlight that for THAT day a bunch of people traded puts relative to calls.

Capture.png


That's basically Peloton right this minute. You can see a ton of people were buying puts around 19-21 May possibly highlighting an upcoming short squeeze. Although, if you go look up the actual short ratio, it was declining significantly at that time. Take it as you will.
 
@axlerod Additionally, here is a screen shot of what my plot looks like. Just realize the graph is just showing how many puts vs how many calls were purchased for a single day and not in any way a short interest indicator. So the big green humps just highlight that for THAT day a bunch of people traded puts relative to calls.

Capture.png


That's basically Peloton right this minute. You can see a ton of people were buying puts around 19-21 May possibly highlighting an upcoming short squeeze. Although, if you go look up the actual short ratio, it was declining significantly at that time. Take it as you will.
Thats awesome! so can that be translated to look like this? Screenshot here only way I know to add. https://prnt.sc/tsuwg3
 

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
656 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