Risk/Reward Visual Aid For ThinkOrSwim

carey3

New member
0OUzAZ5.png

A script to show where +/-6% and 10% are from close for a visual aid in risk/reward decision making

#hint: This draws a horizontal bar at the close or PinValue and 3 set percentages above and below that value./n I wanted a visual line to show where plus and minus 6%, 10% and 15% or 20% was when walking through my watch list./n The PinValue will be used instead of the close value if it is set to anything other than 0.0.

Code:
 (c) Carey Lynch 2026 shared as !HcHeR1ON
#<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
input PinValue = 0.00;

input Hig1percent = 1.06;input ShowHig1 = yes;
input Hig2percent = 1.10;input ShowHig2 = yes;
input Hig3percent = 1.15;input ShowHig3 = yes;
input Low1percent = 0.94;input ShowLow1 = yes;
input Low2percent = 0.90;input ShowLow2 = yes;
input Low3percent = 0.85;input ShowLow3 = yes;
input lineWeight = 2;

#<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
def price = close[1];# because the horizontals are one bar past the last bar.
def centerPt = if PinValue == 0 then price else PinValue;
def lastClose = if isNaN(close) and !isNaN(close[1]) then centerPt else Double.NaN;

#<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
plot UC = Double.NaN;# I started with different colors, but decided on bright yellow for all lines
UC.DefineColor("BrightYellow", CreateColor(255,255,150));
UC.DefineColor("up10%", CreateColor(255,255,150));
UC.DefineColor("up20%", CreateColor(255,255,150));
UC.DefineColor("dn10%", CreateColor(255,255,150));
UC.DefineColor("dn20%", CreateColor(255,255,150));
UC.DefineColor("Purple", CreateColor(192,000,255));
UC.DefineColor("SpringGrn", CreateColor(000,255,127));
UC.DefineColor("HotPink", CreateColor(255,020,147));
#<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
plot PIN = lastClose;
PIN.AssignValueColor( UC.Color("Purple") );
PIN.SetLineWeight(lineWeight);
PIN.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
#<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
plot Pin1P = lastClose * Hig3percent;
plot Pin2P = lastClose * Hig2percent;
plot Pin3P = lastClose * Hig1percent;
plot Pin4P = lastClose * Low1percent;
plot Pin5P = lastClose * Low2percent;
plot Pin6P = lastClose * Low3percent;
Pin1P.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Pin2P.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Pin3P.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Pin4P.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Pin5P.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Pin6P.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Pin1P.AssignValueColor( UC.Color("up20%") );
Pin2P.AssignValueColor( UC.Color("up10%") );
Pin3P.AssignValueColor( UC.Color("BrightYellow") );
Pin4P.AssignValueColor( UC.Color("BrightYellow") );
Pin5P.AssignValueColor( UC.Color("dn10%") );
Pin6P.AssignValueColor( UC.Color("dn20%") );
Pin1P.SetLineWeight(lineWeight);
Pin2P.SetLineWeight(lineWeight);
Pin3P.SetLineWeight(lineWeight);
Pin4P.SetLineWeight(lineWeight);
Pin5P.SetLineWeight(lineWeight);
Pin6P.SetLineWeight(lineWeight);
Pin1P.setHiding(!ShowHig3);
Pin2P.setHiding(!ShowHig2);
Pin3P.setHiding(!ShowHig1);
Pin4P.setHiding(!ShowLow1);
Pin5P.setHiding(!ShowLow2);
Pin6P.setHiding(!ShowLow3);
#<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
input showLabels = yes; # You could add High and low 3, but I didn't need it on the label bar.
# this started with only 2 values above and below close, decided to add 6% later.
AddLabel(showLabels, " "+(Hig1Percent-1)*100+"% "+round(centerPt * Hig1Percent,1)+
" "+(Hig2Percent-1)*100+"% "+round(centerPt * Hig2Percent,1), UC.Color("SpringGrn") );
AddLabel(showLabels, " "+(Low1Percent-1)*100+"% "+round(centerPt * Low1Percent,1)+
" "+(Low2Percent-1)*100+"% "+round(centerPt * Low2Percent,1), UC.Color("HotPink") );

#<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-> That's All Folks
 
Last edited by a moderator:

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
626 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