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

Compile TSSuperTrend Indicator in Strategy

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

    Compile TSSuperTrend Indicator in Strategy

    I'm trying to get the value of the TSSuperTrend indicator as:

    super_trend = TSSuperTrend(Median,14,HMA,2.618,14,ATR)[0];

    or
    super_trend = TSSuperTrend(14,HMA,2.618,14,ATR)[0];

    The first method is as it is called as an indicator. The second is the method shown by the compiler.

    The compiler gives me the error message in the attached jpg. The error relates to the HMA and ATR calls.

    How can I make this work?

    Thanks!

    Larry
    Attached Files

    #2
    include the following line at the top of your script:

    using TradingStudies.NinjaScript.Utility;

    and

    replace HMA with MovingAverageType.HMA

    replace ATR with SuperTrendMode.ATR

    Comment


      #3
      Thanks!

      Roonius,
      Thanks very much! I appreciate the help!

      It seems, to me anyway, that there are many nooks and crannies hidden in NT that make it hard for a "Level 2 player" to navigate through the code, like this one.

      Is there a reference that exposes more of the hidden areas?

      Thanks again!

      Larry

      Comment


        #4
        Larry,

        This is not NinjaTrader specific. It is due to the 3rd party code you are using and as such usage can vary depending on who writes it.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Josh and Roonius,

          I appreciate the help!

          The next baby step involves what seems to be memory leakage when I call the indicator from my strategy.

          I load the two values of the lines and the bool trend into my strategy from:

          up_trend = TSSuperTrend(14,MovingAverageType.HMA,2.618,14,Sup erTrendMode.ATR).UpTrend[0];

          down_trend = TSSuperTrend(14,MovingAverageType.HMA,2.618,14,Sup erTrendMode.ATR).DownTrend[0];

          trend_up = TSSuperTrend(14,MovingAverageType.HMA,2.618,14,Sup erTrendMode.ATR).Trend[0];

          These are inside a "if (FirstTickOfBar)" statement, so I only get these once per bar.

          With these statements included in my strategy, it takes my i7 3GHz CPU with 3GB RAM running Vista about 30 seconds to load my strategy with 5 minute candles and 15 days of historical data. Without the statements, it takes the machine less than a second to load the strategy.

          The instructions consume about 500MB of additional RAM. I can watch the available memory disappear as the strategy is attempting to load. If I recompile and reload the strategy, the first load does not release the memory it took. The second load continues to take memory until I get an "out-of-memory" message.

          The TSSuperTrend indicator has remarkable potential when used in a momentum based strategy. I don't think I can use it as is imagining money on the table and the computer running out of memory.

          Is there a reason for the high memory use when the indicator variables are ported into a strategy? Am I doing something that causes this? Can it be stopped?

          Thanks again very much!

          Larry
          Last edited by epcompany; 05-30-2009, 08:30 AM.

          Comment


            #6
            Hello,

            I will have Josh reply on Monday.
            DenNinjaTrader Customer Service

            Comment


              #7
              Originally posted by epcompany View Post
              Josh and Roonius,

              I appreciate the help!

              The next baby step involves what seems to be memory leakage when I call the indicator from my strategy.

              I load the two values of the lines and the bool trend into my strategy from:

              up_trend = TSSuperTrend(14,MovingAverageType.HMA,2.618,14,Sup erTrendMode.ATR).UpTrend[0];

              down_trend = TSSuperTrend(14,MovingAverageType.HMA,2.618,14,Sup erTrendMode.ATR).DownTrend[0];

              trend_up = TSSuperTrend(14,MovingAverageType.HMA,2.618,14,Sup erTrendMode.ATR).Trend[0];

              These are inside a "if (FirstTickOfBar)" statement, so I only get these once per bar.

              With these statements included in my strategy, it takes my i7 3GHz CPU with 3GB RAM running Vista about 30 seconds to load my strategy with 5 minute candles and 15 days of historical data. Without the statements, it takes the machine less than a second to load the strategy.

              The instructions consume about 500MB of additional RAM. I can watch the available memory disappear as the strategy is attempting to load. If I recompile and reload the strategy, the first load does not release the memory it took. The second load continues to take memory until I get an "out-of-memory" message.

              The TSSuperTrend indicator has remarkable potential when used in a momentum based strategy. I don't think I can use it as is imagining money on the table and the computer running out of memory.

              Is there a reason for the high memory use when the indicator variables are ported into a strategy? Am I doing something that causes this? Can it be stopped?

              Thanks again very much!

              Larry
              I am aware of this, and looking what is causing the trouble.
              Will keep you updated as soon as I find the solution

              Comment


                #8


                You can download updated version (2.1) there

                Comment


                  #9
                  Roonius,
                  Thank you very much for V2.1! I ran it all weekend starting and stopping and recompiling, etc. After a VERY long (comparative) time, my machine bogged down with memory problems but this version is far superior to the previous version in terms of memory usage. It is now useful and trust worthy for real-time trading. I appreciate it and you!

                  I'm sure you understand the power of your indicator relative to price movement: it indicates when you have an advantage trading, it tells you when to stay out, and it is tunable for one's personal risk tolerance. I combined your indicator with PSAR and have made a very powerful trading tool. I hope to owe you a dinner for you and a guest at the Top of the Mark in SF by-and bye.

                  Larry

                  PS: One other item. If I call the indicator for bar [0], it returns zero for the two trend values and false for the trend. I only get legitimate values if I run it from bar [1]. I call it on the first tick of bar [0]. If I could push the values up one bar to bar [0], that would be even better.

                  Here are the strategy lines:

                  up_trend_value = TSSuperTrend(14,MovingAverageType.HMA,2.618,14,SuperTrendMode.ATR).UpTrend[1];
                  down_trend_value = TSSuperTrend(
                  14,MovingAverageType.HMA,2.618,14,SuperTrendMode.ATR).DownTrend[1];
                  trend_up_indicator = TSSuperTrend(
                  14,MovingAverageType.HMA,2.618,14,SuperTrendMode.ATR).Trend[1];

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by prdecast, Today, 06:07 AM
                  1 response
                  4 views
                  0 likes
                  Last Post NinjaTrader_LuisH  
                  Started by Christopher_R, Today, 12:29 AM
                  1 response
                  13 views
                  0 likes
                  Last Post NinjaTrader_LuisH  
                  Started by chartchart, 05-19-2021, 04:14 PM
                  3 responses
                  577 views
                  1 like
                  Last Post NinjaTrader_Gaby  
                  Started by bsbisme, Yesterday, 02:08 PM
                  1 response
                  15 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by i019945nj, 12-14-2023, 06:41 AM
                  3 responses
                  60 views
                  0 likes
                  Last Post i019945nj  
                  Working...
                  X