• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 zweistein, 11-14-2017, 03:24 PM
                          2 responses
                          1,476 views
                          0 likes
                          Last Post woodie1
                          by woodie1
                           
                          Started by Newtrader101, Today, 04:50 AM
                          3 responses
                          18 views
                          0 likes
                          Last Post NinjaTrader_ChrisL  
                          Started by utilizator, Today, 06:31 AM
                          3 responses
                          13 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Started by digibob, Today, 01:13 AM
                          3 responses
                          14 views
                          0 likes
                          Last Post digibob
                          by digibob
                           
                          Started by calebsandfort, Yesterday, 05:16 PM
                          2 responses
                          11 views
                          0 likes
                          Last Post NinjaTrader_PaulH  
                          Working...
                          X