Option Spread Calculator For ThinkOrSwim

DoQtorNo

Member
Howdy and greetings all,

Would like to know if there's a way to calculate teh spread between option chain strike prices. For example when I copy the specific option chain and paste it in the symbol window, would like to place a label that automatically calculates the spread for that particular option.
 
@DoQtorNo Do you use the Active Trader panel by chance...??? Not that it calculates spread... Just curious... The code below is what I use on my charts, both for underlying and options... More for options though... Feel free to use the whole script or strip out what you don't need or modify it to better suit you needs... All three labels can be enabled/disabled...

Ruby:
# My_HL2_BA2_Label
# Created by rad14733
# v1.0 : 2021-03-06 : Initial Release

input showHighLow_2 = yes;
input showBidAsk_2 = yes;
input showAvg = yes;

DefineGlobalColor("HL2", Color.LIME);

AddLabel(showHighLow_2, "HL/2: " + Round((high + low) / 2, 2), GlobalColor("HL2"));

def bid = close(priceType = PriceType.BID);
def ask = close(priceType = PriceType.ASK);

AddLabel(showBidAsk_2, "BA/2: " + Round((bid + ask) / 2, 2), GlobalColor("HL2"));

AddLabel(showAvg, "Avg: " + Round((((high + low) / 2) + ((bid + ask) / 2)) / 2, 2), GlobalColor("HL2"));


# END - My_HL2_BA2_Label
 
Thanks . No i do not use the Active Trader panel...not that advanced just yet. lol. When place your labels against a option chain chart, i get BA/2: N/A. and Avg N/A. Is that because the market is closed?
@DoQtorNo Do you use the Active Trader panel by chance...??? Not that it calculates spread... Just curious... The code below is what I use on my charts, both for underlying and options... More for options though... Feel free to use the whole script or strip out what you don't need or modify it to better suit you needs... All three labels can be enabled/disabled...

Ruby:
# My_HL2_BA2_Label
# Created by rad14733
# v1.0 : 2021-03-06 : Initial Release

input showHighLow_2 = yes;
input showBidAsk_2 = yes;
input showAvg = yes;

DefineGlobalColor("HL2", Color.LIME);

AddLabel(showHighLow_2, "HL/2: " + Round((high + low) / 2, 2), GlobalColor("HL2"));

def bid = close(priceType = PriceType.BID);
def ask = close(priceType = PriceType.ASK);

AddLabel(showBidAsk_2, "BA/2: " + Round((bid + ask) / 2, 2), GlobalColor("HL2"));

AddLabel(showAvg, "Avg: " + Round((((high + low) / 2) + ((bid + ask) / 2)) / 2, 2), GlobalColor("HL2"));


# END - My_HL2_BA2_Label
 
Thanks . No i do not use the Active Trader panel...not that advanced just yet. lol. When place your labels against a option chain chart, i get BA/2: N/A. and Avg N/A. Is that because the market is closed?

Yes... They will populate as soon as the option starts trading...
 
@DoQtorNo Do you use the Active Trader panel by chance...??? Not that it calculates spread... Just curious... The code below is what I use on my charts, both for underlying and options... More for options though... Feel free to use the whole script or strip out what you don't need or modify it to better suit you needs... All three labels can be enabled/disabled...

Ruby:
# My_HL2_BA2_Label
# Created by rad14733
# v1.0 : 2021-03-06 : Initial Release

input showHighLow_2 = yes;
input showBidAsk_2 = yes;
input showAvg = yes;

DefineGlobalColor("HL2", Color.LIME);

AddLabel(showHighLow_2, "HL/2: " + Round((high + low) / 2, 2), GlobalColor("HL2"));

def bid = close(priceType = PriceType.BID);
def ask = close(priceType = PriceType.ASK);

AddLabel(showBidAsk_2, "BA/2: " + Round((bid + ask) / 2, 2), GlobalColor("HL2"));

AddLabel(showAvg, "Avg: " + Round((((high + low) / 2) + ((bid + ask) / 2)) / 2, 2), GlobalColor("HL2"));


# END - My_HL2_BA2_Label
Hi @rad14733 how can i use that code on scan custom to find options with $1 0r $2 between the ask and bid?
 
@jlondono2002 Now you are asking for something altogether different... What you are asking is for an Option Hacker Scan which can be done if you take the time to roll your sleeves up and play with the scanner...
 
@DoQtorNo Do you use the Active Trader panel by chance...??? Not that it calculates spread... Just curious... The code below is what I use on my charts, both for underlying and options... More for options though... Feel free to use the whole script or strip out what you don't need or modify it to better suit you needs... All three labels can be enabled/disabled...

Ruby:
# My_HL2_BA2_Label
# Created by rad14733
# v1.0 : 2021-03-06 : Initial Release

input showHighLow_2 = yes;
input showBidAsk_2 = yes;
input showAvg = yes;

DefineGlobalColor("HL2", Color.LIME);

AddLabel(showHighLow_2, "HL/2: " + Round((high + low) / 2, 2), GlobalColor("HL2"));

def bid = close(priceType = PriceType.BID);
def ask = close(priceType = PriceType.ASK);

AddLabel(showBidAsk_2, "BA/2: " + Round((bid + ask) / 2, 2), GlobalColor("HL2"));

AddLabel(showAvg, "Avg: " + Round((((high + low) / 2) + ((bid + ask) / 2)) / 2, 2), GlobalColor("HL2"));


# END - My_HL2_BA2_Label
By any chance you have a screen shot that you mind sharing on this guy ?
 
By any chance you have a screen shot that you mind sharing on this guy ?

Assuming you meant of the three labels, here you go... They would be the lime colored labels...

HHJvwtI.png
 

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