Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding a line to current StdDev indicator

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

    Adding a line to current StdDev indicator

    I am new to NinjaScript. I would like to modify the current StdDev indicator so as to include a line of max value for a period of "lookBackPeriod". I added the following codes under "protected override void OnBarUpdate()" else section:-

    if (Value[0] > MAX(maxHigh, lookBackPeriod-1)) {maxHigh[0] = Value[0];}
    else {maxHigh[0] = maxHigh[1];}

    where Value[0] is the calculated value of current StdDev and maxHigh is a series I added to hold the max StdDev values over a specific period.

    However, I got an error as follows:-

    Operator '>' cannot be applied to operands of type 'double' and 'NinjaTrader.NinjaScript.Indicators.MAX

    Can anyone help? Thankssssssssss.

    #2
    Hello atman,

    Thanks for your post.

    It looks like you are missing the bars ago index for the MAX() method.
    If you are wanting to use the current bar value then:

    if (Value[0] > MAX(maxHigh, lookBackPeriod-1)[0])
    {
    maxHigh[0] = Value[0];
    }
    else
    {
    maxHigh[0] = maxHigh[1];
    }


    Reference: https://ninjatrader.com/support/help...aximum_max.htm

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    563 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    329 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    547 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    548 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X