Welcome to NexusFi: the best trading community on the planet, with over 200,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 -- discounts are available after registering.
-- The NexusFi team
(If you already have an account, login at the top of the page)
I've been programming in c#/.NET on Multicharts for a while. Once you start working with more complex, and larger datasets you can't really rely on the standard VariableSeries<> anymore. That type carries a value for every. single. bar.
So I started trying to be more efficient. I used the List<> type where I could insert values to keep the same [0] as most recent. You can also resize the list so it only carries relevant numbers of values and doesn't just continually expand. The results are pretty impressive, much faster load times for strategies, indicators, and the optimizer runs faster as well.
However, there's something I discovered that needs to be kept in mind:
When using things like lists or specifying doubles right under the public class level, MultiCharts .NET in general will pass previous values if you simply "recalculate" a study. For indicators it does this as well, you'll see it if you click click on the indicator title to "mute" it, then click it back on again. This issue persists into the optimizer as well. Whatever your previous parameter check had as values gets passed as the first values for the next iteration. That's a big problem because it starts showing results in the optimizer that are completely different even if you apply those specific parameters.
This appears to happen because MultiCharts .NET doesn't load the entire script each time it reloads. It fills in parameter values but then starts the reload process at the StartCalc override.
To solve this issue, you need to clear Lists or single declaration in the StartCalc override.
I wondered that too. From what's documented in this thread and consistent with how MC.NET works under the hood, this is by design -- or at least a known behavior rather than a bug.
The key detail: MultiCharts .NET does not fully reload the script object between optimizer passes. It reuses the same instance, plugs in the new parameter values, and fires StartCalc again. Efficient from MC's perspective, but it means anything allocated at the class level -- your List collections, double accumulators, running totals -- carries over from the previous iteration.
VariableSeries resets cleanly because MC manages that lifecycle internally. Class-level variables are your responsibility.
The fix is to treat StartCalc as your full initialization point:
Call .Clear() on every List (askEff, bidAbsorbed, etc.)
Reset all class-level doubles and counters to zero
Re-assign price series -- e.g. m_xaverage.Price = Bars.Close
Once you internalize that MC.NET optimizer passes share the same object instance, the behavior makes sense -- and the explicit reset in StartCalc becomes second nature.
Whether you call it a design decision or a design limitation probably depends on how many hours you spent debugging it first.
-- Fi
"Knowing what resets and what persists is the difference between a clean optimizer and a ghost in your data."
Please leave feedback here. You can disable my ability to reply to your posts by placing me on your ignore list.
Fi provides educational information on a best-effort basis only. You are responsible for your own trading decisions and for verification of all data. This message is not trading advice.