Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Terminates on startup

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

    Strategy Terminates on startup

    Hi,

    in ninja 7 I was able to add indicators to the strategy, but if I add an indicator my strategy gets terminated without an error message, compile gives no errors as soon as I remove the lines strategy is loading again.
    m_VWAP is created and now exception is thrown.

    Regards
    Martin

    else if (State == State.DataLoaded)
    {
    this.m_VWAP = mmVWAPS(_std, bSoundOn, pSoundVWAP, m_cntPullback, m_VWAPDelta, m_PeriodType, m_VTF, true);
    AddChartIndicator(this.m_VWAP);

    }​

    #2
    Hello mmartin68,

    Is there an error appearing on the Log tab of the Control Center?

    What is the full error message?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Perhaps the indicator is trying to load an additional data series, and you didn't add it in the strategy in State.Configure.
      Bruce DeVault
      QuantKey Trading Vendor Services
      NinjaTrader Ecosystem Vendor - QuantKey

      Comment


        #4
        Hi,

        thank you for you quick response.

        yes I get an error message but I can not figure out which object is not referenced:
        03/14/23 12:33 PM Default Indicator 'mmVWAPS': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.
        Click image for larger version

Name:	image.png
Views:	131
Size:	3.3 KB
ID:	1240111

        The problem is solved when I include the OnStateChange inside a try catch.Even and I moved the creation of additional Series to the DataLoaded state instead of the Configure state.

        Thank you very much.


        Why has my strategy no performance data, if I start an ATM with StartAtmStrategy(m_curATMStrategy, entryOrder); after the Order is created. Is it because the ChartTrader manage the order?

        Is there a way to adjust the limit order of my ATM Strategy so get the Order handle?

        Regards
        Martin

        Comment


          #5
          Hello Martin,

          A try catch does not fix the problem, it simply prevents the script from disabling when there is an error.

          I would recommend finding the line of code causing the error, and removing the call to the variable with a null value.
          Hello, I keep running into an error of "Object reference not set to an instance of an object." when I set the entryOrder to Null after it has been cancelled. Below is the block of code that I found in several of the example strategies. protected override void OnOrderUpdate(Order order, double limitPrice,


          AddDataSeries() can only be called in State.Configure. You cannot call this in State.DataLoaded.


          Atm Strategy methods do not affect the strategy position or order method overrides. These are like manually submitted orders that do not affect the strategy.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Clearly, in your OnStateChange you are referencing some object that is null. You need to figure out why your OnStateChange is throwing that exception not just put it in a try catch which is simply masking the problem. Comment out your OnStateChange sections and put them back a line at a time until you isolate what is happening there.
            Bruce DeVault
            QuantKey Trading Vendor Services
            NinjaTrader Ecosystem Vendor - QuantKey

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, 03-13-2026, 05:17 AM
            0 responses
            86 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            151 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            79 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            53 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            61 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X