Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Null object reference order flow

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Null object reference order flow

    Hi, I'm trying to develop a strategy for different types of futures thinking that they are all the same.
    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;
    }


    #2
    Hi Alessio, thanks for posting.

    Please first use Visual Studio debugging to find the exact line where the exception is occurring. When you run visual studio and attach to the NinjaTrader process it will stop at the line that caused this exception.



    I look forward to hearing of your results.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    38 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    124 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    64 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    41 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X