Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for 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)
Can you build a strategy to reference another chart window? MC.NET
you are correct that when you loop over the last 2500 bars to populate the array, you will run into the MaxBarsBack limitation again.
One approach to prevent this could be to only store the close for the current bar in your array. Then on the next bar you increment the array index and store the new bar's close in the array (using the new index) etc.. You do this until your array index reaches the number of values that you want to store (2500) in your case and at that moment you'd reset the index to 0 and store the new value (while overwriting the oldest value in the array).
Once you have 2500 values in your array you can perform the other calculations.
Just wanted to say thanks to everyone that helped in this thread. Finally figured out exactly how to do this, so to anyone curious here's precisely how you get around the maxbarsback limitation:
At that point you substitute newBarsClose[x] in the same way you'd use Bars.Close[x].
I haven't fully tested it, but it looks like it might cause indicators to calculate faster as well.
UPDATE: The indicator using the array loaded on a 1 tick chart (405,000 bars) in ~15 seconds. Standard indicator using Bars.Close[x] loaded on the same chart in ~25 seconds.
good job. You might be able to speed things up even further by not copying the entire array each time, but by just overwriting the respective index with the new value on every bar.
Something along the lines of this should work for your one tick chart:
On the first bar index 0 is filled (because 0 % 2500 = 0) and each new bar will be stored in the next index (for example on bar two: 1 % 2500 = 1 etc.). Assuming a length of 2500 on bar 2501 the index "(Bars.CurrentBar-1) % 2500" will evaluate to 0 again and overwrite the first index.
I gave this a try and it does something kind of weird, it gives the first value, repeats it until 2500th bar (tick) then repeats another value for the rest of the chart.
My copy method works great for indicators but I'm running into all sorts of silliness trying to use it in a strategy as I keep getting "destination index is not long enough" errors.
I am afraid I could only guess without seeing the entire code.
Does the error message actually state "destination index is not long enough" or destination arrayis not long enough" and how often does it come up?
Regards,
ABCTG
BrianBacchus
I gave this a try and it does something kind of weird, it gives the first value, repeats it until 2500th bar (tick) then repeats another value for the rest of the chart.
My copy method works great for indicators but I'm running into all sorts of silliness trying to use it in a strategy as I keep getting "destination index is not long enough" errors.