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 Mindset, Today, 06:46 AM
        0 responses
        8 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, Yesterday, 05:21 PM
        0 responses
        12 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        15 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        82 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        47 views
        0 likes
        Last Post PaulMohn  
        Working...
        X