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 Barry Milan, Today, 10:35 PM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by WeyldFalcon, 12-10-2020, 06:48 PM
    14 responses
    1,428 views
    0 likes
    Last Post Handclap0241  
    Started by DJ888, Yesterday, 06:09 PM
    2 responses
    9 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by jeronymite, 04-12-2024, 04:26 PM
    3 responses
    40 views
    0 likes
    Last Post jeronymite  
    Started by bill2023, Today, 08:51 AM
    2 responses
    16 views
    0 likes
    Last Post bill2023  
    Working...
    X