# Options Score / Algo Trading

#### Drak

##### New member
Good day to all.
I created a lower chart to ToS charts that scores the option based on a series of checks. These checks where 'made' by u/dj_options from reddit r/algotrading, original post can be found here: The chart plots the score, and displays the all of the checks values in labels, color coded for pass/fail

Here are all the checks for B-Score. If they are True, the counter gets increased by 1.

RSI <=40

Volume >=100

Filled price <= Lower Bollinger band

SMA ( 5 days) <= VWAP

Spread >=0.05 (This might change in future)

Filled price = Current Bid

IV<=40

Today gain <= 0

Code:
declare lower;

input p = FundamentalType.CLOSE;
input length = 20;
input averageType = AverageType.SIMPLE;

def _rsi = if IsNaN(RSI()) then 0 else RSI();
def step1 = If(_rsi <= 40, 1, 0);
def _vol = if IsNaN(volume()) then 0 else volume();
def step2 = If(_vol >= 100, 1, 0);

def filled = if IsNaN(close(priceType = PriceType.LAST)) then 0 else close(priceType = PriceType.LAST);
def lowerband = if IsNaN(MovingAverage(averageType, Fundamental(fundamentalType = p), length) - StDev(close, 20) * 2) then 0 else MovingAverage(averageType, Fundamental(fundamentalType = p), length) - StDev(close, 20) * 2;

def step3 = If(filled <= lowerband, 1, 0);

def sma5 = if IsNaN(MovingAverage(averageType,Fundamental(fundamentalType = p), 5)) then 0 else MovingAverage(averageType, Fundamental(fundamentalType = p), 5);
def vw = vwap();
def step4 = If(sma5 <= vw, 1, 0);

def bid = if IsNaN(close(priceType = PriceType.BID)) then 0 else close(priceType = PriceType.BID);

def step5 = If(spread >= 0.05, 1, 0);

def step6 = If(filled equals bid, 1, 0);
def iv = if IsNaN(imp_volatility(getUnderlyingSymbol(), priceType = PriceType.LAST) * 100) then 0 else imp_volatility(getUnderlyingSymbol(),priceType = PriceType.LAST) * 100;

def step7 = if(iv <= 40, 1, 0);

def dailyOpen = if IsNaN(open(period = AggregationPeriod.DAY)) then (if isNaN(open()) then 0 else open()) else open(period = AggregationPeriod.DAY);

def todaysGain = filled - dailyOpen;
def step8 = If(todaysGain <= 0, 1, 0);

def put = IsPut();
def putcheck = if put then -8 else 0;
def score = step1 + step2 + step3 + step4 + step5 + step6 + step7 + step8 + putcheck;
plot plotscore = score;

AddLabel(yes, if put then "PUT" else "CALL", if put then Color.ORANGE else Color.GREEN);
AddLabel(yes, "Score:" + score, if score >= 6 then if put then Color.RED else Color.GREEN else Color.RED);
AddLabel(yes, "RSI:" + _rsi, if _rsi <= 40 then Color.GREEN else Color.RED);
AddLabel(yes, "Vol:" + _vol, if _vol >= 100 then Color.GREEN else Color.RED);
AddLabel(yes, "Bolngr:" + filled + "<=" + lowerband, if filled <= lowerband then Color.GREEN else Color.RED);
AddLabel(yes, "SMAVWAP:" + sma5 + "<=" + vw, if sma5 <= vw then Color.GREEN else Color.RED);
AddLabel(yes, "Filled:" + filled + "=" + bid, if filled equals bid then Color.GREEN else Color.RED);
AddLabel(yes, "IV:" + iv, if iv <= 40 then Color.GREEN else Color.RED);
AddLabel(yes, "Gain:" + todaysGain, if todaysGain <= 0 then Color.GREEN else Color.RED);

Would very very very much appreciate some help. Can someone tell my why this Code is not working and could improve it. Thanks

Last edited:
Good day to all.
I created a lower chart to ToS charts that scores the option based on a series of checks. These checks where 'made' by u/dj_options from reddit r/algotrading, original post can be found here: The chart plots the score, and displays the all of the checks values in labels, color coded for pass/fail

Here are all the checks for B-Score. If they are True, the counter gets increased by 1.

RSI <=40

Volume >=100

Filled price <= Lower Bollinger band

SMA ( 5 days) <= VWAP

Spread >=0.05 (This might change in future)

Filled price = Current Bid

IV<=40

Today gain <= 0

Code:
declare lower;

input p = FundamentalType.CLOSE;
input length = 20;
input averageType = AverageType.SIMPLE;

def _rsi = if IsNaN(RSI()) then 0 else RSI();
def step1 = If(_rsi <= 40, 1, 0);
def _vol = if IsNaN(volume()) then 0 else volume();
def step2 = If(_vol >= 100, 1, 0);

