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

Question about source code for ATR

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

    Question about source code for ATR

    I've been looking through the source code for the various indicators included with NT to learn the NT API, best practices, and to learn more about C# (I have a background in C and Java). There seems to be a pattern in the constructor for many of the indicators where a member variable is set to a parameter followed immediately by setting the parameter to the same member variable. I'm trying to understand why the second statement is necessary.

    Here's an excerpt of the ATR source for reference (...\My Documents\NinjaTrader 6.5\bin\Custom\Indicator\@ATR.cs):
    Code:
            private ATR[] cacheATR = null;
            private static ATR checkATR = new ATR();
    
            /// <summary>
            /// The Average True Range (ATR) is a measure of volatility. It was introduced by Welles Wilder in his book 'New Concepts in Technical Trading Systems' and has since been used as a component of many indicators and trading systems.
            /// </summary>
            /// <returns></returns>
            public ATR ATR(Data.IDataSeries input, int period)
            {
                checkATR.Period = period;
                period = checkATR.Period;
    Why is the last line necessary?

    Thanks,
    Erik P

    #2
    Hi Erik,

    You should never change anything in that region of the code. That region is automatically generated and is unfortunately outside the scope of what we can offer support for.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      I had the same thought. Its because "checkATR.Period" *may* have some code in its initializer that verifies the input. For example, "1" being the minimum size for an int input.

      Comment


        #4
        Originally posted by Gumphrie View Post
        I had the same thought. Its because "checkATR.Period" *may* have some code in its initializer that verifies the input. For example, "1" being the minimum size for an int input.
        Gumphrie,

        Thanks. That makes sense.

        Cheers,
        Erik

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by kaywai, 09-01-2023, 08:44 PM
        5 responses
        601 views
        0 likes
        Last Post NinjaTrader_Jason  
        Started by xiinteractive, 04-09-2024, 08:08 AM
        6 responses
        22 views
        0 likes
        Last Post xiinteractive  
        Started by Pattontje, Yesterday, 02:10 PM
        2 responses
        16 views
        0 likes
        Last Post Pattontje  
        Started by flybuzz, 04-21-2024, 04:07 PM
        17 responses
        230 views
        0 likes
        Last Post TradingLoss  
        Started by agclub, 04-21-2024, 08:57 PM
        3 responses
        17 views
        0 likes
        Last Post TradingLoss  
        Working...
        X