I want to store the close of the 1st 5 min bar in a daily VariableSeries, first5MClose :
first5MClose[0] = the close of the 1st 5-min bar of today
first5MClose[1] = the close of the 1st 5-min var of yesterday
etc.
But this does not work. first5MClose[0] should not change of value during the session but it does. Strange (see snapshot). Something is wrong, but what ?
The main data stream is a tick chart. The 2nd data stream is the 5 min bar. The 3rd is the daily bar.
Thanks.
Here is the code
Code: Select all
private VariableSeries<double> first5MClose;
protected override void Create() {
DataStream5M = 2;
DataStreamDaily = 3;
first5MClose = new VariableSeries<double>(this, 0, 3);
plot3 = AddPlot(new PlotAttributes("First5MClose", EPlotShapes.Cross, Color.Blue));
}
protected override void StartCalc() {
dailyDS = BarsOfData(DataStreamDaily);
fiveMinDS = BarsOfData(DataStream5M);
}
protected override void CalcBar(){
Boolean cond1 = fiveMinDS.TimeValue.Hour == fiveMinDS.Sessions.First().StartTime.Hours;
Boolean cond2 = fiveMinDS.TimeValue.Minute == 5;
Boolean cond = cond1 && cond2;
if (cond)
first5MClose.Value = fiveMinDS.CloseValue;
plot3.Set(first5MClose[0]);
}