I am having problem setting variables for my supplementary bar. Let me give an easy example below to show what I mean:
#region Variables
private DataSeries vol5m;
private DataSeries vol10m;
#endregion
protected override void Initialize()
{
vol5m= new DataSeries(this);
vol10m= new DataSeries(this);
Add(PeriodType.Minute, 10);
CalculateOnBarClose = true;
}
protected override void OnBarUpdate()
{
if (BarsInProgress == 0)
{
vol5m.Set(Volume[0]);
}
if (BarsInProgress == 1)
{
vol10m.Set(Volumes[1][0]);
Print("Barsinprogress 1 " + Time[0] + " " + vol10m[0] + " " + vol10m[1] + " " + vol10m[2] + " " + vol10m[3] + " " + vol10m[4] + " " + vol10m[5] + " ");
}
}
When I set the primary bar to 5 minute, here is the output:
Barsinprogress 1 22/7/2014 10:00:00 AM 4707 2101 6281 3973 9424 2779
Barsinprogress 1 22/7/2014 10:10:00 AM 6380 2569 4707 2101 6281 3973
Barsinprogress 1 22/7/2014 10:20:00 AM 4481 2947 6380 2569 4707 2101
Take the output from 10am as an example, the vol10m[0] is "4707". I expected the "4707" to become vol10m[1] when the bar was next updated at 10:10am. However, as you can see from the 10:10am output that the "4707" is actually vol10m[2].
Basically whatever number that is set as vol10m[0] will become vol10m[2] when the bar gets updated next, and then become vol10m[4] when it gets updated again. I don't know where the numbers for vol10m[1], vol10m[3], vol10m[5],... etc come from, but they should not be there. (It is easy to verify that the vol10m[1], vol10m[3] etc should not be there because I can simply plot a 10-minute chart to check the volume)
This is just a simple example to illustrate the problem I have been trying to solve for the past week. Would anyone be able to help ?
Thanks very much.
Comment