Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Tick Data and Volume based Backtest

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

    #16
    Hello newworldguy,

    The bid and ask data need to be added a separate data series and then they can be accessed with OnBarUpdate().

    This would be the MarketDataType overload parameter in the Add() command I linked in my post #8.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #17
      To get the bid series I am doing:

      Add(Instrument.MasterInstrument.InstrumentType.ToS tring(), PeriodType.Tick, 1, MarketDataType.Bid);
      Is this valid? i.e. can it be called in initialize?

      Comment


        #18
        sorry i meant:


        Add(Instrument.MasterInstrument.Name, PeriodType.Tick, 1, MarketDataType.Bid);

        Comment


          #19
          Hello,

          This usage is correct, and this must be added to Initialize() and will not work anywhere else.

          Also, I recommend using the Instrument.FullName.

          Add(Instrument.FullName, PeriodType.Tick, 1, MarketDataType.Bid);
          Chelsea B.NinjaTrader Customer Service

          Comment


            #20
            Now I have the indicator that respond to each tick and also every 5 minutes.

            I want to back test this. so added the indicator to a strategy. do I have to add the same data series to the strategy now? to get ticks and 5 minutes etc?

            Comment


              #21
              Hi newworldguy,

              No, if you are adding the indicator to a strategy, you do not need to add the secondary series to the strategy if you are only wanting the indicator to have access to both data series. If you want the strategy to have access to both series, then yes, add the secondary series to the strategy.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #22
                the strategy has to take action every time a certain condition is satisfied based on the indicator value. since that code is in OnBarUpdate of the Strategy, my question becomes how often will on bar update of the strategy be called? Alternatively, maybe I can take the action in the indicator itself?

                thanks

                Comment


                  #23
                  Hi newworldguy,

                  If Calculate on bar close is set to True, OnBarUpdate in the strategy will be triggered when a bar closes.

                  Your indicator call will return what ever values it has at the time of the call. If there are internal calculations happening with multiple time series, it will return whatever has been calculated with the data up to that point using the multiple series.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #24
                    on every trade the indicator adds it to an internal data structure. seems like to me I should just set Calculate on bar close to False, in the strategy, That way the indicator will be evaluated on every tick?

                    Comment


                      #25
                      just tried that. it doesn't seem to work! please advice.

                      Comment


                        #26
                        Hi newworldguy,

                        What are you trying to accomplish by doing this?

                        If your strategy needs to evaluate the indicator on every tick, then why would you not add the tick series to the strategy and then call the indicator using the data from the tick series?

                        By setting your strategy to Calculate on bar close false, you are not setting the indicator to calculate on bar close false, you are simply calling the indicator multiple times on the same bar using the same set of data and would likely get the same value over and over.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #27
                          I guess the question can be summarized as: Can data series be different between strategies and indicators used by the strategies? or the same have to be added to both. for example I have tick, bid and ask for the indicator. do i add the same to the strategy?

                          btw when i do the system seems to hang!

                          Comment


                            #28
                            Chelsea,

                            I have coded the indicator and it works fine in realtime. it takes every tick and does a compute and stores and then every 5 minutes does a trade based on all the computes within that five minute period.

                            now to backtest, first i had to modify the indicator because I was using on marketdatupdate in the indicator in realtime. and you helped me with that. thanks!

                            now i want to actually do the backtest. i find that i need to create strategy since you cannot backtest indicators directly.

                            the strategy is simple. if indicator > 5 paint something on the chart...

                            to accomplish this, i hope i do not have to modify my working indicator again. please advice, hope i have explained my dilemma clearly.

                            Comment


                              #29
                              Hi newworldguy,

                              The indicator can use different data series that the strategy calling it.

                              The bid and ask data will depend on your data provider on whether they have this data available.

                              You can check the chart in the help guide in the section 'Understanding the data provided by your connectivity provider' to see if your data provider has this data.
                              http://www.ninjatrader.com/support/h...rical_data.htm

                              The script will need the ask and bid data if the script is to continue.

                              You can check to see if the data is downloaded in the Historical Data Manager (Tools -> Historical Data Manager... -> select the Edit tab -> click the "+" to expand the instrument -> then look for Bid or Ask depending on what you have downloaded.)


                              Attached is a sample that shows the indicator can have different dataseries. This example prints to the output window (Tools -> Output Window...)
                              Attached Files
                              Chelsea B.NinjaTrader Customer Service

                              Comment


                                #30
                                as per your instructions i have verified that i have all the data needed for the backtest. also i have kinetick so i believe it automatically downloads the data for the ES jun contract when i choose to backtest on that instrument.

                                I will try the TickTest example you sent me, in the meantime if you have any further ideas, please share.

                                thanks,

                                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