def filled = if IsNaN(close(priceType = PriceType.LAST)) then 0 else close(priceType = PriceType.LAST);
def lowerband = if IsNaN(MovingAverage(averageType, Fundamental(fundamentalType = p), length) - StDev(close, 20) * 2) then 0 else MovingAverage(averageType, Fundamental(fundamentalType = p), length) - StDev(close, 20) * 2;

def step3 = If(filled <= lowerband, 1, 0);

def sma5 = if IsNaN(MovingAverage(averageType,Fundamental(fundamentalType = p), 5)) then 0 else MovingAverage(averageType, Fundamental(fundamentalType = p), 5);
def vw = vwap();
def step4 = If(sma5 <= vw, 1, 0);

def bid = if IsNaN(close(priceType = PriceType.BID)) then 0 else close(priceType = PriceType.BID);

def step5 = If(spread >= 0.05, 1, 0);

def step6 = If(filled equals bid, 1, 0);
def iv = if IsNaN(imp_volatility(getUnderlyingSymbol(), priceType = PriceType.LAST) * 100) then 0 else imp_volatility(getUnderlyingSymbol(),priceType = PriceType.LAST) * 100;

def step7 = if(iv <= 40, 1, 0);

def dailyOpen = if IsNaN(open(period = AggregationPeriod.DAY)) then (if isNaN(open()) then 0 else open()) else open(period = AggregationPeriod.DAY);

def todaysGain = filled - dailyOpen;
def step8 = If(todaysGain <= 0, 1, 0);

def put = IsPut();
def putcheck = if put then -8 else 0;
def score = step1 + step2 + step3 + step4 + step5 + step6 + step7 + step8 + putcheck;
plot plotscore = score;

AddLabel(yes, if put then "PUT" else "CALL", if put then Color.ORANGE else Color.GREEN);
AddLabel(yes, "Score:" + score, if score >= 6 then if put then Color.RED else Color.GREEN else Color.RED);
AddLabel(yes, "RSI:" + _rsi, if _rsi <= 40 then Color.GREEN else Color.RED);
AddLabel(yes, "Vol:" + _vol, if _vol >= 100 then Color.GREEN else Color.RED);
AddLabel(yes, "Bolngr:" + filled + "<=" + lowerband, if filled <= lowerband then Color.GREEN else Color.RED);
AddLabel(yes, "SMAVWAP:" + sma5 + "<=" + vw, if sma5 <= vw then Color.GREEN else Color.RED);
AddLabel(yes, "Filled:" + filled + "=" + bid, if filled equals bid then Color.GREEN else Color.RED);
AddLabel(yes, "IV:" + iv, if iv <= 40 then Color.GREEN else Color.RED);
AddLabel(yes, "Gain:" + todaysGain, if todaysGain <= 0 then Color.GREEN else Color.RED);

Would very very very much appreciate some help. Can someone tell my why this Code is not working and could improve it. Thanks
What is it not doing for you?

What is it not doing for you?
I never get a score above 5 (6-8 is the buying zone), also could someone or you add a MACD to that? Like a golden cross or something and if the macd is bullish its also 1 check/score

It doesn't seem to be calculating the bid/ask spread information and I guess it won't do the filled information until you place the trade. I think if you get 3 to 5 of the criteria as long as you get it at a good price it should be a good trade

Good day to all.
I created a lower chart to ToS charts that scores the option based on a series of checks. These checks where 'made' by u/dj_options from reddit r/algotrading, original post can be found here: The chart plots the score, and displays the all of the checks values in labels, color coded for pass/fail

Here are all the checks for B-Score. If they are True, the counter gets increased by 1.

RSI <=40

Volume >=100

Filled price <= Lower Bollinger band

SMA ( 5 days) <= VWAP

Spread >=0.05 (This might change in future)

Filled price = Current Bid

IV<=40

Today gain <= 0

Code:
declare lower;

input p = FundamentalType.CLOSE;
input length = 20;
input averageType = AverageType.SIMPLE;

def _rsi = if IsNaN(RSI()) then 0 else RSI();
def step1 = If(_rsi <= 40, 1, 0);
def _vol = if IsNaN(volume()) then 0 else volume();
def step2 = If(_vol >= 100, 1, 0);

def filled = if IsNaN(close(priceType = PriceType.LAST)) then 0 else close(priceType = PriceType.LAST);
def lowerband = if IsNaN(MovingAverage(averageType, Fundamental(fundamentalType = p), length) - StDev(close, 20) * 2) then 0 else MovingAverage(averageType, Fundamental(fundamentalType = p), length) - StDev(close, 20) * 2;

def step3 = If(filled <= lowerband, 1, 0);

def sma5 = if IsNaN(MovingAverage(averageType,Fundamental(fundamentalType = p), 5)) then 0 else MovingAverage(averageType, Fundamental(fundamentalType = p), 5);
def vw = vwap();
def step4 = If(sma5 <= vw, 1, 0);

