The problem is that when i use futures such as FDAX or FDXS the strategy works perfectly without any error, when i use other futures such ask RTY 3 22 it gives me the error Object reference not set to an instance of an object.
Trying with the RTY 12 21 it doesn't give me any error? what could it be?
this is the code : the bar in progress is :
else if (State == State.Configure)
{
AddVolumetric(Instrument.FullName, BarsPeriodType.Tick, 1, VolumetricDeltaType.BidAsk, 1);
}
if ( BarsInProgress == 1)
{
NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = Bars.BarsSeries.BarsType as NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;
double price;
double buyVol = barsType.Volumes[CurrentBar].TotalBuyingVolume;
double sellVol = barsType.Volumes[CurrentBar].TotalSellingVolume;
if (Position.GetUnrealizedProfitLoss(PerformanceUnit. Ticks) > m_tikTrailing*TickSize && firstTrail)
{
SetStopLoss(CalculationMode.Ticks, 0 );
firstTrail = false;
}
if (Position.MarketPosition == MarketPosition.Flat)
{
if (m_orderSizeMin < Math.Abs(sellVol) || m_orderSizeMin < Math.Abs(buyVol))
{
if (buyVol - sellVol > 0 && Math.Abs(buyVol) > m_orderSizeMin)
{
firstTrail = true;
m_marketHint = MyEnum.LONG;
SetProfitTarget(CalculationMode.Ticks, m_TakeProfitMAX);
SetStopLoss(CalculationMode.Ticks, m_StopLossMAX);
var result2 = EnterLong();
Print("long " + result2.ToString());
}
else if (buyVol - sellVol < 0 && Math.Abs(sellVol) > m_orderSizeMin)
{
firstTrail = true;
m_marketHint = MyEnum.SHORT;
SetProfitTarget(CalculationMode.Ticks, m_TakeProfitMAX);
SetStopLoss(CalculationMode.Ticks, m_StopLossMAX);
var result3 = EnterShort();
Print("short " + result3.ToString());
}
}
m_marketHint = MyEnum.FLAT;
}
Comment