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 NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      65 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      139 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      75 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      45 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      50 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X