Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to "set seed" to initialize different start points for volume bars?

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

    How to "set seed" to initialize different start points for volume bars?

    I'm looking to create volume-type OHLC bars with various start points in NT.

    --Of course, there's no problem creating volume-type OHLC bars out of the box with NT.
    --My question is a bit different. Specifically, I want to change what the 'seed" or initial trade will be in the first OHLC bar.
    --The idea is that I don't want to optimize a strategy to a single representation (i.e., starting point) for the volume OHLC bars since the start point for this type of bar is arbitrary in real life.

    Any suggestions? Is there any functionality in NT that supports this?

    #2
    Hello bluelou,

    Thanks for your post.

    Creating custom bar types is not supported by NinjaTrader. It is also not possible to create / edit bar types from the NinjaScript editor in NinjaTrader.

    However, this thread will remain open for any community members that may want to contribute.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello bluelou,

      Thanks for your post.

      Creating custom bar types is not supported by NinjaTrader. It is also not possible to create / edit bar types from the NinjaScript editor in NinjaTrader.

      However, this thread will remain open for any community members that may want to contribute.

      ChelseaB,
      That's not exactly what I asked so let me try again to be sure. I don't need custom bar types nor do I necessarily need to edit bar types from the NS editor.

      It's misleading in a backtest to accept a single OHLC data series of volume bars since there is no synchronization of volume bars. I don't want to accept just one representation of volume OHLC bars since this will lead likely lead to over-parameterization.

      So, to add a bit of diversity I'm hoping to set the seed of the initial trade in order to have a pseudo-random volume bar time stamp. This is really basic randomization stuff. If it's not in NT it should be.

      Now, based on what you've said I'm assuming NT doesn't have this very basic functionality. Given that, what do you suggest? Should I just create custom instruments to get a different seed?

      Comment


        #4
        Hello bluelou,

        I will need a bit of clarity.

        When you mentioned "I'm looking to create volume-type OHLC bars with various start points in NT. " I took this to mean you are wanting to create a volume type OHLC bar.

        Instead, what are you referring to when you say "seed"?

        Trades are triggered when your conditions are evaluated as true. What conditions are you looking for, for your orders to go in?

        You can get the volume information for a bar or for a day. You can get the OHLC for a day.

        How do you want to blend these together?

        What is the exact data you are looking for?


        For randomizing the parameters there is the genetic optimizer which uses random parameters and then follows generations of child tests to try and find good parameters to use with the script.

        Below is a link to the help guide on the Genetic Optimizer.
        http://www.ninjatrader.com/support/h..._algorithm.htm
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello bluelou,

          I will need a bit of clarity.

          When you mentioned "I'm looking to create volume-type OHLC bars with various start points in NT. " I took this to mean you are wanting to create a volume type OHLC bar.

          Instead, what are you referring to when you say "seed"?

          Trades are triggered when your conditions are evaluated as true. What conditions are you looking for, for your orders to go in?

          You can get the volume information for a bar or for a day. You can get the OHLC for a day.

          How do you want to blend these together?

          What is the exact data you are looking for?


          For randomizing the parameters there is the genetic optimizer which uses random parameters and then follows generations of child tests to try and find good parameters to use with the script.

          Below is a link to the help guide on the Genetic Optimizer.
          http://www.ninjatrader.com/support/h..._algorithm.htm

          Okay, let's start with the idea of how a volume OHLC bar is formed in NT.
          --My guess is that NT stores in a database all "tick" data that a user has loaded into NT. This tick data has a volume field. The volume field can be used to create n-size volume bars.
          --Now, when the user wants, say, 1000-volume 6E bars in NT. That person will always get a 1000-volume bar with the same time stamp regardless of the start/end date on a chart.
          --This means that we will always get a 1000-volume OHLC bar with the same time stamp and the exact same O, H, L, and C, AS IF it were, say, a m-minute bar.
          --But, we know this is false. The only reason the 1000-volume O, H, L, and C are aligned with any time stamp is because of where the 1st record in the database is stored.

          --For instance, instead of starting with the first tick in the NT database, we decide to start with the 999th tick. Then, we will have different time stamps and different OHLCs for each 1000-volume bar. This is what I mean by "seed"; i.e., the initial record in this case. Since this is transaction data (ticks, volume), the choice of initial record is arbitrary.

          --Why do we care?
          If we test on a single representation (a single realization of volume bar data) of the volume OHLC data and we parameterize a trading model only on this one realization we run a real risk of fitting to a data set that only exists because of its seed; in this case, the first record in the NT database. Thus, we want to have the ability to set.seed()

          Am I making any more sense? Any ideas on what I can do in NT to address this issue?

          Comment


            #6
            eDanny,
            Actually, that's not correct. The start time of the chart is just a query to the same data set. You'll get the same volume OHLC bars for a given bar size no matter what the start date is. Give it a try. It's a recipe for really misleading studies/backtests.

            Comment


              #7
              Hello bluelou,

              Volume bars will be time stamped with the close time of the bar.

              That means the time of the bar will not be set permanently until the bar closes.
              (You can test this by checking the time of the current forming bar repeatedly. You will notice that the time changes on it until the bar closes).

              With historical data, yes, tick data will be used to build the volume bar. The last tick that is included with that bar will mark the close time of that bar.

              Each bar will be forced to close at the end of the trading session. Meaning a bar will only be able to contain data within that particular session. If the session closes before 1000 volume is received, that last bar is cutoff anyways and will just be short. Some sessions last overnight and span multiple calendar days.

              The volume bar, Open, High, Low, and Close, will be made by the first tick, highest tick, lowest tick, and last tick that are included with that bar. This will only match a 1 minute based bar if that volume bar happens to only be open for exactly 1 minute which is very unlikely. (But randomly could be possible)

              Volume bars are accurate as far as the Open, High, Low, and Close are concerned as to what was received between the close time of that bar and the close time of the previous bar.
              If you can demonstrate that this is correct, please post the demonstration.


              I am still unclear as to what you are trying to do.
              Can you clarify what you mean when you say: "If we test on a single representation (a single realization of volume bar data) of the volume OHLC data and we parameterize a trading model only on this one realization we run a real risk of fitting to a data set that only exists because of its seed;"

              By seed are you just referring to the first trade time?

              It sounds like you want to run tests over different time periods so that the optimized parameters are not for just one specific time period. If so, thats exactly what the Walk Forward Optimization does. Does the Walk Forward Optimization not suit your needs?
              http://www.ninjatrader.com/support/h...e_a_strate.htm
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_ChelseaB View Post
                Hello bluelou,

                Volume bars will be time stamped with the close time of the bar.

                That means the time of the bar will not be set permanently until the bar closes.
                (You can test this by checking the time of the current forming bar repeatedly. You will notice that the time changes on it until the bar closes).

                With historical data, yes, tick data will be used to build the volume bar. The last tick that is included with that bar will mark the close time of that bar.

                Each bar will be forced to close at the end of the trading session. Meaning a bar will only be able to contain data within that particular session. If the session closes before 1000 volume is received, that last bar is cutoff anyways and will just be short. Some sessions last overnight and span multiple calendar days.

                The volume bar, Open, High, Low, and Close, will be made by the first tick, highest tick, lowest tick, and last tick that are included with that bar. This will only match a 1 minute based bar if that volume bar happens to only be open for exactly 1 minute which is very unlikely. (But randomly could be possible)

                Volume bars are accurate as far as the Open, High, Low, and Close are concerned as to what was received between the close time of that bar and the close time of the previous bar.
                If you can demonstrate that this is correct, please post the demonstration.


                I am still unclear as to what you are trying to do.
                Can you clarify what you mean when you say: "If we test on a single representation (a single realization of volume bar data) of the volume OHLC data and we parameterize a trading model only on this one realization we run a real risk of fitting to a data set that only exists because of its seed;"

                By seed are you just referring to the first trade time?

                It sounds like you want to run tests over different time periods so that the optimized parameters are not for just one specific time period. If so, thats exactly what the Walk Forward Optimization does. Does the Walk Forward Optimization not suit your needs?
                http://www.ninjatrader.com/support/h...e_a_strate.htm
                ChelseaB,
                Thx for sticking with me on this I think we're still talking past each other.

                Here's the idea written a little differently:
                1) Start with any n-volume bar data series on a given interval (start/end dates) and chart it in NT. Next, create a second chart of n-volume bars with slightly different start/end dates. Now, where the 2 charts have overlapping dates look at any of the bars. The volume OHLC bars will be exactly the same across the 2 charts; i.e., the same time stamp and the same OHLC values.

                2) However, we know that if I look at a 1000-volume bar chart on my PC for the same dates, that my volume bars won't have the same time stamps or OHLC values as yours.

                3) Why are they different? Because we had different initial starting records stored in our respective databases.

                Are you with me so far?

                Comment


                  #9
                  Hello bluelou,

                  As long as the data is from a previous day or as long as we opened our charts before the session opened and we have the same data from the same data source, the 1000 Volume bars should be exactly the same between our computers for all of those dates, even if i select a different start date.

                  Can you demonstrate that they do not?

                  It doesn't matter what start date was selected, the volume bars will all begin building at the same time once a new session starts. This is because the session close forces the bar to close. Meaning on the new day, everyone's data starts the same.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Hi bluelou, you are correct and after posting I realized I was wrong and took it down but not before you apparently read it!
                    eDanny
                    NinjaTrader Ecosystem Vendor - Integrity Traders

                    Comment


                      #11
                      Originally posted by NinjaTrader_ChelseaB View Post
                      Hello bluelou,

                      As long as the data is from a previous day or as long as we opened our charts before the session opened and we have the same data from the same data source, the 1000 Volume bars should be exactly the same between our computers for all of those dates, even if i select a different start date.

                      Can you demonstrate that they do not?

                      It doesn't matter what start date was selected, the volume bars will all begin building at the same time once a new session starts. This is because the session close forces the bar to close. Meaning on the new day, everyone's data starts the same.
                      ChelseaB,
                      That's a really good point that I wasn't aware of. I didn't know that the NT transaction count started and ended with each session interval. That wasn't exactly my point but, with respect to NT, I think this obviates any need for me set a seed. Thanks much for your help!

                      ~Lou

                      Comment


                        #12
                        No worries : ). Thx for taking an interest. ChelseaB's point about the transaction count starting at each new session was the most important thing. I had assumed the count was cumulative from the first record in the database.

                        If this was a time series data set in, say, Python or R, and not on the NT platform, it would likely be cumulative since there isn't the concept of 'session time'.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by AaronKoRn, Yesterday, 09:49 PM
                        0 responses
                        11 views
                        0 likes
                        Last Post AaronKoRn  
                        Started by carnitron, Yesterday, 08:42 PM
                        0 responses
                        10 views
                        0 likes
                        Last Post carnitron  
                        Started by strategist007, Yesterday, 07:51 PM
                        0 responses
                        11 views
                        0 likes
                        Last Post strategist007  
                        Started by StockTrader88, 03-06-2021, 08:58 AM
                        44 responses
                        3,981 views
                        3 likes
                        Last Post jhudas88  
                        Started by rbeckmann05, Yesterday, 06:48 PM
                        0 responses
                        9 views
                        0 likes
                        Last Post rbeckmann05  
                        Working...
                        X