Data stream #2 not displayed by indicator  [SOLVED]

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

Data stream #2 not displayed by indicator

Postby Fabrice » 11 Jul 2013

A chart has 2 data streams (same symbol) :
- datastream1 is 5 min
- datastream2 is daily
I dont understand why this code does not display the daily close. It is always the 5-min bar close. It is as if the datastream number (i.e. "new VariableSeries<double>( this, 0, 2 )" or "new VariableSeries<double>( this, 0, 1 )") has no effect.
Regards.

Code: Select all

namespace PowerLanguage.Indicator{
public class fp_test_datastream2 : IndicatorObject {

VariableSeries<double> series_var;

public fp_test_datastream2(object _ctx):base(_ctx){}
private IPlotObject plot1;
protected override void Create() {
// create variable objects, function objects, plot objects etc.
plot1 = AddPlot(new PlotAttributes("", EPlotShapes.Line, Color.Red));

series_var = new VariableSeries<double>( this, 0, 2 );

}
protected override void StartCalc() {
// assign inputs
}
protected override void CalcBar(){
// indicator logic
series_var.Value = Bars.Close[0];
plot1.Set( series_var[0] );
}
}
}

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

Re: Data stream #2 not displayed by indicator

Postby Henry MultiСharts » 12 Jul 2013

Hello Fabrice,

Is "Update on every tick" enabled for your indicator in Format->Study->Format?
What is the state of "Realtime history matching" option?

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

Re: Data stream #2 not displayed by indicator

Postby Fabrice » 12 Jul 2013

"series_var = new VariableSeries<double>( this, 0, 2 );" seems really buggy. Based on the code given in my previous post :
- series_var[0] gives datastream_1 (5-min bar) in real time, instead of daily[0] (the daily close in real-time)
- series_var[1] gives daily[2] instead of daily[1]
- series_var[2] gives daily[3] instead of daily[2]

So the bugs concern all indexes of series_var :
- series_var[0] points to the bad datastream (ds1 instead of ds2)
- series_var[1..n] : points to the good datastream but on the bad index (!...)
daily[0] and daily[1] are not accessible.

To verify: create 3 plots (plot1 displays series_var[0], plot2 the series_var[1], plot3 the series_var[2]).

Everything is ok if series_var is created with data stream 1, i.e. "series_var = new VariableSeries<double>( this, 0, 1 )".

I hope you (MC.Net support) will confirm and correct this quickly. I have (again) lost 2 days of work debugging MC (yes that reminds me a certain thread here...), and this bug prevents me from writing my indicators. As I am not an expert in C#, I hope I do not miss something obvious.
Regards.

PS: hopefully, this bug seems not to affect signals, only indicators.
Last edited by Fabrice on 13 Jul 2013, edited 2 times in total.

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

Re: Data stream #2 not displayed by indicator

Postby Fabrice » 12 Jul 2013

Hello Henry,
Here are the properties of the indicator.
Screen Shot 2013-07-12 at 4.14.26 PM.png
(32.84 KiB) Downloaded 980 times

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

Re: Data stream #2 not displayed by indicator  [SOLVED]

Postby Henry MultiСharts » 19 Jul 2013

Hello Fabrice,

There is no bug.

Code: Select all

series_var = new VariableSeries<double>( this, 0, 1 );
series_var = new VariableSeries<double>( this, 0, 2 );
This code defines which data series will be used to fix the variable values.

In order to get the values of data series 2 you need to use the following code:

Code: Select all

series_var.Value = BarsOfData(2).Close[0];
This functionality is described in MultiCharts .Net Programming Guide: 4.2_Data_Access and in MC .Net FAQ.

If you want to get the realtime values from both data streams "Realtime history matching" option should be disabled for your case.


Return to “MultiCharts .NET”