Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Where to initialize TickSize-based stuff ?

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

    Where to initialize TickSize-based stuff ?

    Hi,
    Documentation states it's forbidden to access TickSize in OnStateChange.
    NinjaScript > Language Reference > Common > Data > TickSize

    "NOTE: This property should NOT be accessed within the OnStateChange() method."


    So how is it possible to initialize something using the TickSize ? I used to do it in OnStartUp(), but now in NT 8 ?

    Do we need to wait for a OnBarUpdate or a OnMarketData and do things like :
    Code:
    if (!tickinited)
    { 
         invTickSize = 1.0f /  Bars.Instrument.MasterInstrument.TickSize;
         tickinited=true;
    }
    It seems the TickSize should be available somewhere in the initialization process, shouldn't it ?

    #2
    You can access this property in OnStateChange() in anything >= State.Configure.

    I just now had the help guide updated to simply warn not to access this from State.SetDefaults.

    Thanks for pointing that out.
    MatthewNinjaTrader Product Management

    Comment


      #3
      That's what I was doing, actually, but it worked, until it stopped working with exception caused by Bars being null.
      Than restarted Ninja and working again. And then exception, so restarted etc...

      So I guessed I wasn't doing it correctly.
      Will restore the code in the onstatechange and see how goes.

      Comment


        #4
        I see. The bars should be ready by the time the indicator/strategy is configured, but to be safe, you should probably access this property in State.DataLoad / State.Historical, which should ensure the bars have been loaded.

        If you do isolate an area where bars were null from State.Configure, please do let us know so we can look into that.
        MatthewNinjaTrader Product Management

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        650 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        370 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        109 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        574 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        577 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X