Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Swing gives wrong result

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

    Swing gives wrong result

    Swing is returning incorrect Swing Low when using Playback and swing low is first bar of RTH session.

    Conditions are as follows:
    1. Example discussed is for ES 12-18 10/26/2018 RTH session.
    2. Swing(1) used for test example although strength does not matter.
    3. Playback is begun at 9:30 AM or a little before but not within the prior session.
    4. Swing low occurs on first bar of RTH session.
    5. Swing low returned by calling: Swing(1).SwingLow[0]
    6. Validity test must return a positive number: Swing(1).SwingLowBar(0,1,Bars.BarsSinceNewTradingD ay)
    7. Result see output window in picture: At time 9:40 Swing(Strength).SwingLow[0] returns 2646 which is incorrect, even though the validity test returns the correct bar of the swing low as a positive number.

    Note that if Playback is begun within the previous session then results are correct. The problem seems to occur when Playback is begun at the RTH session start ((9:30 AM).

    Since the Swing strength condition is dependant upon the last bar of the previous session and the Playback begins after that bar, the Validity test should return -1

    I have attached the test code and screen shot of results.
    Click image for larger version  Name:	20181028b.png Views:	1 Size:	161.1 KB ID:	1037402

    [ATTACH]n1037404[/ATTACH]
    Last edited by Camdo; 10-28-2018, 04:52 PM.

    #2
    Hello Camdo,

    Thank you for reporting the behavior. I will test and attempt to reproduce and if I am able to reproduce I will report the behavior.

    I appreciate your patience.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Camdo,

      The Swing indicator changes its values historically, are you waiting until after the swing is set to check the values?

      Is the behavior different when opening the chart at the same time in the morning with a real-time connection?
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Originally posted by NinjaTrader_ChelseaB View Post
        Hello Camdo,

        The Swing indicator changes its values historically, are you waiting until after the swing is set to check the values?

        Is the behavior different when opening the chart at the same time in the morning with a real-time connection?
        Yes, the Swing(1) strength is satisfied at 9:40 at which time the swing low value is incorrect.
        As you can see in the output window of the screen shot in post #1, The swing low value and its validity check can be read on each bar of the chart.
        The swing low value remains incorrect until a new swing low is made after the session start.
        The problem only manifests when the first bar of the RTH session is the swing low and Playback is started at a time between sessions.
        I have not tested this situation in real time, but I will try. It may take a few days to get results, I will report back.

        Comment


          #5
          Hello Camdo,

          Unfortunately, in the screenshot I am not able to see the time stamps of the last to bars on the chart.

          However, these last two bars do not have a plot appearing on them. This means its likely, the swing isn't set for those last two bars.

          I recommend you wait until the plot is showing on those last two bars, then loop back to those bars (on a later bar) and see if the values were changed.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_ChelseaB View Post
            Hello Camdo,

            Unfortunately, in the screenshot I am not able to see the time stamps of the last to bars on the chart.

            However, these last two bars do not have a plot appearing on them. This means its likely, the swing isn't set for those last two bars.

            I recommend you wait until the plot is showing on those last two bars, then loop back to those bars (on a later bar) and see if the values were changed.
            The bars on the chart in post #1 are 5 min bars. The vertical green line is the first bar of the session which closes at 9:35. The next two bars are 9:40 and 9:45 and the last bar is the working bar not yet closed.

            The red vertical line is 16:00 of the previous session.

            The swing indicator paints a dot at the swing low level under each completed bar. On the chart, there are 3 yellow dots painted from the first bar of the RTH session. The working bar has no dot under it as it is not yet complete. This is correct behavior for a Swing(1). The swing strength is satisfied and the indicator is painting correctly.

            The problem is that the .SwingLow query is reporting back the wrong value when the swing low occurs on the first bar of the RTH session and the test strategy is started between sessions.

            I tested in real time today and got the same wrong result. I then retested in Playback and got the same wrong result. So the problem is not a Playback issue.

            Comment


              #7
              Hello Camdo,

              I've tested the Swing indicator and I'm finding that its best to use the Values[0] and Values[1] so this works with IsValidDataPoint(). If the data point is not valid the close price is returned instead.

              The values are matching what is on the chart.

              Below is a link to a video of the test.
              https://drive.google.com/file/d/1wbG...w?usp=drivesdk

              And attached is the test strategy.
              Attached Files
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Thanks for that feed back Chelsea. I liked the video.
                Your test script also reports wrong swing values when run as described below:
                1. Run the script from the control panel Strategy tab (not installed on a chart). Trading hours use instrument setting, ( note that CME RTH, and CME ETH give wrong results too).
                2. Set Playback ES 12-18 for 10/25/2018 thru 10/26/2018 starting at 9:20 AM or any time just prior to 9:30 AM.
                3. Enable strategy.
                4. Start Playback

                Attached is a screen shot and output file.
                Observe the 10:05 block of output, at 10:05 the swing low should be valid and reporting 2655.75 but instead the script reports "low invalid".
                Also observe that the 10:00 block at time 10:00 reports low valid 2655.75 but at that time it should be reporting invalid because swing strength is not yet satisfied.
                Also observe that the 9:55 block at time 9:55 reports low valid 2652 which is completely erroneous.

                The problem is to determine if the swing is valid on any bar of the chart. The swing is valid when its strength is satisfied.
                The swing plot paints when the swing strength is satisfied and that is when the data is valid for the last swing instance.
                The test for valid data described in Help does not work for the 10/26/2018 instance described in this reply. I think this should be the focus of discussion.

                Your loop back script SwingTest is confusing because the swing instance and swing strength play on each other in close period swings. It cannot be used practically.

                If the script is run on a chart, the script will report correctly. I believe this problem has something to do with where the script is installed.

                Click image for larger version

Name:	20181113a.png
Views:	213
Size:	159.0 KB
ID:	1039620

                [ATTACH]n1039619[/ATTACH]


                Attached Files

                Comment


                  #9
                  Hello Camdo,

                  The screenshots you have provided do not show the swing indicator on the chart.

                  Have you applied the strategy to the chart so that indicator is added to the chart by the AddChartIndicator() method ensuring that the data and parameters are the same?

                  What are you comparing with to know the values are incorrect?


                  Most likely when you running from the strategies tab, the data or parameters are different so the values are different. The script will behave exactly the same no matter if its added to the chart or to the strategies tab of the data and parameters are the same. My recommendation would be, if you are wanting to see indicator values on a chart that are called from a strategy, apply the strategy to a chart so the data source is the same.
                  Last edited by NinjaTrader_ChelseaB; 06-02-2019, 10:21 PM.
                  Chelsea B.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by jxs_xrj, 01-12-2020, 09:49 AM
                  6 responses
                  3,290 views
                  1 like
                  Last Post jgualdronc  
                  Started by Touch-Ups, Today, 10:36 AM
                  0 responses
                  8 views
                  0 likes
                  Last Post Touch-Ups  
                  Started by geddyisodin, 04-25-2024, 05:20 AM
                  11 responses
                  61 views
                  0 likes
                  Last Post halgo_boulder  
                  Started by Option Whisperer, Today, 09:55 AM
                  0 responses
                  8 views
                  0 likes
                  Last Post Option Whisperer  
                  Started by halgo_boulder, 04-20-2024, 08:44 AM
                  2 responses
                  24 views
                  0 likes
                  Last Post halgo_boulder  
                  Working...
                  X