• 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

NT7 Swing Indicator Returning Different Values with COBC=false

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

    NT7 Swing Indicator Returning Different Values with COBC=false

    Hi,

    I'm working on an indicator that uses the built-in NT7 Swing indicator to tell my code what the latest Swing High/Low is. When I run my indicator with the COBC=true, it is reporting the correct values (The high/low of the swing point). When I run my indicator with COBC=false, it reports different values (The open/close of the bar following the swing point). This doesn't make any sense to me as the Swing indicator should just return the Swing High/Low dataseries. Why would the setting of the COBC value modify the Swing values being reported?

    Any help figuring this out will be much appreciated.

    I've included 2 text files (one file for each COBC setting) containing the Swing high/low output for the time period in the image between the 2 vertical blue bars.

    Here is the simplified code which will reproduce what I'm seeing:
    public class DTSwingTest : Indicator
    {
    #region Variables

    private int swingStrength = 6;

    private double swingLow = 0;

    private double swingHigh = 0;

    // User defined variables (add any user defined variables below)
    #endregion

    /// <summary>
    /// This method is used to configure the indicator and is called once before any bar data is loaded.
    /// </summary>
    protected override void Initialize()
    {

    // Setting Overlay to true means our indicator will be defaulted to plot on the price panel
    Overlay = true;

    // Set to false so that tests of the swing points can alert immediately
    CalculateOnBarClose = false;


    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {

    if(Historical)
    return;

    if (FirstTickOfBar)
    {

    swingLow = Swing(swingStrength).SwingLow[0];
    swingHigh = Swing(swingStrength).SwingHigh[0];

    Print ( Time[0].ToString() );
    Print ( Instrument.MasterInstrument.Name + " Swing Low : " + swingLow );
    Print ( Instrument.MasterInstrument.Name + " Swing High : " + swingHigh );
    }



    }

    #region Properties

    #endregion
    }

    }
    COBCTrueSwings.txt

    COBCFalseSwings.txt

    Click image for larger version

Name:	Swing.jpg
Views:	1
Size:	66.2 KB
ID:	898503

    #2
    Dharma,

    The swing indicator essentially goes back and sets values as new information comes in and as such this may explain your issue. In addition, calculate on bar close set to false allows the indicator to update via the most recent bar, whereas calculate on bar close set to true has the indicator only calculate when a bar closes.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Adam,

      I understand that the COBC=false would allow the swing indicator to look at the intrabar data of the current bar but with a swing strength setting of 6, the current bar wouldn't be eligible as a swing point until another 5 bars had closed and shouldn't even be factored in to calculating the last swing point except for marking the last swing point as invalid if the high/low of that bar had been surpassed by the current bar.

      Also, per my attached info, the Swing indicator is reporting the open/close value instead of the high/low when the COBC=false. Isn't the Swing designed to report the high/low values of the bars that become swing points? It doesn't make sense to me that it would ever report a value other than a high/low regardless of the COBC setting.

      What do you think?

      -Thanks

      Comment


        #4
        Dharma,

        It looks like this thread may have covered something similar before : http://www.ninjatrader.com/support/f...ad.php?t=48386

        The Swing indicator can be challenging to work with, I suggest you just plot the High / Low values programmatically accessed to see what info is available as the 'visual only' one you used on the chart is backfitting it's results to easily show the current swing structure of the market analyzed.
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          Adam,

          Thanks. I was able to get my indicator working using the information from the link that you provided.

          Comment


            #6
            Even in NT8, Swing indicator still broken without Calculate.OnBarClose

            Hi,
            in NT7 it has been known for years now that the Swing indicator does not work without CalculateOnBarClose true.
            In NT8, one would hope for an improvement, but no, it is still the same flaw.
            Yes, there is advice for a workaround, but why not just provide a Swing indicator that works properly?

            saltminer

            Comment


              #7
              Hello saltminer,

              Thank you for your post.

              Attached are two indicators (one for NT7 and one for NT8) that pull the Swing High and Low in realtime with the correct Swing High and Low values.

              These indicators use a Strength of 5 and should be applied to your chart that is using the Swing indicator with a Strength of 5 while the Output window is open.

              Please let me know how you are varying from these indicators and what values you are trying to pull that are not appearing in realtime.
              Attached Files
              Patrick H.NinjaTrader Customer Service

              Comment


                #8
                Hi,
                thanks for those, but there is an even clearer way to see the problem. Just use AddChartIndicator(Swing(5)) within a strategy that is calculating tick by tick.

                See attached screenshot. The realtime bars at right are producing incorrect swings, while the historical ones at left are ok.

                saltminer
                Attached Files

                Comment


                  #9
                  Hello saltminer,

                  Thank you for your response.

                  I cannot reproduce that behavior on my end with the attached script. Can you detail if your script varies from mine and if so please detail the differences?

                  I look forward to your response.
                  Attached Files
                  Patrick H.NinjaTrader Customer Service

                  Comment


                    #10
                    Hi,
                    I don't think you waited long enough. Your script does indeed misbehave. See attached screenshot. This is on 5 range chart. Blue line is transition from historical to realtime.

                    saltminer
                    Attached Files

                    Comment


                      #11
                      Hello saltminer,

                      Thank you for your response.

                      You are correct. I will follow up here when I have details on this matter.
                      Patrick H.NinjaTrader Customer Service

                      Comment


                        #12
                        HI PatrickH,

                        any update on that? Would be great if we could use this indicator in real time with correct values in our strategies...

                        Comment


                          #13
                          Hello eddi0505,

                          Thank you for your note.

                          I do not have an update on this but I will update this thread when I do.
                          Patrick H.NinjaTrader Customer Service

                          Comment


                            #14
                            Hello. On a lot of threads I read
                            "
                            Yes, I was able to see the error but at this point have no further details I can relay. Once I have more details on this request I will reply back here.
                            "

                            from a NT representative.

                            Therefore, as it seems that such replies have taken system, can you please tell us what your expectations are for a usable Swing-Indicator as per below asked by DharmaTrader. When do you think you can make this available?

                            Comment


                              #15
                              Hello eddi0505,

                              Thank you for your post.

                              The Swing is working as needed on Historical data and when using the options to calculate on the close of the bar.

                              We are working on correcting the behavior for real-time processing (when not calculating on the close of the bar) and I have every intention of keeping this thread up to date.
                              Patrick H.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by krofs, Today, 03:37 PM
                              2 responses
                              8 views
                              0 likes
                              Last Post krofs
                              by krofs
                               
                              Started by kalalex, Today, 03:51 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post kalalex
                              by kalalex
                               
                              Started by bdelorm, Today, 12:26 PM
                              5 responses
                              26 views
                              0 likes
                              Last Post bdelorm
                              by bdelorm
                               
                              Started by kalalex, Today, 02:23 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post kalalex
                              by kalalex
                               
                              Started by kevinenergy, Today, 01:43 PM
                              4 responses
                              19 views
                              0 likes
                              Last Post NinjaTrader_PaulH  
                              Working...
                              X