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 syncronize chart with strategy

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

    #16
    Okay after playing with the MACD on multi-time frames this is my observations.

    Code:
    MACD 1min: -0.0725339898886261 3min: -0.0952584188761136
    1min Bar Object: 7/20/2007 7:38:00 AM Open: 140.63 High: 140.63 Low: 140.34 Close: 140.62
    MACD 1min: -0.0833415635370898 3min: -0.0952584188761136
    1min Bar Object: [COLOR=Red]7/20/2007 7:39:00 AM[/COLOR] Open: 140.59 High: 140.67 Low: 140.58 Close: 140.63
    MACD 1min: -0.0900615535632312 3min: [COLOR=Red]-0.0952584188761136[/COLOR]
    3min Bar Object: [COLOR=Red]7/20/2007 7:39:00 AM[/COLOR] Open: 140.82 High: 140.83 Low: 140.34 Close: 140.63
    MACD 3min: [COLOR=Red]-0.112775395505793[/COLOR] 1min: -0.0900615535632312
    If you are in the primary bar object and you call the value of the secondary bar object, since the secondary bar object has not updated yet it will return the old value. It isn't until after the secondary bar object gets updated do you get the new value when you access it in the primary bar object.

    I suspect this behavior would carry over in a more dramatic way for your situation because you are using volume as your third interval. I would think that because of when your volume bar is being processed none of your minute bars are up to date yet and thus a delayed value of MACD when you reference its value. Perhaps it would be better to run your calculations on the object with the lowest resolution (your 5min bars). But that produces another issue of is 5mins really the lowest resolution you are running at because you can't really compare the resolution of volume vs minutes. I think if you just run on a volatile market it shouldn't be a problem though.

    This still leaves the issue of how you are getting an "up" value in a down trend. Maybe you would want to print values from every bars object and try to pinpoint what the delay in value is. It has to be getting the MACD value from somewhere so it will probably be helpful to find where the value we are getting is coming from.
    Josh P.NinjaTrader Customer Service

    Comment


      #17
      I've run further tests and it is as I suspected. The volume bars carry the MACD values of the past 1min and past 5min. It is not until those bars are updated does the value become updated in the volume bars.

      Code:
      500vol Bar Object: 12/20/2007 8:09:57 AM Open: 183.91 High: 183.91 Low: 183.9 Close: 183.9
      MACD 500vol: 0.00485589918136498 1min: [COLOR=Red]-0.107769849405713[/COLOR] 3min: 0.0218328041772793 500vol: 0.00485589918136498
      500vol Bar Object: 12/20/2007 8:09:59 AM Open: 183.9 High: 183.92 Low: 183.89 Close: 183.9
      MACD 500vol: 0.00397746488812345 1min: [COLOR=Red]-0.107769849405713[/COLOR] 3min: 0.0218328041772793 500vol: 0.00397746488812345[COLOR=Red]
      1min Bar Object:[/COLOR] 12/20/2007 8:10:00 AM Open: 183.82 High: 183.94 Low: 183.77 Close: 183.9
      MACD 1min: [COLOR=Black]-0.108630635878114[/COLOR] 1min: [COLOR=Red]-0.108630635878114[/COLOR] 3min: 0.0218328041772793 500vol: 0.00397746488812345
      500vol Bar Object: 12/20/2007 8:10:02 AM Open: 183.9 High: 183.95 Low: 183.9 Close: 183.94
      MACD 500vol: 0.00643478884771298 1min: [COLOR=Red]-0.108630635878114[/COLOR] 3min: 0.0218328041772793 500vol: 0.00643478884771298
      500vol Bar Object: 12/20/2007 8:10:02 AM Open: 183.94 High: 183.94 Low: 183.94 Close: 183.94
      MACD 500vol: 0.0082867117351384 1min: [COLOR=Red]-0.108630635878114[/COLOR] 3min: 0.0218328041772793 500vol: 0.0082867117351384
      500vol Bar Object: 12/20/2007 8:10:02 AM Open: 183.94 High: 183.94 Low: 183.94 Close: 183.94
      Josh P.NinjaTrader Customer Service

      Comment


        #18
        Josh

        Thanks for all the info. I understand what you provided.

        If I specify CalculateOnBarClose = false; do the other secondary timeframes only get updated on their bar close? I thought they would be updated every tick as well. That will blow me away if it doesn't.

        Comment


          #19
          All time frames will update tick by tick.
          RayNinjaTrader Customer Service

          Comment


            #20
            Morning Ray

            Nice to get a reply from the Boss.

            I got another signal at 8:51 this morning that I shouldn't. The 5 minute MACD had been pointing down for over an hour but I got an up signal.

            I looked at my code to make sure I didn't have a typo.

            s.MACD(s.BarsArray[s.InstrumentPosition["5-Minute"]],19,38,9)[0] > s.MACD(s.BarsArray[s.InstrumentPosition["5-Minute"]],19,38,9)[1]

            Any ideas? I am backtesting and I can repeat it. Sometimes I get a signal and it was only good before the bar close. This one looks like it held until after bar close.

            Cliff

            Comment


              #21
              Apart from rolling up your sleeves and debug? Print out values and bar times to see what's going on and correlate to the chart. Its tedious but that's what I do.
              RayNinjaTrader Customer Service

              Comment


                #22
                Ray

                It is possible the macd on the 5 minute was up somewhere during the 5 minutes but didn't finish out the bar that way. I can't duplicate the signal now.

                If I specify to update on bar close will I get the correct values on my big time frames when the bar close is on the smallest timeframe? Or will I only get an update to the bigger bars when those bigger bar actually close?

                Cliff

                Comment


                  #23
                  The best way to see the difference between what values are referenced in a multi-series strategy is at the link below.

                  See the images under "How bar data is referenced"

                  RayNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by ScottWalsh, Today, 04:52 PM
                  0 responses
                  1 view
                  0 likes
                  Last Post ScottWalsh  
                  Started by ScottWalsh, Today, 04:29 PM
                  0 responses
                  5 views
                  0 likes
                  Last Post ScottWalsh  
                  Started by rtwave, 04-12-2024, 09:30 AM
                  2 responses
                  22 views
                  0 likes
                  Last Post rtwave
                  by rtwave
                   
                  Started by tsantospinto, 04-12-2024, 07:04 PM
                  5 responses
                  70 views
                  0 likes
                  Last Post tsantospinto  
                  Started by cre8able, Today, 03:20 PM
                  0 responses
                  7 views
                  0 likes
                  Last Post cre8able  
                  Working...
                  X