Help with Final Score Plot - AccDist with 50 period SMA

Mike

Member
VIP
Hello. I have a number of indicators that I use on my charts to determine when to consider opening a position or closing a position. To unclutter the charts I define the variables and the condition that would render them positive or negative. Then I assign each a Score. If the condition is positive the Score is 1 else the Score is 0. A Final Score is then plotted. So far, I've been able to plot scores for 5 indicators. Assuming all conditions were positive the hypothetical plot Final Score code would look like this:

Plot FinalScore = (ScoreInd1) + (ScoreInd2) + (ScoreInd3) + (ScoreInd4) + (ScoreInd5);

The Final Score plot value would be 5

The code listed below for the variable AccDist is the one that I'm having a problem with. Would appreciate some help. Thanks!

Code:
``````#
# TD Ameritrade IP Company, Inc. (c) 2009-2024
#
# MOD M 06/10/24

declare lower;

def AccDist = TotalSum(volume * CloseLocationValue());
def AccDist_average_length = 50;
def ScoreAD = if AccDist > AccDist_average_length then 1 else 0;
FinalScore.AssignValueColor(if FinalScore > 0 then Color.Green else Color.RED);

End Script``````

Solution
Hello. I have a number of indicators that I use on my charts to determine when to consider opening a position or closing a position. To unclutter the charts I define the variables and the condition that would render them positive or negative. Then I assign each a Score. If the condition is positive the Score is 1 else the Score is 0. A Final Score is then plotted. So far, I've been able to plot scores for 5 indicators. Assuming all conditions were positive the hypothetical plot Final Score code would look like this:

Plot FinalScore = (ScoreInd1) + (ScoreInd2) + (ScoreInd3) + (ScoreInd4) + (ScoreInd5);

The Final Score plot value would be 5

The code listed below for the variable AccDist is the one that I'm having a problem with...
Hello. I have a number of indicators that I use on my charts to determine when to consider opening a position or closing a position. To unclutter the charts I define the variables and the condition that would render them positive or negative. Then I assign each a Score. If the condition is positive the Score is 1 else the Score is 0. A Final Score is then plotted. So far, I've been able to plot scores for 5 indicators. Assuming all conditions were positive the hypothetical plot Final Score code would look like this:

Plot FinalScore = (ScoreInd1) + (ScoreInd2) + (ScoreInd3) + (ScoreInd4) + (ScoreInd5);

The Final Score plot value would be 5

The code listed below for the variable AccDist is the one that I'm having a problem with. Would appreciate some help. Thanks!

Code:
``````#
# TD Ameritrade IP Company, Inc. (c) 2009-2024
#
# MOD M 06/10/24

declare lower;

def AccDist = TotalSum(volume * CloseLocationValue());
def AccDist_average_length = 50;
def ScoreAD = if AccDist > AccDist_average_length then 1 else 0;
FinalScore.AssignValueColor(if FinalScore > 0 then Color.Green else Color.RED);

End Script``````
See if this is what you are looking for:

declare lower;

# Define your indicator conditions and scoring here

# Example Indicator 1
def Condition1 = close > Average(close, 50); # Replace with your actual condition
def ScoreInd1 = if Condition1 then 1 else 0;

# Example Indicator 2
def Condition2 = RSI() > 50; # Replace with your actual condition
def ScoreInd2 = if Condition2 then 1 else 0;

# Example Indicator 3
def Condition3 = MACD()."Value" > MACD()."Avg"; # Replace with your actual condition
def ScoreInd3 = if Condition3 then 1 else 0;

# Example Indicator 4
def Condition4 = close > open; # Replace with your actual condition
def ScoreInd4 = if Condition4 then 1 else 0;

# Example Indicator 5
def Condition5 = close > BollingerBands()."UpperBand"; # Replace with your actual condition
def ScoreInd5 = if Condition5 then 1 else 0;

# Calculate Final Score
def FinalScore = ScoreInd1 + ScoreInd2 + ScoreInd3 + ScoreInd4 + ScoreInd5;

# Plot Final Score
plot FinalScorePlot = FinalScore;
FinalScorePlot.AssignValueColor(if FinalScore > 2 then Color.GREEN else Color.RED); # Example coloring
FinalScorePlot.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

Not the exact question you're looking for?

87k+ Posts
323 Online

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?