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 AaronKoRn, Today, 09:49 PM
      0 responses
      4 views
      0 likes
      Last Post AaronKoRn  
      Started by carnitron, Today, 08:42 PM
      0 responses
      8 views
      0 likes
      Last Post carnitron  
      Started by strategist007, Today, 07:51 PM
      0 responses
      9 views
      0 likes
      Last Post strategist007  
      Started by StockTrader88, 03-06-2021, 08:58 AM
      44 responses
      3,975 views
      3 likes
      Last Post jhudas88  
      Started by rbeckmann05, Today, 06:48 PM
      0 responses
      9 views
      0 likes
      Last Post rbeckmann05  
      Working...
      X