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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    81 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    64 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    68 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    55 views
    0 likes
    Last Post CarlTrading  
    Working...
    X