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

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.
    JesseNinjaTrader Customer Service

    Comment


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

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by junkone, Today, 11:37 AM
      0 responses
      2 views
      0 likes
      Last Post junkone
      by junkone
       
      Started by quantismo, 04-17-2024, 05:13 PM
      5 responses
      34 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by proptrade13, Today, 11:06 AM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Started by love2code2trade, 04-17-2024, 01:45 PM
      4 responses
      34 views
      0 likes
      Last Post love2code2trade  
      Started by cls71, Today, 04:45 AM
      2 responses
      10 views
      0 likes
      Last Post eDanny
      by eDanny
       
      Working...
      X