**https://usethinkscript.com/threads/...ain-column-for-thinkorswim.15238/#post-124464**

__updated version:__Hey everyone. I created a metric to judge unusual options activity that works as a column. Here is the code:

Code:

```
#Defining variables
def Delta = Delta();
def Ivol = imp_volatility(GetUnderlyingSymbol());
def OptionMarkPrice = close;
def UnderlyingPrice = close(getUnderlyingSymbol());
def UnderlyingVolume = volume(getUnderlyingSymbol());
#V.A.L.R - Volitility Adjusted Leverage Ratio
def Leverage = (Delta * UnderlyingPrice);
def LeverageRatio = Leverage / OptionMarkPrice;
def VALR = LeverageRatio * Ivol;
#Volume to open interest ratio (if statement pervents divide by zero errors)
def OpenInterest = if open_interest(period = AggregationPeriod.DAY) == 0 then 1 else open_interest(period = AggregationPeriod.DAY);
def volOI = volume / OpenInterest;
#Option dollar volume traded
def DvolumeOpt = volume * ohlc4 * 100;
#Underlying dollar volume traded
def DvolumeUnd = UnderlyingPrice * UnderlyingVolume;
def DvolumeRatio = DvolumeOpt / DvolumeUnd;
#Multiply by 1000 so output better displays in the columns
def WhaleScore = VALR * volOI * DvolumeRatio * 1000;
plot WhalePlot = WhaleScore;
```

Here is the logic behind the calculations:

def Leverage: We begin by multiplying the Delta of a contract by the price of the underlying to get how many dollars worth of the underlying one contract controls. Using the amount of dollars controlled per contract normalizes the measurement so it can be compared between instruments.

def LeverageRatio: We divide the dollar volume controlled per contract by the dollar amount of that contract. This gives us a unitless ratio that is how many dollars worth of the underlying you are controlling per dollar spent on the contract. This alone could be a useful metric.

def VALR: We multiply the LeverageRatio by the implied volitility (IVol) of the underlying instrument. This is done to normalize the value because low implied volitility instruments naturally allow for more leverage in their options contracts than high ones. So now all instruments dollar leverage per contract should be on an even playing field. This metric is still unitless.

def volOI: volume to open interest ratio. This is the classic metric considered when hunting for unusual options and is very important.

def DvolumeOpt: Dollar volume traded in the option contract, just multiplying option price by volume. Keeping to the theme of normalizing to dollars so we can better compare instruments.

def DvolumeUnd: Dollar volume traded in the underlying, just multiplying underlying price by underlying volume. Keeping to the theme of normalizing to dollars so we can better compare instruments.

def DvolumeRatio: Ratio of money spent on the option contract to the whole of the underlying. Represents underlyings capacity to absorb options activity. Higher values show that contract has more impact on the underlying by representing a higher proportion of liquidity. A problem I've noticed with other unusual options scanners is tickers like SPY and AAPL always showing lots of "unusual activity" due to massive dollar volumes traded at given strikes. Relative to the liquidity of SPY and AAPL the activity is actually not that unusual. This ratio is how we account for differing levels of liquidity across instruments.

Def WhaleScore: Our final unusual options activity metric, we get it by multiplying three ratios. The unitless metric VALR which measures how many dollars worth of the underlying you are controlling per dollar spent on a contract on a volitility adjusted basis. Higher values equate to more risk (and therefore more conviction) by naturally prioritizing out of the money high risk plays. Volume to open interest ratio shows money being put where it wasn't previously. DvolumeRatio shows the amount of money spent on the option contract relative to the whole of the underlying. Higher values are more unusual as it means option contract spend is a higher proportion of the total liquidity. All of these metrics are multiplied together to get a value where the farther you are from zero the more "unusual" the activity. Multiplying by 1000 is just to make the output more user friendly to display in the columns.

Note: In the thinkorswim implementation WhaleScore positive values are calls and negative values are puts due to the delta value being positive or negative depending on put or call designation.

And here is the thread where I ask questions on how it can be improved so those discussions can be had there:

https://usethinkscript.com/threads/getting-data-from-an-illiquid-asset.15227/

Repeated lots of stuff from that thread here, sorry for doing these posts a bit haphazardly. Play with it and let me know what you think!

Last edited by a moderator: