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

Multi time frame and WMA

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

    #16
    Hello David,

    This probably has to do with your CalculateOnBarClose settings. When set to true you will get the value of the last complete bar, not the in-process bar. To get the most recent values, change CalculateOnBarClose to false. You can hard code this property or change the setting whenever you run it.
    Ryan M.NinjaTrader Customer Service

    Comment


      #17
      The problem is that I am not getting the values from the last complete bar. I am getting the bar before that, in the added time frame only.

      After running this some more, this is some kind of timing issue.

      For example, when I start a market replay, just after 9:30 I get my first print statement. In the primary time frame I am seeing the correct values for "Close" and "WMA High" from the last 10 minute bar of the previous day. In the added time frame I am getting values not from the last bar of the previous day, but from the 2nd last bar of the day. Then at 9:40 in my next print statement I am again seeing the correct values for my primary time frame, those from the first bar of the day. On the secondary time frame, now I am seeing the values for the last bar of the previous day.

      This pattern continues on during the day ...

      In testing this has caused some entries to occur 1 bar later than intended.

      Thanks,

      David

      Comment


        #18
        David, Please post the latest .cs file you're working with from Documents\NinjaTrader\bin\custom\strategy.
        Ryan M.NinjaTrader Customer Service

        Comment


          #19
          The "posting rules" tell me I can post attachments but other than images and hyperlinks, I don't see how.

          Comment


            #20
            Dave,

            Attachments are handled through individual posts. Click reply and when composing your post look for Manage Attachments button under Additional Options.
            Ryan M.NinjaTrader Customer Service

            Comment


              #21
              Originally posted by NinjaTrader_RyanM View Post
              Dave,

              Attachments are handled through individual posts. Click reply and when composing your post look for Manage Attachments button under Additional Options.
              I had to click on "Quote" to see those options. Reply just gave me the quick reply option which is apparently less "robust".

              Maybe I'll add a smiley face while I'm here...
              Attached Files

              Comment


                #22
                Hi David,

                One thing I noticed from your strategy is that your secondary time frame is larger than the primary. This is important in version 6.5, but shouldn't matter as much in version 7.

                You should modify your strategy so that secondary series is smaller than the primary series.

                Please see this reference sample on Backtesting NinjaScript Strategies with an intrabar granularity for assistance on coding this. Below is the section that discusses the order of OnBarUpdate calls in a multi instrument strategy.

                When working with multiple bar series objects it is important to understand the sequential order in which the
                OnBarUpdate() method is triggered. The bars will always run with the primary first followed by the secondary and
                so on.

                Important: Primary bars will always execute before the secondary bar series.
                If a bar is timestamped as 12:00PM on the 5min bar series, the call order between the equally timestamped 12:00PM
                bar on the 1min bar series is like this:
                12:00PM 5min
                12:00PM 1min
                12:01PM 1min
                12:02PM 1min
                12:03PM 1min
                12:04PM 1min
                12:05PM 5min
                12:05PM 1min
                Last edited by NinjaTrader_RyanM1; 06-02-2010, 11:36 AM.
                Ryan M.NinjaTrader Customer Service

                Comment


                  #23
                  Sorry I'm a bit confused by your response. Just to be clear (if you could not tell from the cs) I am using version 6.5.

                  First you said my "secondary time frame is larger". Yes I agree, it is.

                  Then you said I should modify so that my "primary series" is"smaller" than the larger. Isn't it already???

                  I'm guesing you mean that my higher time frame, 30 min, should be my primary rather than the 10 min time frame? Also you seem to be suggesting that the way I have it now is preferable for 6.5?

                  Comment


                    #24
                    Yes, you're right. Thanks for seeking clarification.

                    If you have two series, a 10 minute and 30 minute:

                    Your 30 minute series should be the primary series. This is the series you run the strategy against.
                    Your 10 minute series should be the secondary series. This is the series you add in the initialize method.

                    This is preferred when using version 6.5 due to the timing of bar objects.
                    Ryan M.NinjaTrader Customer Service

                    Comment


                      #25
                      Ryan,

                      This looks promising after my initial tests on market replay data this morning. I had to do some tweaking as my entry and exit conditions are on my secondary timeframe now (as compared to the example with the entry condition on the primary time frame) but my entries, exits and all print statements are now looking like I envisioned.

                      Thanks,

                      David

                      Comment


                        #26
                        Glad to hear, David. Thanks for the update.
                        Ryan M.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by ETFVoyageur, Today, 02:15 AM
                        5 responses
                        29 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by drnoggin, Today, 12:19 PM
                        1 response
                        14 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Started by synthhokie, Today, 12:00 PM
                        1 response
                        16 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Started by moneyexe, Today, 11:22 AM
                        1 response
                        12 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Started by stevec1824, Today, 11:00 AM
                        2 responses
                        8 views
                        0 likes
                        Last Post stevec1824  
                        Working...
                        X