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;
plot FinalScore = (ScoreAD);
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;
plot FinalScore = (ScoreAD);
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);
 
Solution

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Thread starter Similar threads Forum Replies Date
M Help adding ATR in my scans Questions 1
S Help on Price crosses above prev day high study Questions 10
Toesz Help Moving Average Study Questions 2
Z ATR From the Lows help Questions 1
H Help with script for color Questions 1

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
293 Online
Create Post

Similar threads

Similar threads

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.
Back
Top