def bid = if IsNaN(close(priceType = PriceType.BID)) then 0 else close(priceType = PriceType.BID);

def step5 = If(spread >= 0.05, 1, 0);

def step6 = If(filled equals bid, 1, 0);
def iv = if IsNaN(imp_volatility(getUnderlyingSymbol(), priceType = PriceType.LAST) * 100) then 0 else imp_volatility(getUnderlyingSymbol(),priceType = PriceType.LAST) * 100;

def step7 = if(iv <= 40, 1, 0);

def dailyOpen = if IsNaN(open(period = AggregationPeriod.DAY)) then (if isNaN(open()) then 0 else open()) else open(period = AggregationPeriod.DAY);

def todaysGain = filled - dailyOpen;
def step8 = If(todaysGain <= 0, 1, 0);

def put = IsPut();
def putcheck = if put then -8 else 0;
def score = step1 + step2 + step3 + step4 + step5 + step6 + step7 + step8 + putcheck;
plot plotscore = score;

AddLabel(yes, if put then "PUT" else "CALL", if put then Color.ORANGE else Color.GREEN);
AddLabel(yes, "Score:" + score, if score >= 6 then if put then Color.RED else Color.GREEN else Color.RED);
AddLabel(yes, "RSI:" + _rsi, if _rsi <= 40 then Color.GREEN else Color.RED);
AddLabel(yes, "Vol:" + _vol, if _vol >= 100 then Color.GREEN else Color.RED);
AddLabel(yes, "Bolngr:" + filled + "<=" + lowerband, if filled <= lowerband then Color.GREEN else Color.RED);
AddLabel(yes, "SMAVWAP:" + sma5 + "<=" + vw, if sma5 <= vw then Color.GREEN else Color.RED);
AddLabel(yes, "Filled:" + filled + "=" + bid, if filled equals bid then Color.GREEN else Color.RED);
AddLabel(yes, "IV:" + iv, if iv <= 40 then Color.GREEN else Color.RED);
AddLabel(yes, "Gain:" + todaysGain, if todaysGain <= 0 then Color.GREEN else Color.RED);

Would very very very much appreciate some help. Can someone tell my why this Code is not working and could improve it. Thanks
addlabel(1," " + step1 + " " + step2 + " " + step3 +" " +step4 + " " + step5 + " " + step6 + " " + step7 + " " + step8 +" " + putcheck);
Then you can tweak each individual step to get the results you want.
Hope this helps.

Last edited:
Awesome ideas and work. The labels work now. How do we interpret the labels? For example, for SPY it shows gain in RED 4.68

Awesome ideas and work. The labels work now. How do we interpret the labels? For example, for SPY it shows gain in RED 4.68

Since this is an implementation of the algo linked to this thread. The Original Poster (dj_options) mentioned that he takes a trade whenever the gain is less than 0 (green label) or as close to 0 and the Score is >= 6 or 7 (higher number is the most probable trade).

addlabel(1," " + step1 + " " + step2 + " " + step3 +" " +step4 + " " + step5 + " " + step6 + " " + step7 + " " + step8 +" " + putcheck);
Then you can tweak each individual step to get the results you want.
Hope this helps.
I cleaned the labels : (delete all addlabel at the end and replace with this):
addlabel(1," " + step1 + " " + step2 + " " + step3 +" " +step4 + " " + step5 + " " + step6 + " " + step7 + " " + step8 +" " + putcheck, color.yellow);
AddLabel(yes, if put then "PUT" else "CALL", if put then Color.ORANGE else Color.GREEN);
AddLabel(yes, "Score:" + round(score,2), if score >= 6 then if put then Color.RED else Color.GREEN else Color.RED);
AddLabel(yes, "RSI:" + round(_rsi,2), if _rsi <= 40 then Color.GREEN else Color.RED);
AddLabel(yes, "Bar Vol:" + _vol, if _vol >= 100 then Color.GREEN else Color.RED);
AddLabel(yes, "LBB:" + round(filled,2) + "<=" + round(lowerband,2), if filled <= lowerband then Color.GREEN else Color.RED);
AddLabel(yes, "SMAVWAP:" + round(sma5,2) + "<=" + round(vw,2), if sma5 <= vw then Color.GREEN else Color.RED);
AddLabel(yes, "Filled:" + round(filled,2)+ "=" + round(bid,2), if filled equals bid then Color.GREEN else Color.RED);
AddLabel(yes, "IV:" + round(iv,2), if iv <= 40 then Color.GREEN else Color.RED);
AddLabel(yes, "Gain:" + round(todaysGain,2), if todaysGain <= 0 then Color.GREEN else Color.RED);

I do weekly options and don't see how this helps you make any money.
Good luck!

Anyone want tos share the link to this study, I cant get it to work. Thanks in advance

Options Cost Column Questions 3
scan for OTM options LOD in results columns Questions 0
select two options to create a spread and.... Questions 0
Options price Questions 1

87k+ Posts
287 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?