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

Adjusting EMA not only at State == State.DataLoaded

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

    Adjusting EMA not only at State == State.DataLoaded

    Hi everybody,

    is it possible to adjust the EMA not only at the beginning of the programm?
    If i attach an EMA to a ninjascript strategy i´ll get following code:

    Code:
    else if (State == State.DataLoaded)
    {
    EMA1 = EMA(Close, Convert.ToInt32(EMAValue);
    }
    So if i´ve understood this right, this piece of code will be only once called (at the beginning of the programm).

    Is there a possibility to change the value of the EMA while the programm is running?

    #2
    Hello debleded,

    Thanks for your post.

    That is correct. State.DataLoaded is called only once after all data series have been loaded.

    See this help guide for more information: https://ninjatrader.com/support/help...tatechange.htm

    You could change the value of the EMA in your script by assigning a different value for your EMA variable in OnBarUpdate().

    For example, if you would like to set the EMA to calculate using a period of 5 then in OnBarUpdate() you could call something like EMA1 = EMA(Close, 5);. Now EMA1 is calculated with a period of 5 instead of the initial period that was assigned to it.

    Let us know if we may further assist.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Thank you for the answer!
      This makes absolute sense.

      So i just define EMA1 new in the OnBarUpdate() Method.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by geddyisodin, 04-25-2024, 05:20 AM
      8 responses
      58 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by jxs_xrj, 01-12-2020, 09:49 AM
      4 responses
      3,285 views
      1 like
      Last Post jgualdronc  
      Started by Option Whisperer, Today, 09:55 AM
      0 responses
      5 views
      0 likes
      Last Post Option Whisperer  
      Started by halgo_boulder, 04-20-2024, 08:44 AM
      2 responses
      22 views
      0 likes
      Last Post halgo_boulder  
      Started by mishhh, 05-25-2010, 08:54 AM
      19 responses
      6,189 views
      0 likes
      Last Post rene69851  
      Working...
      X