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 ETFVoyageur, Yesterday, 07:05 PM
    5 responses
    41 views
    0 likes
    Last Post ETFVoyageur  
    Started by jpeep, 08-16-2020, 08:31 AM
    13 responses
    487 views
    0 likes
    Last Post notenufftime  
    Started by realblubb, 04-28-2024, 09:28 AM
    2 responses
    32 views
    0 likes
    Last Post realblubb  
    Started by bmarovets, Today, 06:33 PM
    0 responses
    12 views
    0 likes
    Last Post bmarovets  
    Started by JGriff5646, Yesterday, 10:02 PM
    2 responses
    24 views
    0 likes
    Last Post JGriff5646  
    Working...
    X