MaxBarsBack with multiple data series

Questions about MultiCharts .NET and user contributed studies.
Fabrice
Posts: 182
Joined: 14 Jun 2011
Has thanked: 44 times
Been thanked: 30 times

MaxBarsBack with multiple data series

Postby Fabrice » 15 Mar 2014

Hello,

On a simple 5-min bar chart with 60 days, there are about 6000 bars. With this code, MaxBarsBack will be around 1940 :

Code: Select all

protected override void StartCalc() {
// assign inputs
}
protected override void CalcBar()
{
plot1.Set(Bars.Close[1200]);
if (Bars.LastBarOnChart)
{
Output.WriteLine("MaxBarsBack: {0}", ExecInfo.MaxBarsBack); // 1941
}
}
This allows me to display things up to 20 days, which is good.

Now, I add a daily data stream for same instrument, with the same numbers of days (60). The remaining of the code is the same :

Code: Select all

protected override void StartCalc()
{
dsDaily = BarsOfData(3); // BarsOfData(3) is the daily bar instrument
}
protected override void CalcBar()
{
plot1.Set(Bars.Close[1200]);
if (Bars.LastBarOnChart)
{
Output.WriteLine("MaxBarsBack: {0}", ExecInfo.MaxBarsBack); // "Calculating..."
}
}
The indicator remains in the "Calculating…" state. Why ? Because now MaxBarsBack is also applied to the daily data stream, which, of course, does not contains so much bars. The last index working for Bars.Close[index] is 55. Note that there is absolutely no reference to the daily data stream. Only a declaration. The daily datastream is not used, but it prevents me from using the 5-min data stream. Very strange… and not expected at all.

So there are 6000 5-min bars, and MaxBarsBack prevents me to go beyond the 56th. That does not cover a single session !...

Is there something to change this behavior ? Because at the moment, this makes all the code that relies on a MaxBarsBack of around 1940 unusable. What comes naturally to the mind is that each data stream should have their own MaxBarsBack value. In this example, MaxBarsBack for the daily data stream should probably be 1. But above all, that should not affect the MaxBarsBack of the main data stream. It makes no sense to apply a MaxBarsBack value calculated on a 5-min series to a daily series. Or is there another solution to this problem ?

Regards.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: MaxBarsBack issue with multiple data series

Postby JoshM » 16 Mar 2014

(...) What comes naturally to the mind is that each data stream should have their own MaxBarsBack value. In this example, MaxBarsBack for the daily data stream should probably be 1. But above all, that should not affect the MaxBarsBack of the main data stream. It makes no sense to apply a MaxBarsBack value calculated on a 5-min series to a daily series.
This is a very good idea, since it indeed does not make a lot of sense that each data series has the same MaxBarsBack value.

Regarding your current problem, have you considered loading the daily data through the DataLoader? That way the data is not actually loaded on the chart, yet still available, and therefore no MaxBarsBack issue.

(A `dataloader site:http://www.multicharts.com` Google search turns up some examples of the DataLoader).

Fabrice
Posts: 182
Joined: 14 Jun 2011
Has thanked: 44 times
Been thanked: 30 times

Re: MaxBarsBack issue with multiple data series

Postby Fabrice » 16 Mar 2014

Hello JoshM,

Thank you for your answer. As this issue seems to me so big and strange, I have decided to do the same kind of test on MC (last release build 8593), just to be sure. I have tried to do the same simple test with EasyLanguage (same instrument, same session, 60 days of 5-min bars) :

Code: Select all

plot1( close[1200] );
if LastBarOnChart then begin
print ("MaxBarsBack: ", MaxBarsBack) ;
end ;
Result: 1941 ---> exactly the same than MC.Net

And now when using the daily data stream (60 days) :

Code: Select all

plot1( close[36] );
plot2( close of data2);
if LastBarOnChart then begin
print ("MaxBarsBack: ", MaxBarsBack) ;
end ;
Result: 36 is last index working. For this index, MaxBarsBack is 58.

Clearly, this issue is coded in the engine of studies (and probably also in the strategies we can suppose). This is not an issue just belonging to MC.Net. I think it deserves to be thought by TS Support.

About your suggestion of using IDataLoader, I was thinking about it. I was wondering if it was also affected by MaxBarsBack. It seems not, so it is probably the immediate solution for me.

Best regards.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: MaxBarsBack issue with multiple data series

Postby Henry MultiСharts » 19 Mar 2014

Hello Fabrice and JoshM,

This is a limitation of the current implementation of MaxBarsBack functionality.
Unfortunately there is no technical possibility to change this behavior at the moment.

Fabrice
Posts: 182
Joined: 14 Jun 2011
Has thanked: 44 times
Been thanked: 30 times

Re: MaxBarsBack with multiple data series

Postby Fabrice » 19 Mar 2014

6000 bars on the chart, and only 56 usable by the indicator. And that cannot be changed at the moment ! What a shame…

As you say : "Unfortunately". You could not have chosen a better word indeed…

Regards.


Return to “MultiCharts .NET”