Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by alifarahani, Today, 09:40 AM
    6 responses
    36 views
    0 likes
    Last Post alifarahani  
    Started by Waxavi, Today, 02:10 AM
    1 response
    17 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Started by Kaledus, Today, 01:29 PM
    5 responses
    14 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by Waxavi, Today, 02:00 AM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Started by gentlebenthebear, Today, 01:30 AM
    3 responses
    17 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X