Background: Trying to use some OF methods but am confused why some methods working well others don't. The code (strategy code) is run on a Volumetric chart. Below is my simplified codes:
protected override void OnBarUpdate()
{
double poc;
long bv, av;
NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe ofBars = Bars.BarsSeries.BarsType as NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;
if (State == State.Realtime)
{
if (kbTest){
kbTest=false;
ofBars.Volumes[CurrentBar].GetMaximumVolume(null, out poc);
Print("poc at "+poc.ToString());
try{
bv=ofBars.Volumes[CurrentBar].GetBidVolumeForPrice(Close[0]);
av=ofBars.Volumes[CurrentBar].GetAskVolumeForPrice(Close[0]);
Print(string.Format("bv={0} av={2}",bv,av));
}
catch(Exception e){
Print(e.Message);
}
}
}
} //============ End of code
The bool var kbTest is set via keyboard. So when I press my KB key, the print output I get is:
poc at 2796.25
Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
.. which means the GetMaximumVolume is working (poc value tally with the chart display) but why the other OF methods generating exception? In the error print above, what is the "argument list"?
Pls help me overcome this issue. Thanks,
Tiang
Comment