Fold exceed historical data

Ivan Felipe

New member
Hi, can anybody help me with this ?

In the code:

fold i = 0 to 200 with res1 = 0 while res1 <= high do ...whatever;

this doesn´t work - and stop execution of the script - when there is not enouth historical data (less than 200 bars in this case ) and it shows an error messsage like this:
" Study requires at least 265 bars to be computed but only 155 are available..."

Any idea how to solve this trouble or, at least, how to find the amount of historical available data (155 in this case) to handle a solution-

Thanks a lot... (Please excuse my english)
 
Solution
Hi, can anybody help me with this ?

In the code:

fold i = 0 to 200 with res1 = 0 while res1 <= high do ...whatever;

this doesn´t work - and stop execution of the script - when there is not enouth historical data (less than 200 bars in this case ) and it shows an error messsage like this:
" Study requires at least 265 bars to be computed but only 155 are available..."

Any idea how to solve this trouble or, at least, how to find the amount of historical available data (155 in this case) to handle a solution-

Thanks a lot... (Please excuse my english)

next time provide a real study , not a partial code line.
we have no idea what you really tried.

i'm guessing you should be using getvalue(high,i) , not high, otherwise ...
@Ivan Felipe You failed to mention the timeframe of your Chart, in Days and Minutes for example, but this could be the issue... You need to have enough candles/bars visible on your Chart in order for the Study to parse them... Increase the amount of historical lookback and you should have better results...
 

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

Hi, can anybody help me with this ?

In the code:

fold i = 0 to 200 with res1 = 0 while res1 <= high do ...whatever;

this doesn´t work - and stop execution of the script - when there is not enouth historical data (less than 200 bars in this case ) and it shows an error messsage like this:
" Study requires at least 265 bars to be computed but only 155 are available..."

Any idea how to solve this trouble or, at least, how to find the amount of historical available data (155 in this case) to handle a solution-

Thanks a lot... (Please excuse my english)

next time provide a real study , not a partial code line.
we have no idea what you really tried.

i'm guessing you should be using getvalue(high,i) , not high, otherwise , the fold is useless.
i threw something together and it works... so not sure what you were doing?

if there is no data before the first bar, then the plot starts with 1.
if there is data, then it starts with a higher number.

i tried with and without this,
and !isnan(getvalue(close,i))
and it was the same,
so it appears , the fold stops if there is no data to read.


go here and get a few symbols for testing
https://www.iposcoop.com/last-100-ipos/

test symbol - CRWV hour

Code:
#https://www.iposcoop.com/last-100-ipos/

declare lower;

def na = double.nan;
def bn = barnumber();

input qty = 200;
def a = fold i = 0 to qty
 with k = 0
 while k <= getvalue(high,i)
# while k <= getvalue(high,i) and !isnan(getvalue(close,i))
 do k+1;


#plot z0 = 0;
plot z = if !isnan(close) then a else na;
 

Attachments

  • Capture.JPG
    Capture.JPG
    73.2 KB · Views: 10
Solution

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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