Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Confused about Bars

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

    Confused about Bars

    Hi,

    1) I have built a strategy using the strategy builder. I understand that when I use the strategy builder wizard without unlocking the code, I can only utilize one bars object, which means that all my indicators have to be calculated off one interval series (ie: 5min, 10min, 60min). That is, my Stochastics, 20SMA, Bollingers, ADX, DI+ & DI- would all be calculated using the same bars object and hence the same timeframe. Is this correct?

    If this is correct, how do I check what is the default primary bars object used to calculate my indicator? Under the conditions builder, I have left "Input Series" as "Default Input". How do I find out what is the default input series interval, and where can I change this default value if I need? Now, I don't even know what sort of interval my TA values are being calculated from, and where I can change the time frame if I need to! Pls advise me!


    2) Secondly, I am trying to test my strategy in the strategy analyzer. Here is where things get really confusing, since the strategy analyzer has its own "Data Series" section where the user is given some options: Price Based On, Type, and "Value".

    What does this data series section do? If I specify the value as 1(minute), does this change my strategy's primary bars object to a 1 minute bar? Won't this screw up my strategy if my primary bars were originally set as the 60min interval bar type?

    If specifying 1min changes my strategy's parameters, the strategy analyzer won't give me an accurate picture of my strategy's performance, since my strategy utilizes 60 min bars to calculate TA values. On the other hand, if I enter 60mins as the "value" under the data series section, the strategy analyzer gives me no results at all.

    Can you please clarify if specifying a different value from the strategy's primary bars actually alters the strategy's primary bars (and hence the strategy itself!), or whether the "data series" value in the backtest function simply affects the sensitivity of the backtest?

    3) The same confusion arises in the "Strategies" tab in the main window. When I add a new strategy, the "data series" section is identical to the one which shows up in the backtest!

    If I specify a value of 1min here, and my strategy code uses 60min bars as the primary bars object, does this (1) screw up my strategy parameters by calculating all my indicators based on a 1min interval series (and hence fundamentally change the strategy)? (2) Or is this simply a means to provide an event trigger for the calculateonbarclose method (in which case, it is irrelevant since I have set "calculateonbarclose" to false)

    4) If setting the values in the data series section is a means of specifying the bars objects on which TA values are calculated, how does the backtester and strategy runner accommodate strategies which incorporate different bars objects (multiple timeframe strategies)? Say, if I set 1 min as my value in the "Data Series" section, how will this affect my other bars objects in a multi timeframe strategy?

    My confusion in points 2, 3 and 4 revolve around the confusing "data series" section and how specifying a value there (eg: 1min) affects bars objects specified in the strategy code itself (if at all). Some clarification would be very much appreciated!

    #2
    Also, I would like to clarify something. When I backtest my strategy for 1 year prior on a basket of 30 FX pairs using the strategy analyzer, does Ninjatrader automatically pull all the relevant data from my data provider (Barchart subscription)?

    Comment


      #3
      Originally posted by skyholder84 View Post
      Hi,

      1) I have built a strategy using the strategy builder. I understand that when I use the strategy builder wizard without unlocking the code, I can only utilize one bars object, which means that all my indicators have to be calculated off one interval series (ie: 5min, 10min, 60min). That is, my Stochastics, 20SMA, Bollingers, ADX, DI+ & DI- would all be calculated using the same bars object and hence the same timeframe. Is this correct?
      This is correct.
      If this is correct, how do I check what is the default primary bars object used to calculate my indicator? Under the conditions builder, I have left "Input Series" as "Default Input". How do I find out what is the default input series interval, and where can I change this default value if I need? Now, I don't even know what sort of interval my TA values are being calculated from, and where I can change the time frame if I need to! Pls advise me!
      If you select Default Input, there should be some sort of selection that allows you to pick Close, High, Low, Volume, etc for the Input Series. You can always hardcode this value in so there is no confusion.
      2) Secondly, I am trying to test my strategy in the strategy analyzer. Here is where things get really confusing, since the strategy analyzer has its own "Data Series" section where the user is given some options: Price Based On, Type, and "Value".

      What does this data series section do? If I specify the value as 1(minute), does this change my strategy's primary bars object to a 1 minute bar? Won't this screw up my strategy if my primary bars were originally set as the 60min interval bar type?
      This data series section is where you set what kind of bars and timeframe you want to use. If you select 1 minute bars, this would indeed change your strategy's primary bars to a 1 minute bar. It could quite possible screw up your strategy if it is supposed to use 60 minute bars, so be sure to select a 60 minute timeframe.
      If specifying 1min changes my strategy's parameters, the strategy analyzer won't give me an accurate picture of my strategy's performance, since my strategy utilizes 60 min bars to calculate TA values. On the other hand, if I enter 60mins as the "value" under the data series section, the strategy analyzer gives me no results at all.
      Please make sure you're specifying a backtest that is long enough to create enough 60 minute bars to actually run the backtest.
      Can you please clarify if specifying a different value from the strategy's primary bars actually alters the strategy's primary bars (and hence the strategy itself!), or whether the "data series" value in the backtest function simply affects the sensitivity of the backtest?
      It does alter the strategy's primary bars as described above.
      3) The same confusion arises in the "Strategies" tab in the main window. When I add a new strategy, the "data series" section is identical to the one which shows up in the backtest!

      If I specify a value of 1min here, and my strategy code uses 60min bars as the primary bars object, does this (1) screw up my strategy parameters by calculating all my indicators based on a 1min interval series (and hence fundamentally change the strategy)? (2) Or is this simply a means to provide an event trigger for the calculateonbarclose method (in which case, it is irrelevant since I have set "calculateonbarclose" to false)
      Again, this is the exact same situation as the backtester. Please select a 60 minute timeframe if your strategy is designed to use 60 minute bars.
      4) If setting the values in the data series section is a means of specifying the bars objects on which TA values are calculated, how does the backtester and strategy runner accommodate strategies which incorporate different bars objects (multiple timeframe strategies)? Say, if I set 1 min as my value in the "Data Series" section, how will this affect my other bars objects in a multi timeframe strategy?
      Multiple bar series are created and utilized within the same strategy. They all run alongside each other and the OnBarUpdate()s are mingled among each other, but with a different BarsInProgress for each (if BarsInProgress == 0, that is the primary series, BIP = 1 - secondary series, etc) You can take a look at the SampleMultiTimeframe strategy present in every installation of NinjaTrader (Tools -> Edit NinjaScript -> Strategy -> SampleMultiTimeFrame) to get a feel for how MTF strategies work.

      Please let us know if you have any other questions.
      AustinNinjaTrader Customer Service

      Comment


        #4
        Hi Austin,

        Thanks for the swift and comprehensive reply:

        On Question 1 which I posed earlier, how do I set the default bars on my strategy to 60mins? I would like to know for sure what the default bars timeframe on my strategy is. When building the data series section, there is no data series input section for me to specify the primary bars interval type, so there is a problem there. Also, I can't seem to find it in the code.

        Also, I would like to clarify something. When I backtest my strategy for 1 year prior on a basket of 30 FX pairs using the strategy analyzer, does Ninjatrader automatically pull all the relevant data from my data provider? (I am currently using a paid Barchart subscription)

        Thanks!

        Comment


          #5
          I'm still A little confused. If the data series box in the strategy tester and the live strategy runner require the user to specify a single minute value input, how can they accommodate multitimeframe strategies where several bars objects exist? If my strategy uses 5m, 10m and 60m bars, which should I specify in the data series box? Should it be the primary bar that is specified in the data series box?

          Also, I can't bactest my strategy on any other data series input other than the 1m input. I've tried 2m, 5m, 10m etc, and backtested it over an entire year. The 1 min data series throws up hundreds of trades, and the rest throw up absolutely nothing. This can't be a pure coincidence. I'm sure that over a year, my strat would have activated at least several times using other bars intervals other than the 1m interval. Do I need to download interval-specific historic data for the backtesting to work on when My strategy uses A 60m primary bars interval series in TA calculations rather than 1m intervals?
          Last edited by skyholder84; 10-24-2010, 02:00 AM.

          Comment


            #6
            Hello again, unfortunately it is not possible to set the default timeframe for a strategy - you must make sure you select the correct period when starting it. When you backtest, NinjaTrader will automatically download all of the necessary data.

            Multi-timeframe strategies have their secondary (and tertiary, etc) timeframes configured with code in the Initialize() section. The primary timeframe is specified in the data series box.

            As for why your strategy does not generate results, would you be willing to post the code here so we can take a look at it? It should backtest on all timeframes.
            AustinNinjaTrader Customer Service

            Comment


              #7
              I would like to send you my code directly rather than post it here. Pls advise me on how I can do so.

              Also, I am getting very disturbing crashes in NT7. I tried changing the margin limits in the simulator tab under options, and NT7 crashed. Now, each time I edit ANYTHING under tools => options, NT7 crashes.

              I have tried uninstalling and reinstalling NT7, but the error persists. Can you guide me on how to do a complete uninstall? I would have to wipe all traces of NT7 off the registry and reinstall, and I'm not sure how to do that.

              Comment


                #8
                Skyholder, you can email it to support at ninjatrader dot com with a link to this thread and Attn: Bertrand in the email subject.

                To do a full reinstall, please follow these steps, but be sure to backup your license key and other important data beforehand:
                1. Close all running applications.
                2. Then from the Start menu select --> Control Panel --> Add and Remove Programs.
                3. From Add and Remove Programs select NinjaTrader 6.5 and click Remove.
                4. Then manually delete the folder "NinjaTrader 6.5" located under Start --> My Documents.
                5. Delete any NinjaTrader installation files. This can be done by going to Start --> My Computer --> Search button --> search for (NinjaTrader*) --> select Local C Disk and then press search.
                6. Then you will need to clear your internet browser cache and history. You will clear this from within your internet browser (with IE, Tools-->Options, delete cookies and files, clear history).
                7. Reboot your machine.
                8. Once these steps are completed, download NT6.5 from the link below:
                  Download

                Please let us know if you are able to get up and running after the reinstall.
                AustinNinjaTrader Customer Service

                Comment


                  #9
                  Hi Austin,

                  Most of my problems were solved by simply disabling my virus scan software. A disgustingly simple solution, but it took me 24 gruelling hours to discover it! After disabling it, the crashes no longer occur, and backtesting on multiple bar values no longer poses a problem.

                  My strategy is up and running, and I have just one final issue I need to address before going live. My broker is Interactive brokers, and due to cost considerations (unique to IB), each trade executed by my strategy is sized as 26,000 units.

                  However, the strategy simulator is throwing up some really strange orders: it splits each order into two fills , one being 25,999 units and the other being 1 unit. Given that IB charges a minimum of USD2.5 per Forex trade, does this strange split fill effectively double my cost? If it does (and even if it doesn't), how do I prevent this strange outcome?

                  NT is an awesome engine, but some of the functions and parameters just aren't intuitive to first time users. The help guide explanation is also often quite inadequate.
                  As such, your continued patience and prompt assistance so far has been a great relief to me.

                  Comment


                    #10
                    Hello,

                    Glad to hear you found the issue. I will pass this on to Austin.

                    As far as the orders issue, when you start the strategy and create the strategy there is a setting that you need to change when starting the strategy.

                    Understanding strategy properties



                    Stop and Target Submission.

                    Let me know if I can be of further assistance.
                    BrettNinjaTrader Product Management

                    Comment


                      #11
                      Hi Brett,

                      There is one last bug in my strategy that I need help in fixing.

                      Walkthrough of my strat:

                      1) A pivot based trend following strategy built using conditions builder.

                      Conditions set 1,2,3 for trading Supports 1, 2 and 3. Set 4 for Long Order Entry, Set 5 for Long order Exit.

                      Conditions set 6,7,8 for trading Resistances 1, 2 and 3. Set 9 for short Order Entry, Set 10 for short order Exit.


                      2) Uses Parabolic SAR as an exit condition

                      Currently, my strategy places entry orders perfectly, and I have no problem with trade entry. However, when a parabolic SAR crossover occurs, causing the strategy to exit the trade, something baffling occurs.

                      The moment the trade is closed out, the strategy executes one immediate round trip trade at market. Buying, and selling immediately within the next second (or vice versa)!

                      My strategy uses OnBarUpdate = false and updates on every tick. I thought that avoiding the crossover method (and hence the lookback period problem) and using a direct value-to-value comparison between parabolic SAR and price would fix the situation, but it does not. The nonsensical round-trip trade made after every normal trade exit still occurs!

                      Fortunately, only one nonsensical round trip trade is triggered after the close. Still, it is baffling and expensive, and I was hoping you could help me look at the code (and the attached trade sheet) and explain why this is happening.

                      Thanks!
                      Last edited by skyholder84; 10-25-2010, 05:08 PM.

                      Comment


                        #12
                        Hello,

                        In your strategy are you always reversing the position or should it wait until EnterShort parameters are correct?

                        I look forward to assisting you further.
                        BrettNinjaTrader Product Management

                        Comment


                          #13
                          PSar is used purely as a stop, never as a reversal strategy trigger. All EnterShort parameters must be correct. Pivots are the trigger.

                          Comment


                            #14
                            Hello,

                            Here is what I think is happening.

                            You are setting a variable to 1, 2 or 3 based on checking for some entry parameters. Then you set this variable back to 0 when you get in.

                            However what I believe is occuring is that this 0 is getting instantly set back to 123 after you got in long since the entry parameters are still good.

                            So EnterLong() is getting recalled however since the strategy is only allowed to have 1 long at a time it doesnt get you in a second time. However it will get you in instantly again after you have returned to a flat position since EnterLong() is still being called.

                            I recommend that in Set 5 where you ExitLong() and the other set where you ExitShort() you also set this variable to 0. This way you ensure that a new entry condition is in fact true after you have exited the current trade.

                            Let me know if I can be of further assistance.
                            BrettNinjaTrader Product Management

                            Comment


                              #15
                              Hi Brett,

                              Sorry it took so long to reply; morning's just arrived over here on the Pacific Rim.

                              I believe that's the issue! I'm mortified that I couldn't see the simple logical flaw in my strategy, but more importantly, a sense of gratitude to you for helping me locate the flaw!

                              Kudos to you and Austin, and thanks a bunch!

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              85 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              47 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              29 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              32 views
                              0 likes
                              Last Post TheRealMorford  
                              Started by Mindset, 02-28-2026, 06:16 AM
                              0 responses
                              67 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Working...
                              X