• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Series<T> Instantiation in OnStateChange() State == State.Configure Vs. DataLoaded?

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

    Series<T> Instantiation in OnStateChange() State == State.Configure Vs. DataLoaded?

    Hello,

    Either the NT8 help documentation is inconsistent with itself regarding where a Series<T> should be instantiated, or perhaps the answer is "it depends".

    On the main NT8 "OnStateChange()" documentation page (https://ninjatrader.com/support/help...tatechange.htm), the grid row for "State.Historical" has the following bullet point under the column "this is where you should":

    "Initialize any class level variables (including custom Series<T> objects)"

    However, on the "NinjaScript Best Practices" page ( https://ninjatrader.com/support/help..._practices.htm ), under the "State management practices" header, it recommends that a Series<T> be instantiated in the "else if (State == State.DataLoaded)" if/else branch:

    Code:
      else if (State == State.DataLoaded)
      {
        // Since these values do are dependent on bars, they should only reset during State.DataLoaded
        mySMAIndicator = SMA(14);
        mySeries = new Series<double>(this);
      }
    Also, the NT8 Strategy Builder instantiates Series<T> objects in the DataLoaded if/else branch. Here's an example from a strategy I created in the NT8 Strategy Builder:

    HTML Code:
    			else if (State == State.DataLoaded)
    			{				
    				MyDataSeries = new Series<double>(this);			
    			}
    When should a Series<T> object be instantiated in the "else if (State == State.DataLoaded)" section?

    When should a Series<T> object be instantiated in the "else if (State == State.Historical)" section?


    Thank you very much in advance,

    EquityTrader

    #2
    Hello,

    It's been over a day and a half since I asked the question below.

    Can anyone from NinjaTrader give an official ruling on which official NinjaScript documentation is right and which is wrong by answering the question in my previous post below?

    Based on your answer, the Strategy Builder may also need a change, but at the very least, either your "NinjaScript Best Practices" page or your "OnStateChange()" will need to be edited.

    Thank you very much,

    EquityTrader

    Comment


      #3
      Hello EquityTrader,

      Thank you for your patience.

      The Best Practices would be correct here. Thank you for bringing this to our attention I will forward this to our Product Management team.
      Patrick H.NinjaTrader Customer Service

      Comment


        #4
        Hi NinjaTrader_Patrick,

        Thank you very much for your help.

        Per your advice, I will instantiate all Series<T> objects in "else if (State == State.DataLoaded)" (per the NinjaScript Best Practices page and the Strategy Builder output) instead of in "else if (State == State.Historical)" (per the OnStateChange() page).

        Thanks again,

        EquityTrader

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by ATMtrader0001, Today, 01:48 PM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_PaulH  
        Started by RandanAL, Yesterday, 05:13 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Kate  
        Started by JustinCross, Today, 02:11 PM
        0 responses
        8 views
        0 likes
        Last Post JustinCross  
        Started by Uwe1981, Today, 03:41 AM
        3 responses
        22 views
        0 likes
        Last Post NinjaTrader_Kate  
        Started by maxie, Today, 11:43 AM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Monica  
        Working...
        X