What I'm actually trying to do is cumulate volume for up waves and down waves. Starting with a simple Close[0] > Close>[1] for up volume and vice versa for down volume. This works but I would like to change the previous bar, if it was a down close in an up wave. Seems simple enough, the IDataSeries class says to do this:
myDataSeries.Set(1,value)
This should change the historical value one bar ago to whatever I want. It does not work.What it does do is change the present bar to something really screwy when cumulating volume. So I reduced this using numbers for values rather then volume. Still not getting correct results.
Here is the code snippet, can you please tell me what I'm doing wrong? I replaced volume with numbers just to simplify it. The real code sets DownVolume dataseries for down waves, ie, down closes. This code below is doing some crazy things. The last if statement is the statement used to cumulate volume in an upwave.
protected override void OnBarUpdate()
{
if (CurrentBars[0] < BarsRequired)
return;
//Attempt to fix a down bar in up wave . This didn't work
// Up wave fix
if (Close[0] > Close[1]
&& Close[1] < Close[2]
&& Close[2] >= Close[3])
{
DownVolume.Set(5);
UpVolume.Set(1,20); //This should set the UpVolume 1 bar ago to 20 but it does not!!
}
if (Close[0] > Close[1] || (Close[0] == Close[1] && Close[1] > Close[2]))
{
UpVolume.Set(10);
DownVolume.Set(1);
}
Comment