if someone knows what's going wrong with this code....
#region Variables
privateint activeBar = -1;
private System.Collections.ArrayList alBuys = new System.Collections.ArrayList();
private System.Collections.ArrayList alSells = new System.Collections.ArrayList();
privatedouble lastPrice = 0.0;
privateint buys = 0;
privateint sells = 0;
#endregion
protectedoverridevoid Initialize()
{
Add(new Plot(new Pen(Color.Lime, 6), PlotStyle.Bar, "Buys"));
Add(new Plot(new Pen(Color.Red, 6), PlotStyle.Bar, "Sells"));
Add(new Line(Color.Gold, 0, "Zero Line"));
CalculateOnBarClose = false;
DisplayInDataBox = true;
Overlay = false;
PriceTypeSupported = false;
PlotsConfigurable = true;
}
protectedoverridevoid OnBarUpdate()
{
if (CurrentBar < activeBar)
{
Values[0].Set((double)alBuys[CurrentBar]);
Values[1].Set(-(double)alSells[CurrentBar]);
return;
}
elseif (CurrentBar != activeBar)
{
alBuys.Insert(Math.Max(activeBar, 0), Historical ? 0 : buys);
alSells.Insert(Math.Max(activeBar, 0), Historical ? 0 : sells);
buys = 0;
sells = 0;
activeBar = CurrentBar;
}
else
{
Values[0].Set(buys);
Values[1].Set(-sells);
}
}
protectedoverridevoid OnMarketData(MarketDataEventArgs e)
{
if (e.MarketDataType == MarketDataType.Last)
{
lastPrice = e.Price;
// Buys : >= Ask
if (lastPrice >= e.MarketData.Ask.Price)
{buys += e.Volume;}
// Sells : <= Bid
elseif (lastPrice <= e.MarketData.Bid.Price)
{sells += e.Volume;}
}
}
}
}
Comment