Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT 6.5 Strategy question

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

    NT 6.5 Strategy question

    Hi,

    I am newbie so I apologize in advance for my simple question.

    I would like to create an autotrader for the tssupertrend. I have managed to get the indicator ( a striped down version of TSSupertrend without all the of choices just the bare necessities) attached to the strategy. I am placing print statements to see what values are being returned by the indicator to the Strategy. It appears i can see, in the strategy, a number of the plotted variables (via the Print Statement) but not the internal dataseries.

    In other autotrader examples I have seen this section added....
    in the properties section (where the parameters are specified) of the indicator:
    [Browseable(false)]
    [XmlIgnore()]

    public DataSeries st_ATM_Series
    { get {Update();
    return ST_ATM_SERIES }
    }

    print statements in the indicator show the correct values of the DataSeries ( as i can see them in the Output Window for the indicator when run without the strategy ).

    However the print statements in the Strategy always return Zero for the passed DataSeries.
    I am using the following syntax to do the print in the strategy ( in the onbarupdate):

    Print("(sT_ATM_Series[0]="+XX_TSSuperTrend(10, 2.01, 14).sT_ATM_Series[0]);

    However, these Print statements return the correct values in the Strategy and the indicator

    Print("UpTrend = "+XX_TSSuperTrend( 10, 2.01, 14).UpTrend[0].ToString("0.00"));
    Print("DnTrend = "+XX_TSSuperTrend( 10, 2.01, 14).DownTrend[0].ToString("0.00"));
    Print("Close = "+Close[0].ToString("0.00"));


    Could someone kindly provide some direction....

    Thank you kindly in advance

    Regards

    Sam

    #2
    Hello SammyC,

    It looks like you're having difficulty exposing the value of sT_ATM_Series[0] accessed from within a strategy.

    The snippet you posted is needed for this and the reference sample below can help with setting this up.
    This reference sample provides help on exposing indicator values that are not plots.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Ryan

      Thank you for your extremely quick reply.
      I have reviewed the code snippet you sent.
      I now believe the problem may be in the indicator not the strategy.

      I am using a DataSeries rather than a BoolSeries but it should be the same principle.

      i do not require and exposed variable.
      I wish to just pass the DataSeries.

      I note one difference in the example you provided.
      My code uses:

      public DataSeries sT_ATM_Series
      ( get {update(); return ST_ATM_Series }
      }

      rather than

      public DataSeries sT_ATM_Series
      ( get { return ST_ATM_Series }
      }

      with is in the code snippet

      Could this be where my problem lies?
      I am unable to get it to work either way.

      I know the values are correct going into
      sT_ATM_Series as a print statement at the bottom of onbarupdate confirms it.

      I do the update by using one of the following:
      sT_ATM_Series.Set(1);
      or
      sT_ATM_Series.Set(-1);


      Any direction you can provide is greatly appreciated.

      Regards

      Sam



      ST_ATM_Series.Set(1)

      Comment


        #4
        Sam, could you perhaps attach the full indicator code you're using so we can run it on our end for check? The DataSeries should not need the 'forced' Update() call, though it should not 'hurt' here in your case, would changing to a snippet below help for your public properties?

        public DataSeries ST_ATM_Series
        ( get { return sT_ATM_Series }
        }

        Comment


          #5
          HI Bertrand,

          Thank you for your suggestion on changing the case in my dataseries. Sorry, it did not help.
          However, after playing with it for a day i believe i know where the problem lies but i am unable to determine why it is happening and asking for your help and direction.

          Rather than sending my entire lengthy script i managed to reproduce the error in a smaller version of the 2 parts( indicator and strategy).

          I have attached 2 ZIP files each containing an indicator and a strategy.

          Case 1 works perfectly as your documentation indicates.
          a)i stripped down tssupertrend to its essential components;
          b)compiled it;
          c)then created a very simple strategy with the wizard and modified it to display the value of the dataseries on each onbarupdate.
          d)compiled the strategy
          e) It works perfectly per the documentation

          Case 2
          a) started working with the version of Case 1 (the tssupertrend indicator)
          b) added 3 parameters to the indicator which were not present in Case 1
          Note these were added to the very end of the parameters ( not in between previous parameters)
          c) Note:i just added parameters no additional logic was added to onbarupdate; just in the variables section for declaration
          d) compiled the indicator ... it looks perfect in the chart.
          e) created a new strategy from scratch using the wizard.
          f) only added prints to display the contents of the DataSeries
          g) compiled the strategy
          h) the strategy no longer recognizes the DataSeries
          it is always 0 not 1 or -1 as expected ( or as in Case 1)


          I am using NT 6.5 version 15
          Not certain if i can provide much more but at least i isolated the problem for you
          Thank you kindly for your patience and help

          Regards
          Sam
          Attached Files

          Comment


            #6
            Hi Sam,

            I'm looking into this and will get a response to you later today. Thank you for your patience.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Hi Sam,

              I was looking at your case2 files since that was what you were having issues with and you use the same file name for both indicators. Unfortunately it did not compile for me successfully.

              Please package all necessary files into one NinjaScript file. Use File > Utilities > Export NinjaScript for this.

              Ryan M.NinjaTrader Customer Service

              Comment


                #8
                Ryan | Bertrand

                I am so sorry for the mix up on my part.
                After all that testing and confirming i cannot believe i assembled the cs files incorrectly

                So here are the case2 indicator and strategy exported from Ninja.
                I have also included a JPG file.... to describe what i am trying to achieve.

                I am certain the problem is with the 3 parameters added at the bottom of the parameters list

                Please let me know if there is something else i can provide you to figure out what is going on.
                Thank you for your patience

                Sam
                Attached Files

                Comment


                  #9
                  Thanks - was able to import and look at this a good bit. You should see an error message in the log tab when running the strategy. It looks like somewhere it is trying to access an empty object when running the indicator code.

                  Will need to use try catch to isolate which line in the indicator is causing this:


                  The only difference I can see between the two files (the one that works and the one that doesn't) is the parameters as you indicate. Unfortunately I'm not sure why this would contribute to the error.

                  If try-catch doesn't identify this for you, it may be best to start over from the working version, and slowly add the parameters, verifying behavior at each step.
                  Ryan M.NinjaTrader Customer Service

                  Comment


                    #10
                    Ryan,

                    Thank you for the suggestion for the trap to the log.
                    but will it work in the parameters section?
                    I specifically made no changes to the onbarupdate to see if i could identify the problem.
                    and currently the error occurs by adding the 3 parameters...
                    any thoughts on this?


                    on another note.... i find it interesting that the in the strategy the newly added parameters in the CASE2 example are at the front of the lookup when they were added to the end of the parameters. Is it possible there is a mixup on the order of the passed parameters?

                    Thank you again for your help

                    Sam

                    Comment


                      #11
                      It works to capture the line of code that's trying to access the empty object. You're right - this shouldn't be the parameters section. It is most likely to going to be found in OnBarUpdate(). It can still provide clues about which line is running into the exception.

                      An additional test I ran on the Case2 file - I commented out the parameters, adjusted the strategy inputs to only 3, and ran into the same issue - all zeroes for your indicator.

                      I couldn't identify any other difference between these two files (besides the additional parameters) and that's why it may work better to start adding components to the working one, verifying your indicator value at each step.

                      You may be on the right track with the parameter sequencing. Parameters are always sequenced in alphabetical order, and is worth investigating. You may need to adjust the order of expected inputs on the strategy side after making changes in the indicator.
                      Ryan M.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      648 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      369 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      108 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      572 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      573 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X