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 CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      267 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      169 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      171 views
      1 like
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      260 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      210 views
      0 likes
      Last Post CarlTrading  
      Working...
      X