Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Standard indicators and Indicator methods

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

    Standard indicators and Indicator methods

    Can anyone explain why the code for standard indicators like SMA in Ninja do not conform to the equivalent Indicator Method in Ninja.

    For example,

    Indicator method SMA:
    Examples



    // Prints the current value of a 20 period SMA using default price type
    double value = SMA(20)[0];
    Print("The current SMA value is " + value.ToString());

    In Ninja script for SMA however the code does not appear to use the SMA method but has the following code. Why doesn't it just use the SMA Indicator Method?

    {
    if (CurrentBar == 0)
    Value.Set(Input[
    0]);
    else
    {
    double last = Value[1] * Math.Min(CurrentBar, Period);
    if (CurrentBar >= Period)
    Value.Set((last + Input[
    0] - Input[Period]) / Math.Min(CurrentBar, Period));
    else
    Value.Set((last + Input[0]) / (Math.Min(CurrentBar, Period) + 1));
    }
    }

    #2
    The example is a usage of SMA. The code below the example is how the SMA is created.

    Comment


      #3
      Hello skiguy,

      Thank you for your post.

      Tasker is correct here, the method is SMA() and the code for the SMA is needed to actual calculate the SMA() value.

      Comment


        #4
        Thanks guys. I thought that might be the case.

        In summary, the SMA method behind the scenes uses the code shown and this also applies to other indicator methods.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        581 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        338 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        554 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        552 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X