• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by rafaelabe1977, Today, 03:51 AM
    1 response
    9 views
    0 likes
    Last Post sledge
    by sledge
     
    Started by jenifeery79, Today, 05:03 AM
    0 responses
    4 views
    0 likes
    Last Post jenifeery79  
    Started by rexmie888, Today, 04:00 AM
    0 responses
    6 views
    0 likes
    Last Post rexmie888  
    Started by terminatorT1000, Yesterday, 06:40 PM
    1 response
    16 views
    0 likes
    Last Post NT-Roland  
    Started by cmarkb, Today, 02:15 AM
    4 responses
    16 views
    0 likes
    Last Post cmarkb
    by cmarkb
     
    Working...
    X