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 Hwop38, 05-04-2026, 07:02 PM
        0 responses
        164 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        318 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        246 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        350 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        179 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Working...
        X