Each time a customis created, our servers have to store its values in memory, for future use.
During backtesting this is not an issue, as, when the backtest ends, we can safely forget about these values. They only live in memory for a couple of seconds.
However, when you run a strategy, it may continue to run for months on end. We keep the last 500 values in memory of eachyou create.
This could quickly get out of hand, so we've imposed limits on persistent memory for exactly the same reasons as we talked about in Execution Speed Limits.
Every QuantScript strategy has a limit of 200KB of persistent memory. Eachyou create takes up 8KB.
In simple terms, you can create up to 25 custom series within a single strategy.
Another case in which we persist values in whenever you use thetime travel operator on a complex series based on , , , , , or . If a series is complex enough that recalculating its past values would not be trivial, QuantScript may choose to save its past values in memory so it can access them immediately whenever necessary.
Let's look at some examples:
If there was no persistence of values involved, QuantScript would have to add up 401 values to calculate theseries, and on every bar, too.
Thankfully, QuantScript detects this and persists past values of theseries in memory. Now, calculating means just adding up 5 numbers.
For every such series QuantScript decides to persist, another 8KB of persistent memory is taken up for your strategy.
You can see how much persistent memory is allocated for your strategy by referring to the Console below the QuantScript Editor, after calculating the strategy's backtest.
An additional limit we have imposed is a limit on throwaway(intrabar) memory - the memory that's allocated during the execution of a single bar. We're way more lax there - the limit is 8MB. Much higher, as this memory is cleared after each execution of the script.
Refer to the Console below the QuantScript Editor to find out how much throwaway memory your strategy allocates on average.