I've created a custom bar type, it seems to be working fine. But I'm running into a problem trying to create a strategy that uses this bar type. I'd like to create an object of the custom bar type so I can reference it in my script. I'm using the reference code for OrderFlow Volumetric bars as a loose guide for this but I can't get it to work for my custom type, the object is always NULL.
The Volumetric Bars reference code looks like this:
protectedoverridevoidOnBarUpdate()
{
if (Bars==null)
return;
// This sample assumes the Volumetric series is the primary DataSeries on the chart, if you would want to add a Volumetric series to a
NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pebarsType=Bars.BarsSeries.BarsTypeas
NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;
if (barsType==null)
return;
}
--------------------------------------------------------------------------------------
My code looks like this:
if (Bars == null)
return;
// attempt to cast the bars object as Imbalance bars, if cast fails, then it's not an imbalance bar
NinjaTrader.NinjaScript.BarsTypes.FixedDollarImbBa rs imbalanceType = Bars.BarsSeries.BarsType as NinjaTrader.NinjaScript.BarsTypes.FixedDollarImbBa rs;
if ( imbalanceType == null )
imbalanceCheck = false;
else
imbalanceCheck = true;
But this cast never works, my object is always NULL. Can you fill me in on why it's not working?
Thanks
Comment