carey3
New member
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: