Can you tell from this what's wrong?
if (CurrentBar > activeBar)
{
previousVol = 0; // reset all variables
buys = 0;
sells = 0;
activeBar = CurrentBar;
}
else
{
//Calculate the volume traded since the last update
double tradeVol = previousVol == 0 ? Volume[0] : Volume[0] - previousVol;
//Determine if the volume increase was on the bid or ask
if (Close[0] >= GetCurrentAsk())
buys += tradeVol;
else if (Close[0] <= GetCurrentBid())
sells += tradeVol;
netVol = buys - sells; //Get the net volume
previousVol = Volume[0]; //Update the volume
}
SpreadOpen.Set(0); //Want all bars to start at the zero line
SpreadClose.Set(netVol); //The bar should track and close on the net volume
SpreadHigh.Set(buys); // plot the total buy vol above the line
SpreadLow.Set(-1*sells); //Plot the total sell vol below the line
}
Comment