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

On NT's EMA code

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

    On NT's EMA code

    Hi NT experts,

    I need help to understand the logic of official NT EMA code:
    Value.Set(CurrentBar == 0 ? Input[0] : Input[0] * (2.0 / (1 + Period)) + (1 - (2.0 / (1 + Period))) * Value[1]);

    Is it equivalent to:
    if (CurrentBar ==0)
    {
    Value.Set(Input(0));
    }
    else
    {
    Value.Set(Input[0] * (2.0 / (1 + Period)) + (1 - (2.0 / (1 + Period))) * Value[1]);
    }
    In other words, the formular applies to all bras except for the 1st bar?
    Any suggestions are welcome.


    #2
    binwang2, correct on the first bar assign the Input value, on the following bars, calculate the EMA values as per the standard formula.
    BertrandNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by WHICKED, Today, 02:02 PM
    0 responses
    2 views
    0 likes
    Last Post WHICKED
    by WHICKED
     
    Started by selu72, Today, 02:01 PM
    0 responses
    0 views
    0 likes
    Last Post selu72
    by selu72
     
    Started by f.saeidi, Today, 12:14 PM
    8 responses
    21 views
    0 likes
    Last Post f.saeidi  
    Started by Mikey_, 03-23-2024, 05:59 PM
    3 responses
    49 views
    0 likes
    Last Post Sam2515
    by Sam2515
     
    Started by Russ Moreland, Today, 12:54 PM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_Erick  
    Working...
    X