Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error finding lowest ATR Value over X periods

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

    Error finding lowest ATR Value over X periods

    Hi guys,

    I am trying to reference the lowest ATR value over the last X days, but am getting a compile error with the MIN function. Below is the code which is used in an if statement:

    ATR(volatilityLength)[0] <= MIN(ATR(volatilityLength)[0],volatilityLength)[0]

    volatilityLength is an int variable.

    I am getting two errors for the same line, one is an overload method match, and the other is saying that it cannot convert from 'double to ninjatrader .. data series..'

    Any thoughts?

    Cheers!
    Shane

    #2
    Hello,

    Thank you for the question.

    This is because the MIN is asking for a DataSeries but is being provided a Double as you can see from this statement:

    Code:
    MIN([U]ATR(volatilityLength)[B][0][/B][/U],volatilityLength)[0])
    Instead of
    Code:
    ATR(volatilityLength)[0]
    You would need to use
    Code:
    ATR(volatilityLength)
    Here is the completed example, I created the variable volatilityLength for the example:

    Code:
    int volatilityLength = 10;
    Print(ATR(volatilityLength)[0] <= MIN(ATR(volatilityLength),volatilityLength)[0]);
    I look forward to being of further assistance.

    Comment


      #3
      Thanks Jesse, that did the trick - much appreciated!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      633 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      364 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      105 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      567 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      568 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X