Modify line length based on certain candle?

05vprice

New member
Hello everyone!

I am sure this is going to be very simple for someone, but I am stuck haha. Take a look at the image below. I am trying to only allow that magenta line to go to the right 3 candles. I will also share the code I am using to draw the line too. I'd appreciate any help. I have came across many other posts that have lines plotted, but I was unable to get any snippets to work with my plot :(

input showRetraceLine = Yes;
input extendRetraceLine = Yes;

def upper50line = if meetsCriteriaUp and showRetraceLine then high[1] - retraceAmt else If(extendRetraceLine, upper50line[1], Double.NaN);

plot DrawUpper50 = upper50line;
DrawUpper50.SetDefaultColor(Color.CYAN);
DrawUpper50.SetPaintingStrategy(PaintingStrategy.DASHES);

uKq9JTF.png
 
Last edited by a moderator:

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
Your code appears to be incomplete. Based on our private conversation, it looks like you need help with a premium indicator you purchased somewhere else. Not sure if someone on here will be able to help with your request. I would recommend reaching out to the developer and ask for help.
 

05vprice

New member
Developer doesn’t respond and I posted the entire portion of the code that involves the plotting of the line. Just thought someone might have an idea of how to add to this or change how the line is drawn to be limited.
 

horserider

Well-known member
VIP
How can this plot when some of it is not defined? Did you even get this to plot in T0S?

def upper50line = if meetsCriteriaUp and showRetraceLine then high[1] - retraceAmt else If(extendRetraceLine, upper50line[1], Double.NaN);
 

05vprice

New member
MeetscriteriaUp and retraceAmt are just conditions doesn’t need to be anything complicated. I didn’t think those really mattered in terms of plotting the actual line. I’m by far not an expert or very experienced with this. I can post more of the code. I didn’t know what all was needed for you guys to help. It does plot just as it did in the image I attached.
 

horserider

Well-known member
VIP
Ok, tried it. Does not plot. At least the code you provided. Throws errors as shown below. Your ToS must work different than mine. o_O

Expected double
No such variable: meetsCriteriaUp at 4:22
No such variable: retraceAmt at 4:73
No such variable: meetsCriteriaUp at 4:22
No such variable: retraceAmt at 4:73
 

05vprice

New member
I have meetsCriteriaUp and retraceAmt defined in my code I just didn’t post those snippets above. We could just remove meetsCriteriaUp though.

The idea is to draw a line 50% up from the low of that large red candle as a retracement line.
 
Last edited:

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