# Basic Scoring System

#### msloane23423

##### New member
Hi all, blown away by this resource and that there are so many pieces of code. Great work all. I am a relatively simple trader and like everyone else I use a few key metrics to determine trends in the market on both minute scale and longer scale.

What I am trying to do is extremely simple for any basic level coder so looking for some help.

I am looking to create a lower chart, that encapsulates one line, which represents a summation of many evaluations, one based on momentum, one based on price.

For example, if the prices is ABOVE the SMA 20, that would be 1. If the SMA 20 is greater than the last bar, that would be 1. Together this would score as 2.

How do i code that in thinkscript? If i get that snippet i can fold in the rest of my metrics... thank you all.

My guess on how to do thois was to declare lower, then declare variables for each metric.... var 1= PRice vs SMA20, var 2 = SMAvsXBarsAgo, etc...

then at the end plot the summation of all of those variables...

THank you...

Here is a really basic example.

Plot 1 every time the close is greater than 20 SMA.

Code:
``````declare lower;

input price = close;
input length = 20;
input displace= 0;

def SMA = Average(price[-displace], length);

plot score1 = if close > SMA then 1 else 0;``````

Thanks, lll see if can start there!

What i tried to do now was add price vs the SMA 50... but instead of plotting the one line, i want to evaluate the if statement to be a 1 or 0.

then take all these if evaluations that are defined and add up those variables for the value to be plotted.

Code:
``````declare lower;

##SMA20PriceVariables
input price20 = close;
input length20 = 20;
input displace20 = 0;

##SMA50PriceVariables
input price50 = close;
input length50 = 50;
input displace50 = 0;

def SMAPrice20 = Average(price20[-displace20], length20);
def SMAPrice50 = Average(price50[-displace50], length50);

def  ScoreSMAPrice20 = if close > SMAPrice20 then 1 else 0;
def  ScoreSMAPrice50 = if close > SMAPrice50 then 1 else 0;

plot = SUM(ScoreSMAPrice20+ScoreSMAPrice50)``````

Ok i figured this part out...

Here is my cleaned up elemental code...

I will now use displace to look back X bars right so I can compare one moment in time to another?

Code:
``````declare lower;

##SMA20PriceVariables
input price20 = close;
input length20 = 20;
input displace20 = 0;

##SMA50PriceVariables
input price50 = close;
input length50 = 50;
input displace50 = 0;

def SMAPrice20 = Average(price20[-displace20], length20);
def SMAPrice50 = Average(price50[-displace50], length50);

def  ScoreSMAPrice20 = if close > SMAPrice20 then 1 else 0;
def  ScoreSMAPrice50 = if close > SMAPrice50 then 1 else 0;

plot FinalScore =  (ScoreSMAPrice20+ScoreSMAPrice50);``````

Can also use the sum feature, heres an example:

Code:
``````#defining places in which we have greater than [x] SDev of volume
def SCAN = RelativeVolumeStDev(50).RelVol >= 3;

#scanning to see where we have greater than 3 SDev+ volume, on 3 out of the past 5 days
plot FinalScore = Sum(SCAN, 5) >= 3;``````

keywords: adding summing summed added tally tallying

Last edited:
I really like this forum, hope it stays free... there is a lot of info and interesting ideas here.

Back in the day, I used to add 'em up, as you're suggesting and ended up with >800 lines of script, then color coded, as in assignpricecolor, then whittled 'em back down to see what worked for me and what didnt. Its really a good exercise to find out what works, whats touted and what is simple a waste.

Thanks for everyone's input.. @codydog, I agree 100%. There is so much noise you need to focus on basics which is what I ended up doing with my entire strategy. This code is extremely basic but it does, based on what I am looking at, distill everything and tell me which way the wind is blowing. Not sure if this will be of any use to anyone here but I actually used it today and actually it DID keep me from making some dumb trades. Basically when the line is trending at 6 (max value based on variables) and riding upper boundary you know it's bull trend but when it starts to waffle a bit its losing steam, so that prevented me from taking longs. YMMV and I plan to add more to this as time goes on but its been a good exercise overall. The next thing I want to add is distance from the closest outer Bollinger band as I have noticed failed reversals as the band widens and price does not.

Code:
``````declare lower;

##SMA20PriceVariables
input price20 = close;
input length20 = 20;
input displace20 = 1;

##SMA50PriceVariables
input price50 = close;
input length50 = 50;
input displace50 = 1;

def SMAPrice20 = Average(price20, length20);
def SMAPrice50 = Average(price50, length50);

def SMAMomo20 = Average(price20[+displace20], length20);
def SMAMomo50 = Average(price50[+displace50], length50);

##Price Evaluations
def ScoreSMAPrice20 = if close > SMAPrice20 then 1 else 0;
def ScoreSMAPrice50 = if close > SMAPrice50 then 1 else 0;
def ScoreVWAPPrice = if close >vwap(period = AggregationPeriod.DAY) then 1 else 0;

##MomentumEvaluations
def ScoreRSIMomo = if RSI() > 50 then 1 else 0;
def ScoreSMAMomo20 = if SMAPrice20 > SMAMomo20 then 1 else 0;
def ScoreSMAMomo50 = if SMAPrice50 > SMAMomo50 then 1 else 0;

plot TotalScore =
(
+ScoreSMAPrice20
+ScoreSMAPrice50
+ScoreVWAPPrice
+ScoreRSIMomo
+ScoreSMAMomo20
+ScoreSMAMomo50
);

plot neutraline = 3;``````

@msloane23423 scoring systems sometimes benefit from weighted scores, for instance, some would consider a falling RSI or falling CCI a showstopper so might give it a 2 or even a 3. Just a thought...

Last edited:
Thanks for everyone's input.. @codydog, I agree 100%. There is so much noise you need to focus on basics which is what I ended up doing with my entire strategy. This code is extremely basic but it does, based on what I am looking at, distill everything and tell me which way the wind is blowing. Not sure if this will be of any use to anyone here but I actually used it today and actually it DID keep me from making some dumb trades. Basically when the line is trending at 6 (max value based on variables) and riding upper boundary you know it's bull trend but when it starts to waffle a bit its losing steam, so that prevented me from taking longs. YMMV and I plan to add more to this as time goes on but its been a good exercise overall. The next thing I want to add is distance from the closest outer Bollinger band as I have noticed failed reversals as the band widens and price does not.

Code:
``````declare lower;

##SMA20PriceVariables
input price20 = close;
input length20 = 20;
input displace20 = 1;

##SMA50PriceVariables
input price50 = close;
input length50 = 50;
input displace50 = 1;

def SMAPrice20 = Average(price20, length20);
def SMAPrice50 = Average(price50, length50);

def SMAMomo20 = Average(price20[+displace20], length20);
def SMAMomo50 = Average(price50[+displace50], length50);

##Price Evaluations
def ScoreSMAPrice20 = if close > SMAPrice20 then 1 else 0;
def ScoreSMAPrice50 = if close > SMAPrice50 then 1 else 0;
def ScoreVWAPPrice = if close >vwap(period = AggregationPeriod.DAY) then 1 else 0;

##MomentumEvaluations
def ScoreRSIMomo = if RSI() > 50 then 1 else 0;
def ScoreSMAMomo20 = if SMAPrice20 > SMAMomo20 then 1 else 0;
def ScoreSMAMomo50 = if SMAPrice50 > SMAMomo50 then 1 else 0;

plot TotalScore =
(
+ScoreSMAPrice20
+ScoreSMAPrice50
+ScoreVWAPPrice
+ScoreRSIMomo
+ScoreSMAMomo20
+ScoreSMAMomo50
);

plot neutraline = 3;``````
This is a pretty cool idea man, thanks for sharing. I really dig the 1 to 6 scale system. This opened my mind to other possibilities.

### Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
375 Online

## 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.