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

Gettting indicator as dataseries?

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

    Gettting indicator as dataseries?

    This is basic, but I can't get it right. I declare a dataseries i.e.:

    DataSeries ds_normalized_spread;

    And then in OnStartUp(), I want to set it to the plotted value of the following indicator:

    ds_normalized_spread= Ratio(false, symbol2, includeMultiplier). ?????? ;

    What am I missing?

    #2
    AntiMatter,

    Thank you for your post.

    In your example you are trying to set the DataSeries as a Ratio value

    You would want to Set() the data series with values.

    ds_normalized_spread.Set();
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      "Ratio" is the name of an indicator here:

      I want the DataSeries to be set to the output of the indicator....

      Comment


        #4
        This is how you would want your setup to be-

        ds_normalized_spread.Set(Ratio(false, symbol2, includeMultiplier)[0]);
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          **NT** Error on calling 'OnStartUp' method for strategy 'NormalizedSpreadStrategyJC1/0f43af4480324a40bf4c653b2f386a73': Object reference not set to an instance of an object.

          Comment


            #6
            AntiMatter,

            Apologies, I did not see that you were trying this in OnStartUp()

            You will need to use this in OnBarUpdate() so that the values get added to the data series for each bar update.
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              Thanks for all the help. I am trying to adapt some existing code, which assigns the following indicator to the DataSeries in OnStartup():

              ds_normalized_spread=PSTNormalizedSpread(averageBa rs, dblMPFixedValue, includeMultiplier, inputSeriesSelection, nAgo, nsAverageType, nsMidpointTypeSelection, nsPITType, showMidpoint, showNormalizedSpread, showRawSpreadPriceSeries, spreadType, symbol1, symbol1Units, symbol2, symbol2Units, symbol3,symbol3Units).NormalizedSpread;

              However, rather than utilising the PSTNormalizedSpread, I want to instead utilise the Spread indicator. e.g.:

              ds_normalized_spread= Ratio(false, symbol2, includeMultiplier).value ????

              I have played around with your suggestions above, but it is not behaving as expected. This is probably due to it being a multi-instrument strategy, so when utilising:

              ds_normalized_spread.Set(Ratio(false, symbol2, includeMultiplier)[0]);

              it gets set to the wrong value when the BarsInProgress = symbol2.

              Thus, I would like to assign the indicator to the dataseries in the same way as the original author did. I just can't seem to do it!

              Comment


                #8
                Antimatter,

                You can use the BarsInProgress to separate out the data so that when BIP == symbol1 and then Set() the value, it will only apply to the values from symbol1

                if(BarsInProgess == 1)
                {
                //set your dataseries value here
                }
                Cal H.NinjaTrader Customer Service

                Comment


                  #9
                  OK thanks, was going down that route anyhow, but thought it might be cleaner to keep it the same way as the original script. Also, I wasn't really understanding why the original author could assign his indicator that way, but I cannot assign my indicator in the same way???!

                  Comment


                    #10
                    Do you have an example of how they were writing it?
                    Cal H.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by NinjaTrader_Cal View Post
                      Do you have an example of how they were writing it?
                      Code:
                      #region Variables
                                  DataSeries ds_normalized_spread;
                                  Bollinger bb_entry;
                      And in OnStartUp:

                      Code:
                              protected override void OnStartUp()
                              {
                                 ds_normalized_spread=PSTNormalizedSpread(averageBars, dblMPFixedValue, includeMultiplier, inputSeriesSelection, nAgo, nsAverageType, nsMidpointTypeSelection, nsPITType, showMidpoint, showNormalizedSpread, showRawSpreadPriceSeries, spreadType, symbol1, symbol1Units, symbol2, symbol2Units, symbol3,symbol3Units).NormalizedSpread;
                      
                      bb_entry=Bollinger(ds_normalized_spread,entryBandStdDev,spreadBandCalcHorizon);
                      And then later, it is used ie.

                      Code:
                      if (ds_normalized_spread[0]>bb_entry.Upper[0])
                                              {
                      I would like to simply replace the

                      ds_normalized_spread=PSTNormalizedSpread(.....) for a different indicator. For example, using the output from the Ratio indicator.

                      As you can see, I am a little out-of-my-depth here, so thanks for the help.

                      Comment


                        #12
                        AntiMatter,

                        Your example is calling the Indicator itself and not a data series from the Ratio.

                        You can access and public dataseries from the Ratio by adding a period at the end and selecting the name of the dataseries

                        Example -
                        ds_normalized_spread = SMA(14).Value;
                        Cal H.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by yertle, Yesterday, 08:38 AM
                        7 responses
                        28 views
                        0 likes
                        Last Post yertle
                        by yertle
                         
                        Started by bmartz, 03-12-2024, 06:12 AM
                        2 responses
                        21 views
                        0 likes
                        Last Post bmartz
                        by bmartz
                         
                        Started by funk10101, Today, 12:02 AM
                        0 responses
                        4 views
                        0 likes
                        Last Post funk10101  
                        Started by gravdigaz6, Yesterday, 11:40 PM
                        1 response
                        8 views
                        0 likes
                        Last Post NinjaTrader_Manfred  
                        Started by MarianApalaghiei, Yesterday, 10:49 PM
                        3 responses
                        11 views
                        0 likes
                        Last Post NinjaTrader_Manfred  
                        Working...
                        X