Option spread Calculator

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.
 

rad14733

Well-known member
VIP
@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
 

DoQtorNo

Member
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
 

rad14733

Well-known member
VIP
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...
 

jlondono2002

New member
@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?
 

rad14733

Well-known member
VIP
@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...
 

Malachaim

New member
VIP
@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 ?
 

rad14733

Well-known member
VIP
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
 

Similar threads

Top