NexusFi: Find Your Edge


Home Menu

 





Multicharts .NET Preserves Certain Data in Optimizer in Error


Discussion in MultiCharts

Updated
    1. trending_up 4,088 views
    2. thumb_up 2 thanks given
    3. group 2 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 BrianBacchus 
Las Vegas
 
Experience: Intermediate
Platform: MultiCharts .NET
Trading: CL
Posts: 26 since Oct 2015
Thanks Given: 7
Thanks Received: 37

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.

The end result looks something like this:

protected override void StartCalc(){

m_xaverage1.Price = Bars.Close;
m_xaverage1.Length = MacroTrendLength;
m_xaverage2.Price = Bars.Close;
m_xaverage2.Length = ShorterLengthAvg;

askEff.Clear();
bidAbsorbed.Clear();
bidEff.Clear();
askAbsorbed.Clear();

askEffAvg = 0;
bidAbsorbAvg = 0;
bidEffAvg = 0;
askAbsorbAvg = 0;
combineAsk.Value = 0;
combineBid.Value = 0;

}

Just putting this out there in case someone starts pulling their hair out with frustration because MC .NET isn't behaving the way it seems it should.


Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
The Backwardation Signal: How the CL Futures Curve Tells …
Commodities
April FOMC Minutes: Most Divided Fed Since 1992 -- Many …
Traders Hideout
The May 31 Binary: 60% Trump Declares Iran Ops Over, Onl …
Prediction Markets & Event Contracts
Iran Ceasefire Surges to 19.5% on US 15-Point Plan -- 82 …
Prediction Markets & Event Contracts
$4.5M Floods Russia Nuclear Contract in 24 Hours -- Krem …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
The Pivot Point 113.6³ — Navigating the Prediction of …
26 thanks
Sober Journey With S&P
16 thanks
The Confluence Meter: A Multi-Layered Signal Framework B …
11 thanks
NT8 color choices
10 thanks
Volume Indicators
7 thanks
  #2 (permalink)
 
FuManChou's Avatar
 FuManChou 
Saint Paul, Minnesota, United States
 
Experience: Intermediate
Platform: MultiCharts
Broker: Edge Clear LLC
Trading: MNQ
Frequency: Many times daily
Duration: Hours
Posts: 109 since Jun 2019
Thanks Given: 1,144
Thanks Received: 122

Just wondering. Have you reached out to the MultiCharts team and see what they say? Is it working as designed or a limitation in MC?

FYI. I have two licenses (MC + MC.NET) and have not used MC.NET much.


Reply With Quote
  #3 (permalink)
 
Fi's Avatar
 Fi 
NexusFi
 



FuManChou View Post
Just wondering. Have you reached out to the MultiCharts team and see what they say? Is it working as designed or a limitation in MC?

@FuManChou,

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."


Learn more about Fi AI trading companion
IMPORTANT: I can make mistakes! Always verify data before relying on it.

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.
Reply With Quote




Last Updated on May 6, 2026


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts