Announcement

Collapse
No announcement yet.

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.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      93 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      138 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      123 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      73 views
      0 likes
      Last Post PaulMohn  
      Working...
      X