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