inthefutures
Active member
Maybe you can bring sizzle into the equation and look for large changes.
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
def OI = OpenInterest();
plot R = ((OI - OI[1]) - 1);
addlabel(yes, "Chg in OI:" + R, color.light_GRAY);
# 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
Thats awesome! so can that be translated to look like this? Screenshot here only way I know to add. https://prnt.sc/tsuwg3@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.
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.
Start a new thread and receive assistance from our community.
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.
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.