Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

State.DataLoaded or State,Configue

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

    State.DataLoaded or State,Configue

    Hi

    Just to further my understanding as I study ninjascript:

    I have seen the MACD indicator written including the price series included in both State.Configure and also in State.DataLoaded

    eg
    else if (State == State.DataLoaded)
    {
    fastEma = new Series<double>(this);
    slowEma = new Series<double>(this);
    }

    or

    else if (State == State.Configure)
    {
    constant1 = 2.0 / (1 + Fast);
    constant2 = (1 - (2.0 / (1 + Fast)));
    constant3 = 2.0 / (1 + Slow);
    constant4 = (1 - (2.0 / (1 + Slow)));
    constant5 = 2.0 / (1 + Smooth);
    constant6 = (1 - (2.0 / (1 + Smooth)));

    fastEma = new Series<double>(this);
    slowEma = new Series<double>(this);
    }



    How does this change the behavior of the code written?
    thanks

    #2
    Hello fluke,

    Thanks for your post.

    When creating the Series object by syncing to the NinjaScript object using "this," the code may work the same without issues seen. As a best practice, it would be advised to create the Series object in State.DataLoaded since creating the series generally depends on data being available to synchronize with. If you used a Bars object to build the Series object in State.Configure, you would certainly run into issues.

    More information on Series<T> objects can be found here - https://ninjatrader.com/support/help...us/seriest.htm

    Information on State Management Best Practices can be found here - https://ninjatrader.com/support/help...urceManagement

    Please let us know if we can be of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    36 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    20 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    14 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    19 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    22 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X