MaxBarsBack issue when creating indicators under multiple charts

Questions about MultiCharts .NET and user contributed studies.
arthur203
Posts: 1
Joined: 04 Jun 2018
Has thanked: 1 time

MaxBarsBack issue when creating indicators under multiple charts

Postby arthur203 » 29 Jul 2020

I am currently building a strategy based on .Net64 that trades on S&P 500 front month futures (“ES?0”) while referencing some indicators calculated only on S&P 500 index (“^GSPC”). I wish to have the following feature to my strategy:
⦁ It triggers orders to the front month futures on a daily basis at 16:00 EST (which is just when the S&P 500 market closed, and my indicators get refreshed after obtaining the latest data).

To come up with the solution, I created chart 1 (“ES?0”) from source Interactive Brokers (“IB”) with an “hourly” resolution and chart 2 (“^GSPC”) from source Free Quotes with a “daily” resolution.

The issues facing are as follow:
⦁ There are 1400 bars obtained in chart 1 from Interactive Broker. Since my indicators require to reference 300 days of daily data from ^GSPC, chart 1 did not have enough historical data (i.e., it would require around 300 days x 24 hours = 7200 bars of data, which is more than 1400 bars we have). As my strategy creates signal based on the indicators created from chart 2, it should only require 300 days of daily data from ^GSPC. However, the indicators calculated inside the strategy return wrong value due to the limited bars from chart 1. For instance, if MaxBarsBack is set at 301, only the latest ((1400-301)/24 = 45bars) of chart 2 are returning correct VariableSeries values, while rest of the previous bars (bars 1 to bars 301) of VariableSeries are default to be zero (no calculations can take place until MaxBarsBack has been met), leading to incorrect calculation of the indicators inside the signal.

I have referenced different articles come up with several preliminary solutions. Please advise if the following solutions are feasible and correct me if my concept is unclear:
⦁ Using “Bars.FullSymbolData” to get rid of the MaxBarsBack constraint. However, it doesn’t work on the indicators that stores values by VariableSeries object.
⦁ Obtaining more data from IB for chart 1 (it returned about 1400 bars of data only). But is that possible?
⦁ Obtaining values from plotted indicators referencing chart 2 (their values are correct since there is no max bars back constraint). But is that possible?
⦁ Adopting chart 1 as (“^GSPC”) and chart 2 as (“ES?0”), then submit order on chart 2. But is that possible?
⦁ Rewrite the indicators by using array to store the VariableSeries values. But it seems tedious.

User avatar
Svetlana MultiCharts
Posts: 645
Joined: 19 Oct 2017
Has thanked: 3 times
Been thanked: 163 times

Re: MaxBarsBack issue when creating indicators under multiple charts

Postby Svetlana MultiCharts » 14 Aug 2020

Hello arthur203,

1. Bars.FullSymbolData provides access to the data series only and is not related to the variables.
If you would like to store more data than MaxBarsBack allows, you can use standard C# arrays.
2. Normally IB provides 1 year back of historical data, but it depends on the specific instrument and your IB subscription plan.
3. If you apply the indicator to the second data series, you will get the indicator’s values from data2.
How do you transfer values from the indicator into signal? Is there any reason why you do not calculate the values in the signal directly?
4. It is possible to send orders from the base data series only (data1).


Return to “MultiCharts .NET”