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

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
    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by zstheorist, Today, 07:52 PM
    0 responses
    3 views
    0 likes
    Last Post zstheorist  
    Started by pmachiraju, 11-01-2023, 04:46 AM
    8 responses
    149 views
    0 likes
    Last Post rehmans
    by rehmans
     
    Started by mattbsea, Today, 05:44 PM
    0 responses
    5 views
    0 likes
    Last Post mattbsea  
    Started by RideMe, 04-07-2024, 04:54 PM
    6 responses
    33 views
    0 likes
    Last Post RideMe
    by RideMe
     
    Started by tkaboris, Today, 05:13 PM
    0 responses
    5 views
    0 likes
    Last Post tkaboris  
    Working...
    X