Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now, It is Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I'm just starting with trying to work with the PriceSeriesProvider (PSP) Class.
I wrote the following code, but I get an error as soon as I tried to change PSP1.Close to anything beyond 0 or 1. (Eventually I want to get the value for PSP1.Clsoe[14] or something similar).
What am I doing wrong here that prevents me from looking at the value for anything greater than Close[1]?
Can you help answer these questions from other members on NexusFi?
since PSPs load asynchronously your code might be trying to access values that are not yet present. As a safety net you can try checking the PSP has enough values using "PSP1.Count" before you access a certain index. For performance reasons you can use a boolean flag that you set to true once when the PSP has enough values. This way you avoid having to check this on every bar.
Depending on your MaxBarsBack setting it is also not guaranteed that the PSP holds 14 bars back when you try to access it on the first bar. The check mentioned above can help preventing the error message in that case, too.