Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Swing behavior different on CalculateOnBarClose

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

    Swing behavior different on CalculateOnBarClose

    The swing indicator does not calculate correct values when you set the Calculate on Bar Close to False. On a chart, it is easy to change the setting for only the Swing indicator. When used within a strategy with CalculateOnBarClose=false, swing becomes unreliable.

    Is there a way to run Swing indicator with the CalculateOnBarClose=true when the rest of the strategy runs with CalculateOnBarClose=false?

    Thanks.

    #2
    praiz, you can check into this reference sample below showing a technique to combine COBC false / true conditions in one script - http://www.ninjatrader.com/support/f...ad.php?t=19387
    BertrandNinjaTrader Customer Service

    Comment


      #3
      I looked at the example. It is doing opposite of what I want to do. The swing indicator does not work as expected with CalculateBarOnClose=false (every tick). I want the indicator to have the property of CalculateBarOnClose=true while the rest of the strategy and indicators to use CalculateBarOnClose=false.

      I can achieve the result in a chart where the chart and all the indicators are set to use CalculateBarOnClose=false except the swing indicator which I can set to the opposite setting. Unfortunately, I haven't been able to figure out how to achieve the same from within a strategy (added to the chart or otherwise).

      Is there is a way for me to access indicator values added to a chart from within a strategy? I know of adding indicators to a chart from within a strategy but not how to access indicators added to the chart outside the strategy.

      Comment


        #4
        praiz, you would always call the indicator method directly in your script - so if you place your swing indicator call in if (FirstTickOfBar) would the values still be off for your use comparing to the indicator run on CalculateOnBarClose = true?
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Yes! There is an issue with the swing indicator where it calculates incorrect values when running in CalculateBarOnClose=false. So, it does not matter if I use FirstTickOfBar.

          At this point, I am thinking of rewriting the swing indicator so it uses closed bars regardless of the CalculateBarOnClose setting.

          Comment


            #6
            Due to the nature of the Swing indicator study, you would be expected to see differences comparing a programmatic call if it's methods vs the true indicator display, which is more meant as a visual market structure tool. To see what values are accessible at what point via a script, please just plot the SwingHigh and SwingLow returns as plots for your chosen strength - in my testing those were correct and up to date in COBC = false use as well.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              First - Thank you so much for working with me on this.

              Let me show you by example how swing indicator is broken when COBC is false. The results are broken both in the chart (visually) and within a strategy/script.

              To view the broken results, please replay the ES data from 11/22/11 with COBC=false on the swing indicator added to the chart.

              Last edited by praiz; 03-13-2012, 05:36 PM.

              Comment


                #8
                Thanks for the screenshot, this can happen with indicators running COBC = false - conditions become true / false intrabar and thus you would see differences when comparing to running the calcs on bar close only. You can see this effect for example as well if you trade on an MA crossover in realtime with COBC = false, it could whipsaw you as the trade could be valid intrabar but gone as the closing tick is seen - traders have thus to make a choice / tradeoff

                Do you wait until the bar is closed or is there a high probability before the bar close that the signal stays?
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  The incorrect values stay. That is the problem. As you can see from the chart, whenever these values are referenced from the time they are created, they remain incorrect. Can this be resolved? Thanks.

                  For the swing indicator, can the calculations be performed on FirstTickOfBar instead of intrabar? This way, it will work on both the COBC=false and COBC=true. Since swing requires many bars to elapse before determining the swing position, it is not an indicator that needs update in 'realtime'/intrabar.
                  Last edited by praiz; 03-14-2012, 07:05 PM.

                  Comment


                    #10
                    Originally posted by praiz View Post
                    The incorrect values stay. That is the problem. As you can see from the chart, whenever these values are referenced from the time they are created, they remain incorrect. Can this be resolved? Thanks.

                    For the swing indicator, can the calculations be performed on FirstTickOfBar instead of intrabar? This way, it will work on both the COBC=false and COBC=true. Since swing requires many bars to elapse before determining the swing position, it is not an indicator that needs update in 'realtime'/intrabar.
                    I would suggest that in your strategy, you use a named instance of the Swing() indicator and then change the COBC property of that named instance, and use it by its name.

                    Comment


                      #11
                      Hello,

                      Do you have a sample of how to create a named instance of the indicator. Never done this before. I am assuming I would have to declare the variable of type Swing (any references to be included in the file to the Swing assembly?) in the variables section. Would I do a 'new' on the instance in the initialize section?

                      This appears to be an idea with great potential. I ended up creating my own version of the indicator, though it is not an indicator, just a method call which does the exact same calculations as the Swing indicator with COBC = false. I would however like to try out what you suggest.

                      Thanks again.

                      Comment


                        #12
                        Originally posted by koganam View Post
                        I would suggest that in your strategy, you use a named instance of the Swing() indicator and then change the COBC property of that named instance, and use it by its name.
                        Here is one way.

                        Code:
                         
                        #region Variables
                                private Swing SwingforcedCOBC;
                                #endregion
                         
                                protected override void OnStartUp()
                                {
                                    this.SwingforcedCOBC = Swing(5); //swing strength of "5"
                                    this.SwingforcedCOBC.CalculateOnBarClose = true;
                                }
                         
                                protected override void OnBarUpdate()
                                {
                                    // use SwingforcedCOBC here when you want to get swing points.
                                }

                        Comment


                          #13
                          Thank you so much!! I thanked you twice now. This opens a ton of possibilities. Is there a section on this forum where we can find out about things Ninjatrader can do but is not in the official documentation?! If only the product documentation had something around this feature. It would have saved me many days. Love the product though.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by DJ888, 04-16-2024, 06:09 PM
                          6 responses
                          18 views
                          0 likes
                          Last Post DJ888
                          by DJ888
                           
                          Started by Jon17, Today, 04:33 PM
                          0 responses
                          1 view
                          0 likes
                          Last Post Jon17
                          by Jon17
                           
                          Started by Javierw.ok, Today, 04:12 PM
                          0 responses
                          6 views
                          0 likes
                          Last Post Javierw.ok  
                          Started by timmbbo, Today, 08:59 AM
                          2 responses
                          10 views
                          0 likes
                          Last Post bltdavid  
                          Started by alifarahani, Today, 09:40 AM
                          6 responses
                          41 views
                          0 likes
                          Last Post alifarahani  
                          Working...
                          X