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 inanazsocial, Today, 01:15 AM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by rocketman7, Today, 02:12 AM
      0 responses
      10 views
      0 likes
      Last Post rocketman7  
      Started by dustydbayer, Today, 01:59 AM
      0 responses
      1 view
      0 likes
      Last Post dustydbayer  
      Started by trilliantrader, 04-18-2024, 08:16 AM
      5 responses
      23 views
      0 likes
      Last Post trilliantrader  
      Started by Davidtowleii, Today, 12:15 AM
      0 responses
      3 views
      0 likes
      Last Post Davidtowleii  
      Working...
      X