Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

VWAP Modification

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

    #46
    No, the strategy does not need to know the period lookback of any nested indicators (except such as it needs to instantiate them if it is an input parameter of the indicator) but the strategy needs to add all of the required data series.
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #47
      Thanks Bruce

      So the way I nestle the datasereies required by the indicator into the strategy should work


      AddDataSeries(Instrument.FullName.ToString(), new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1}, "US Equities RTH");/// Closes[1]
      AddDataSeries(Instrument.FullName.ToString(), new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1}, "CBOE US Index Futures ETH");/// Closes[2]​


      AddDataSeries(Data.BarsPeriodType.Minute, 1);/// Closes[3]
      AddDataSeries(Data.BarsPeriodType.Minute, 5);/// Closes[4]
      AddDataSeries(Data.BarsPeriodType.Minute, 15);/// Closes[5]
      AddDataSeries(Data.BarsPeriodType.Minute, 30);/// Closes[6]​

      *****************************


      ATSFloatingAnchors1 = ATSFloatingAnchors(Close, true, true, true, 1, 120, true, 5, 78, true, 15, 78, true, 30, 78);

      I am wondering if the dataloaded for the indicator as above the 1 , 120 is actually the Closes[3] of the indicator dataseries
      the Closes[1] and Closes[2] do not have anything shown similar to the 1 , 120 inputs

      I am concerned that the 1,120 is being considered as Closes[1] and referencing the First loaded AddDataSeries Item which will be incorrect as that is RTH only

      Thanks again

      UPDATE It is actually not working at all, I went back and updated the strategy to Plot on Chart for the Indicator and there are NO PLOTS
      Last edited by DTSSTS; 05-01-2023, 07:18 AM.

      Comment


        #48
        I would absolutely not do that with the "Instrument.FullName.ToString()" that should be null.

        Also, when you add different data series in the strategy, and then it uses some or all of them in the nested indicator, they do not have to be in the same order - they just all have to be present in the strategy.

        So, the strategy needs to AddDataSeries all that the strategy needs plus all that the indicator needs. The indicator only needs to AddDataSeries its own needs. They do not have to be the same BarsArray index e.g. Closes[3] vs Closes[2] in each place - they just all have to be there.
        Bruce DeVault
        QuantKey Trading Vendor Services
        NinjaTrader Ecosystem Vendor - QuantKey

        Comment


          #49
          OK let me take this one step at a time as to not confuse your appreciated answers - YOU are really really good and I am sure appreciated by all

          Step ONE

          AddDataSeries(Instrument.FullName.ToString(), new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1}, "US Equities RTH");/// Closes[1]
          AddDataSeries(Instrument.FullName.ToString(), new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1}, "CBOE US Index Futures ETH");/// Closes[2]​

          these are used in the indicator to plot vwap Closes[1] is RTH so that standard vwap only calculates during RTH but Mainly so that when used on an Equity would not pickup afterhours data if applied to ETH hours chart, the Closes[2] was standard vwap in ETH session. I do not want to use the primary data for these calculations

          SO how would you STATE those 2 DataSeries other than just

          AddDataSeries(Data.BarsPeriodType.Minute, 1);from the primary instrument

          ************************************************** **************************************************

          Regarding the indicator being calculated in the strategy itself is my biggest issue with this - I DO NOT UNDERSTAND THIS STATEMENT

          Also, when you add different data series in the strategy, and then it uses some or all of them in the nested indicator, they do not have to be in the same order - they just all have to be present in the strategy

          plus all that the indicator needs - THIS IS WHAT I HAVE Closes[1] to Closes[6]

          I do not understand this part -- BarsArray index e.g. Closes[3] vs Closes[2] in each place - they just all have to be there.

          The indicator is calculating plots base​ BarsInProgress = 3 etc - 3 being Closes[3] etc for 3 thru 6 So seems somehow it must know

          But anyway I have 6 AddedDataSeries in the indicator and have them in the same order as posted in Version 6.5 Miscellaneous
          I have the indicator to Plot on Chart and I am not seeing any plots

          Thanks again

          Added Item No, the strategy does not need to know the period lookback of any nested indicators (except such as it needs to instantiate them if it is an input parameter of the indicator) but the strategy needs to add all of the required data series.

          except such as it needs to instantiate them if it is an input parameter of the indicator - the indicator does use a variable lookback Period on closes 3 thru 6 EACH OF THOSE ITEMS SHOWN HERE

          ATSFloatingAnchors1 = ATSFloatingAnchors(Close, true, true, true, 1, 120, true, 5, 78, true, 15, 78, true, 30, 78);

          THE 78 IS A VARIABLE LOOKBACK PERIOD USED TO CALCULATE THE PLOTS

          SO do they need to be hard coded
          Last edited by DTSSTS; 05-01-2023, 08:34 AM.

          Comment


            #50
            Originally posted by DTSSTS View Post
            Step ONE

            AddDataSeries(Instrument.FullName.ToString(), new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1}, "US Equities RTH");/// Closes[1]
            AddDataSeries(Instrument.FullName.ToString(), new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1}, "CBOE US Index Futures ETH");/// Closes[2]​

            these are used in the indicator to plot vwap Closes[1] is RTH so that standard vwap only calculates during RTH but Mainly so that when used on an Equity would not pickup afterhours data if applied to ETH hours chart, the Closes[2] was standard vwap in ETH session. I do not want to use the primary data for these calculations

            SO how would you STATE those 2 DataSeries other than just

            AddDataSeries(Data.BarsPeriodType.Minute, 1);from the primary instrument
            Just repeat those same lines in the strategy's State.Configure section:

            Code:
            AddDataSeries(null, new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1}, "US Equities RTH"); // needed by nested indicator
            AddDataSeries(null, new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1}, "CBOE US Index Futures ETH"); // needed by nested indicator
            You can put them in the same order in the strategy (all six of them) as they are in the indicator but they do not have to be in the same order. For instance, suppose the indicator needs six of them (Closes[1] through Closes[6]) which for the indicator are BarsInProgress == 1 through BarsInProgress == 6. Suppose further the strategy needs the indicator, plus another four additional DataSeries of its own.

            In the strategy, then, you could AddDataSeries the four the strategy needs first, then AddDataSeries the other six that the indicator is going to need. The fact that they're Closes[5] through Closes[10] in the strategy does not matter - to the indicator they will still be Closes[1] through Closes[6]. All that matters is that the strategy added all the right series so they are available to the indicator. If you did this as described above, in the strategy in OnBarUpdate, if the strategy did not need any of those six (except for the indicator needing them) you could do if (BarsInProgress > 4) return; and just not even process them.

            I'm not 100% sure I answered everything you've asked, so please let me know if I'm missing the mark here.
            Last edited by QuantKey_Bruce; 05-01-2023, 08:39 AM.
            Bruce DeVault
            QuantKey Trading Vendor Services
            NinjaTrader Ecosystem Vendor - QuantKey

            Comment


              #51
              Yes this item you did not address I do not think

              except such as it needs to instantiate them if it is an input parameter of the indicator - the indicator does use a variable lookback Period on closes 3 thru 6 EACH OF THOSE ITEMS SHOWN HERE

              ATSFloatingAnchors1 = ATSFloatingAnchors(Close, true, true, true, 1, 120, true, 5, 78, true, 15, 78, true, 30, 78);

              THE 78 IS A VARIABLE LOOKBACK PERIOD USED TO CALCULATE THE PLOTS

              SO do they need to be hard coded ??????????

              OR COULD I JUST add the variable inputs required by the indicator to the strategy

              ie AnchorONEDataSeriesMinutes and AnchorONELookBackPeriod (for each items closes 3 thru 6

              ************************************************** *******

              I change to null on the 2 dataseries, F5 to recalculate the Indicator on the chart, and the chart locked up and never calculated - IT has been stuck on Calculating for about 7 mins.

              Comment


                #52
                Hello DTSSTS,

                Thanks for your notes.

                QuantKey_Bruce is correct, when calling AddDataSeries() you can set Instrument.FullName.ToString() to null instead. For example:

                AddDataSeries(null, new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1}, "US Equities RTH");

                If the indicator you are using in the strategy contains six added data series in the script, then those same 6 data series should be added to the strategy. The order of the AddDataSeries() calls do not need to be the exact same as long as you have all six added series placed in the strategy. QuantKey_Bruce gave a good example of this in post # 50.

                You will need to hardcode the parameters being used in the AddDataSeries() methods in State.Configure as previously stated.

                When instantiating your indicator in State.DataLoaded, you could hardcode the values or you could use a variable.

                If you changed the AddDataSeries() to use null instead of Instrument.FullName.ToString(), please remove the script from the chart and then add it back to the chart to make sure changes took effect. Note the Log tab of the Control Center for any errors that might arise when running the script.

                It is important to also make sure there are enough bars in all the added series in the script by using a CurrentBars check if you have not done so. See the help guide page below for more information about this.

                Make sure you have enough bars: https://ninjatrader.com/support/help...nough_bars.htm
                <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                Comment


                  #53
                  You do not have to hard-code the inputs. They can be variables. But, if they change during the same run of the strategy e.g. if they change on each bar that is quite inefficient and should probably be done differently. But if you mean they are inputs of the strategy and you then pass them in as inputs of the indicator and they don't change during one run of the strategy, that is fine.
                  Bruce DeVault
                  QuantKey Trading Vendor Services
                  NinjaTrader Ecosystem Vendor - QuantKey

                  Comment


                    #54
                    BrandonH you lost me here

                    You will need to hardcode the parameters being used in the AddDataSeries() methods in State.Configure as previously stated.

                    When instantiating your indicator in State.DataLoaded, you could hardcode the values or you could use a variable.

                    what is the difference​

                    Comment


                      #55
                      Bruce IF i create variable inputs in my Strategy (not changes while stratgey is running) IT is just setting the starting point to calculate vwap for example 1 120 is 1 min 120 periods to find the High

                      IF I just add input for the variables and name them exactly as the Indicator uses, will the indicator find those inputs

                      this ATSFloatingAnchors1 = ATSFloatingAnchors(Close, true, true, true, 1, 120, true, 5, 78, true, 15, 78, true, 30, 78);

                      would become this in the strategy

                      ATSFloatingAnchors1 = ATSFloatingAnchors(Close, true, true, true, AnchorONEDataSeriesMinutes , AnchorONELookBackPeriod , true, AnchorTWODataSeriesMinutes , AnchorTWOLookBackPeriod, true, AnchorTHREEDataSeriesMinutes , AnchorTHREELookBackPeriod , true, AnchorFOURDataSeriesMinutes , AnchorFOURLookBackPeriod );


                      AnchorONEDataSeriesMinutes AnchorONELookBackPeriod ARE Exactly same variable input names from the Indicator

                      Thanks

                      Comment


                        #56
                        Yes, that seems fine from what I can see. Are you having trouble with it when you do it that way? There's no problem with having variables (such as input parameters in the strategy) as parameters of the indicator when it is instantiated in State.DataLoaded.
                        Bruce DeVault
                        QuantKey Trading Vendor Services
                        NinjaTrader Ecosystem Vendor - QuantKey

                        Comment


                          #57
                          Hello DTSSTS,

                          Thanks for your note.

                          The AddDataSeries() method must be called in State.Configure and the values you supply to the AddDataSeries() method must be hardcoded as stated in the help guide.

                          From the AddDataSeries() help guide:"Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided. "

                          AddDataSeries(): https://ninjatrader.com/support/help...dataseries.htm

                          Instantiating an indicator in a NinjaScript strategy is different than adding an additional data series. The AddDataSeries() method requires you to hardcode values into this method as noted above and noted in the help guide whereas instantiating an indicator does not require you to hardcode the values.

                          You would instantiate the indicator in State.DataLoaded and do not have to hardcode the values. This means you would place ATSFloatingAnchors1 = ATSFloatingAnchors(Close, true, true, true, 1, 120, true, 5, 78, true, 15, 78, true, 30, 78); within State.DataLoaded and if you want to use variables for the values in this line of code you could do so.

                          <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                          Comment


                            #58
                            OK so in the strategy I MUST DO THIS

                            AddDataSeries(null, new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1}, "US Equities RTH");/// Closes[1]
                            AddDataSeries(null, new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1}, "CBOE US Index Futures ETH");/// Closes[2]​


                            AddDataSeries(Data.BarsPeriodType.Minute, 1);/// Closes[3]
                            AddDataSeries(Data.BarsPeriodType.Minute, 5);/// Closes[4]
                            AddDataSeries(Data.BarsPeriodType.Minute, 15);/// Closes[5]
                            AddDataSeries(Data.BarsPeriodType.Minute, 30);/// Closes[6]​

                            and then this and create variable inputs for the strategy, if SO then could the AddDataSeries for Closes 3 4 5 6 not all be 1 minute as the Variable inputs below are overriding that anyway
                            OR ARE YOU SAYING IF there is a possibility that a user might input 120 minutes then that has to be an added DataSeries as well

                            ATSFloatingAnchors1 = ATSFloatingAnchors(Close, true, true, true, AnchorONEDataSeriesMinutes , AnchorONELookBackPeriod , true, AnchorTWODataSeriesMinutes , AnchorTWOLookBackPeriod, true, AnchorTHREEDataSeriesMinutes , AnchorTHREELookBackPeriod , true, AnchorFOURDataSeriesMinutes , AnchorFOURLookBackPeriod );​


                            here are my secondary dataseries used in MY INDICATOR Itself THEY MUST BE VARIABLE inputs OR IF NOT SUGGESTED THERE AS WELL
                            I guess I could have bool statements to choose Minutes 1 2 3 5 10 15 30 60 120 and then code in

                            IF any bool1 true , bool2 true etc

                            BUT THAT WOULD be like 40 bools to achieve that, about 10 for each dataseries


                            AddDataSeries(null, new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1}, "US Equities RTH");/// Closes[1]
                            AddDataSeries(null, new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1}, "CBOE US Index Futures ETH");/// Closes[2]


                            AddDataSeries(Data.BarsPeriodType.Minute, AnchorONEDataSeriesMinutes);/// Closes[3]
                            AddDataSeries(Data.BarsPeriodType.Minute, AnchorTWODataSeriesMinutes);/// Closes[4]
                            AddDataSeries(Data.BarsPeriodType.Minute, AnchorTHREEDataSeriesMinutes);/// Closes[5]
                            AddDataSeries(Data.BarsPeriodType.Minute, AnchorFOURDataSeriesMinutes);/// Closes[6]​

                            SO DO I NEED TO REMOVE THE VARIABLE inputs from the INDICATOR as well

                            Comment


                              #59
                              Wish I have known NOT to refresh the script of the chart with the indicator after I compiled with null added. Had to manually endtask to unlock NinjaTrader and since then after 2 restarts there is NO Control Center, so I cannot recover workspace or backup. Backup would still lose all work done on 4/30

                              Comment


                                #60
                                Hello DTSSTS,

                                Thanks for your note.

                                "OK so in the strategy I MUST DO THIS

                                AddDataSeries(null, new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1}, "US Equities RTH");/// Closes[1]
                                AddDataSeries(null, new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1}, "CBOE US Index Futures ETH");/// Closes[2]​


                                AddDataSeries(Data.BarsPeriodType.Minute, 1);/// Closes[3]
                                AddDataSeries(Data.BarsPeriodType.Minute, 5);/// Closes[4]
                                AddDataSeries(Data.BarsPeriodType.Minute, 15);/// Closes[5]
                                AddDataSeries(Data.BarsPeriodType.Minute, 30);/// Closes[6]​​"


                                Yes, that is correct. This is hardcoding the values for the AddDataSeries() method as the help guide states.

                                "SO DO I NEED TO REMOVE THE VARIABLE inputs from the INDICATOR as well"

                                Yes, you will need to remove the variables from the indicator AddDataSeries() methods and hardcode those values similar to how you hardcoded them in the quote above.

                                You could refresh the script on the chart using the F5 key on the keyboard but it is recommended to remove the script from the chart and readd the script to the chart to ensure the changes you made take effect.

                                If you are not able to successfully open NinjaTrader, run a repair using the NinjaTrader installer.
                                • Close NinjaTrader if you have it opened.
                                • Restart your PC.
                                • After restarting your PC, download the NinjaTrader installer from this link
                                  • account.ninjatrader.com
                                • Once the installer is downloaded, run the NinjaTrader installer.
                                • Click the Next button
                                • Click the Repair button to run a repair.
                                • After the repair is complete, exit the Installer
                                • Restart NinjaTrader 8
                                Last edited by NinjaTrader_BrandonH; 05-01-2023, 01:13 PM.
                                <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                647 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