Ask Line +20

Adeodatus

Member
Maybe a hand with this too? this part won't clear out all the red highlighted script:

for i = 0 to 19
{
plot extendedLine = if barNumber() == i then HorizontalLine else extendedLine[1];

and the last ( } )also red highlight.


Will it show a line at ask and run out to the right 20 ?



plot HorizontalLine = if barNumber() == 0 then ask else HorizontalLine[1];
HorizontalLine.SetDefaultColor(color.red);
HorizontalLine.SetLineWeight(3);
HorizontalLine.AssignValueColor(if HorizontalLine >= close then color.red else color.green);

# extend line for 20 periods
for i = 0 to 19
{
plot extendedLine = if barNumber() == i then HorizontalLine else extendedLine[1];
extendedLine.SetDefaultColor(color.red);
extendedLine.SetLineWeight(1);
extendedLine.SetStyle(curve.SHORT_DASH);
}
 
Solution
Maybe a hand with this too? this part won't clear out all the red highlighted script:

for i = 0 to 19
{
plot extendedLine = if barNumber() == i then HorizontalLine else extendedLine[1];

and the last ( } )also red highlight.


Will it show a line at ask and run out to the right 20 ?



plot HorizontalLine = if barNumber() == 0 then ask else HorizontalLine[1];
HorizontalLine.SetDefaultColor(color.red);
HorizontalLine.SetLineWeight(3);
HorizontalLine.AssignValueColor(if HorizontalLine >= close then color.red else color.green);

# extend line for 20 periods
for i = 0 to 19
{
plot extendedLine = if barNumber() == i then HorizontalLine else extendedLine[1];
extendedLine.SetDefaultColor(color.red)...
Maybe a hand with this too? this part won't clear out all the red highlighted script:

for i = 0 to 19
{
plot extendedLine = if barNumber() == i then HorizontalLine else extendedLine[1];

and the last ( } )also red highlight.


Will it show a line at ask and run out to the right 20 ?



plot HorizontalLine = if barNumber() == 0 then ask else HorizontalLine[1];
HorizontalLine.SetDefaultColor(color.red);
HorizontalLine.SetLineWeight(3);
HorizontalLine.AssignValueColor(if HorizontalLine >= close then color.red else color.green);

# extend line for 20 periods
for i = 0 to 19
{
plot extendedLine = if barNumber() == i then HorizontalLine else extendedLine[1];
extendedLine.SetDefaultColor(color.red);
extendedLine.SetLineWeight(1);
extendedLine.SetStyle(curve.SHORT_DASH);
} #hal_fold


thinkscript has a function called fold, for creating loops
https://tlc.thinkorswim.com/center/reference/thinkScript/Reserved-Words/fold

but, fold can't include any output commands. all it can do is calculate a number. you can't put a plot within a fold loop. a separate plot command is needed for every desired plotted object.

https://usethinkscript.com/threads/simple-explanation-of-fold-trying-to-learn.8044/#post-76663

...extend line for 20 periods
for i = 0 to 19...

can't control other bars , can only draw on the current bar and change values on current bar.
so a loop can't change data on other bars.

could save the barnumber on the bar that is first plotted and add 20, and save that value. then compare each barnumber to those, to see if the current bar is between them. if so plot a line.

but, if another signal occurs during the 20 bars, the line would start over, and plot for 20 bars...
if you want multiple lines plitted on 1 bar, need to have multiple plot formulas.


i don't try to fix partial codes. if you have this much wrong in this short sample, probably most of the code is wrong.
Not all errors will be highlighted red at first. as you fix one error, more may show up, and so on.

post the whole code and someone might try to fix it.
 
Last edited:
Solution

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
274 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