You want to know how indicators are calculated in MultiCharts .NET and which features of the program affect indicator calculation.

The calculation process of MultiCharts .NET indicators

Better understanding of how MultiCharts .NET indicators are calculated helps with creating better performing indicators and troubleshooting apparent inconsistent behaviour.

The following three steps take place when an indicator is added to a data series:

Step 1: Processing price bars and the MaxBarsBack offset

When an indicator is applied to a data series, all historical price bars are processed one-by-one, starting with the first (i.e., the oldest) price bar (MultiCharts Wiki, 2012).

The actual calculations, however, practically never start on the first price bar. Since most indicators reference historical price data, calculations need to be postponed until there are enough historical price bars available. For example, a 10-period moving average indicator needs to delay its calculations until the 11th bar.

The amount of price bars that are needed before the indicator calculations start are called the MaxBarsBack.

Indicator calculation and the MaxBarsBack setting

The MaxBarsBack setting, an abbreviation for maximum number of bars a study will reference, determines how many bars an indicator requires before it begins calculating (MultiCharts Wiki, 2012, 2013). Due to MaxBarsBack, an indicator begins calculating at the MaxBarsBack + 1 bar number at the soonest.

Example of setting the MaxBarsBack in MultiCharts .NET

The MaxBarsBack setting can be found in the indicator’s Format Study screen (right-click the indicator in the chart or the indicator name in the Status Line and select ‘Format [indicator name]’).

The different MaxBarsBack options impact the indicator calculations as follows (MultiCharts Wiki, 2012):

  • With a manually set value in the Format Study window: calculations are postponed until the MaxBarsBack + 1 bar number. When the manually set value is too low, an error message is triggered by MultiCharts .NET;
  • With a programmatically set MaxBarsBack value: calculations are delayed until the MaxBarsBack + 1 bar number. When the programmatically set value is too low, the indicator gets stuck in an infinite recalculation loop (see Henry MultiCharts, 2014);
  • With the ‘Auto-Detect’ setting: the MaxBarsBack is initially set to the largest data offset used in the indicator. When that value is too low (which can happen when functions are called), the MaxBarsBack value is automatically increased and the indicator calculated again starting from the beginning of the data series. This continues until the automatically determined MaxBarsBack value is large enough to calculate the indicator on all historical price bars.

The ‘Auto-Detect’ setting can cause an indicator (and any functions it references) to be executed repeatedly for the first few price bars (MultiCharts Wiki, 2012). Set the MaxBarsBack to a fixed value if your code should not be executed more than once for the first few bars.

After the MaxBarsBack have been taken into account, the indicator begins its calculation on the first historical price bar following the MaxBarsBack offset.

Step 2: Calculating the indicator on historical price data

In the second step, the indicator begins to work through all historical price bars, starting with the MaxBarsBack + 1 bar number up to the bar preceding the last bar on the chart. During this calculation, the programming code is processed once on the close of every historical price bar (MultiCharts Wiki, 2012).

On each historical bar, the indicator can generate its output like a plot, text, trendline, or alert (MultiCharts Wiki, 2012).

Step 3: Calculating the indicator on the last bar of the chart

When the indicator has processed all historical price bars, it arrives at the last bar on the chart. Depending on the ‘Update on Every Tick’ option, which can also be set programmatically with the UpdateOnEveryTick attribute, the last price bar is processed in one of the following ways (MultiCharts Wiki, 2012, 2013):

Example of setting 'Update on every tick' in MultiCharts .NET

The ‘Update on Every Tick’ option can be found in the indicator's Format Study window.

  • With ‘Update on Every Tick’ enabled: the indicator is calculated in real-time with every price update. Each new tick will cause the indicator to be re-evaluated on the last price bar (not on the whole data series). The incomplete bar is processed in the same way as historical, completed price bars by the indicator.
  • With ‘Update on Every Tick’ disabled: the indicator is calculated on bar close only. With this option the indicator is processed in real-time the same way as historical price bars: only on bar close and only once per bar.

A more efficient indicator calculation is therefore possible with disabling the ‘Update on Every Tick’ option, especially when the indicator is applied to multiple instruments or calculation intensive.

Key points:

  • Indicators begin their historical calculations on the MaxBarsBack + 1 bar number;
  • Historical price bars are evaluated once per bar, at the bar’s closing price;
  • The last bar of the chart can either be evaluated with every new price update or only on the bar close.

Henry MultiCharts (2014, 14 January). MultiCharts .NET 8.8 Release forum topic. Retrieved on July 24, 2014, from

MultiCharts (2013). MultiCharts .NET Programming Guide (version 1.0). Retrieved from

MultiCharts Wiki (2012, 23 February). How Scripts Work. Retrieved on July 22, 2014, from

MultiCharts Wiki (2013, 17 October). Indicator Settings. Retrieved on July 22, 2014, from

Visit for more helpful coding articles.