Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ParabolicSAR Problem in 6.5 in Market Replay

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

    ParabolicSAR Problem in 6.5 in Market Replay

    I believe I have found what may be a bug in the NT 6.5 ParabolicSAR indicator.

    The following code snipit prints the ParabolicSAR value when backtested, but fails to provide a value other than 0 (zero) when run under Market Replay.

    I tried this same test on 6.0 and it ran as expected when backtested and in Market Replay.

    Code:
    [FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] OnBarUpdate()[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
    [SIZE=2][FONT=Courier New]Print(CurrentBar.ToString() + [/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]" ParabolicSAR=["[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] + ParabolicSAR([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0.02[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0.2[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0.02[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] + [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"]"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
    [/COLOR][/SIZE][/FONT]
    In other testing I have done I belive that in Market Replay or when running in real-time the ParabolicSAR indicator fails to return a value.

    Thanks!

    #2
    Any errors in the Control Center logs?

    It prints on my end:
    Code:
    2816 ParabolicSAR=[11984.5805055442]
    2817 ParabolicSAR=[11961]
    2818 ParabolicSAR=[11961.64]
    2819 ParabolicSAR=[11962.2672]
    2820 ParabolicSAR=[11963.696512]
    2821 ParabolicSAR=[11965.06865152]
    Last edited by NinjaTrader_JoshP; 03-20-2008, 09:57 PM.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Interesting. No errors in the CC logs, this is all I get when I start up Market Replay and then run the strategy:

      3/21/2008 7:26 Strategy Starting NinjaScript strategy 'PSARTestv2/addff52653ab4df2b8f6781d3ef5ea5e' : On starting a real-time strategy - StrategySync=WaitUntilFlat EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositio ns Set order quantity by=Strategy
      3/21/2008 7:24 Default Simulation account 'Replay101' reset
      3/21/2008 7:24 Connection Market Replay Connection: Primary connection=Connected Price feed=Connected
      3/21/2008 7:24 Connection Market Replay Connection: Primary connection=Connecting Price feed=Connecting
      On the same machine I ran this under NT 6.5.0.10 (where it did not work) and also tested it under NT 6.0.1000.7 (where it did work).

      I changed the test to use SMA instead of PSAR and it worked as expected in both environments.

      Sounds like my next step is try this same test on the two other computers I have NT installed. I won't be able to do that until this evening.

      Can you try this with a currancy - that is all I have been working with.

      Thanks.

      Comment


        #4
        Works as expected on my end. Not sure what might have caused the issue on your end.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          So, I was able to quicky duplicate the same problem on both my other NT installations. Again, as before, on one machine I have both NT 6.0 and 6.5 - no problem on the 6.0 install, but same problem on the 6.5

          I then tried my other machine where I only have a 6.5 install - same problem.

          BUT......

          I also realized my testing was fairly limited - I was only testing a single currency in a single time frame on a single Market Replay file... so I started to experment with changing these.

          Initally the same promblem persisted.

          Then I had to load some new historical data and try different Market Replay files to try other currencies... I had problem getting the charts to show data... not sure what I did wrong... I try this and that and then.. IT STARTED WORKING!

          All the combinations I tried worked, so I went back and tried my inital senario... and it worked as well.

          I realized I was going through the steps of connecting to Market Replay, opening a chart, starting the strategy, etc. a little different now than I had done before (I am such a creature of habit).

          So... I am moving forward on trying to figure this out on the assumption that when I start up the Market Replay I am doing something to cause the problem.

          I will let you know what I find out...

          Thanks for your help.

          Comment


            #6
            Glad you got it working.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              May be related....

              I don't know if this realted to the same problem I reported below... but I am seeing another anomoly with the ParabolicSAR Indicator.

              When I backtest the following code segment;
              Code:
              [FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] OnBarUpdate()[/SIZE][/FONT]
              [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
              [SIZE=2][FONT=Courier New]Print(CurrentBar.ToString() + [/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]": ParabolicSAR=["[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] + ParabolicSAR([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0.02[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0.2[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0.02[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] + [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"]"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
              [SIZE=2][FONT=Courier New]Print(CurrentBar.ToString() + [/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]": Stochastics.D=["[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] + Stochastics([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]7[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]14[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]3[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]).D[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] + [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"]"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
              [SIZE=2][FONT=Courier New]Print(CurrentBar.ToString() + [/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]": Stochastics.K=["[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] + Stochastics([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]7[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]14[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]3[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]).K[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] + [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"]"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
              [SIZE=2][FONT=Courier New]Print(CurrentBar.ToString() + [/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]": SMA=["[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] + SMA([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]10[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] + [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"]"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
              [SIZE=2][FONT=Courier New]Print([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"*********************************************"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
              [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
              I consitantly find that when evaluating the values for the LAST bar of the back test data that the value for Stochastics and SMA are printed... however, the value for ParabolicSAR is always zero.

              Again, I tried this on both of my 6.0 installations and it worked ok... I got a non-zero value for my last bar ParabolicSAR.

              But in all three of my 6.5 installations, my final bar ParabolicSAR call always returns zero. In fact, if you modify these indicators to print out a debug statement each time their individual OnBarUpdate() method is called you will also find that the ParabolicSAR OnBarUpdate() is not entered when called from the last bar in the backtest.

              I have attached a sinpit of backtest data (1 Day price values for EURUSD for 2007) which manifest this problem. I have tested this with a varity of time frames and currency backtest data and consitantly have the same result.

              Again, I hope I am not wasting your time, but I would really like to know why this is happening.

              Thanks for all your help,

              kgillis23
              Attached Files
              Last edited by kgillis23; 03-22-2008, 10:33 PM.

              Comment


                #8
                Again, works as expected on my end. Please post a simple-as-possible strategy along with exact steps to reproduce. Information like instrument, time period, strategy settings etc. will be useful.

                Also, your attached file shows a log with all numbers. No sign of zero values.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Steps to Reproduce the "Last Bar of ParabolicSAR is wrong" Scenario:

                  Import the attached ParabolicSARTest.zip NinjaScript strategy file. It is a strategy that does nothing more than use the Ninjascript Print() method to output the ParabolicSAR(0.02,0.2, 0.02)[0] value with each OnBarUpdate() call.

                  Import the $EURUSD.txt Historical Data file, which is the attached file in post #7 of this thread (It contains the daily OHLC values for the currency $EURUSD for the year 2007). Use this file to backtest the ParabolicSARTest strategy.

                  If you have not done so already, from the Instrument Manager add the currency $EURUSD to your own list of Instruments. Do not change any of the default settings.

                  From a new Strategy Analyzer backtest $EURUSD with the following settings:
                  Strategy: ParabolicSARTest
                  Type: Day
                  Value: 1
                  From: 1/1/2007
                  To: 1/1/2008
                  Exclude weekend: False
                  Include commission: False
                  Label: ParabolicSARTest
                  Min. bars required: 20
                  File type: Default
                  Slippage: 0
                  Entries per direction: 1
                  Entry handing: AllEntries
                  Set order quantity: by strategy
                  Time in force: Gtc
                  The tail end of your test should display the following in the Output Window:
                  300: ParabolicSar[0]=[1.46317152]
                  301: ParabolicSar[0]=[1.4582160768]
                  302: ParabolicSar[0]=[1.453263182976]
                  303: ParabolicSar[0]=[1.44920181004032]
                  304: ParabolicSar[0]=[1.44587148423306]
                  305: ParabolicSar[0]=[1.44314061707111]
                  306: ParabolicSar[0]=[1.4414]
                  307: ParabolicSar[0]=[1.4307]
                  308: ParabolicSar[0]=[1.43204]
                  309: ParabolicSar[0]=[1.4344916]
                  310: ParabolicSar[0]=[1.437740272]
                  311: ParabolicSar[0]=[1.44072905024]
                  312: ParabolicSar[0]=[0]
                  NOTE: The final ParabolicSAR value is zero.

                  Again: I cannot duplicate this problem in NT 6.0, but it happens to me consistently (every time) I backtest in NT 6.5 (I have tried it on three different machines).
                  Attached Files
                  Last edited by kgillis23; 03-24-2008, 05:10 PM.

                  Comment


                    #10
                    I have also found...

                    Not to get things too mixed up, but in reference to my original problem where the ParabolicSAR was not providing any valid values when run in Market Replay....

                    I have found this to take place when ever the value for CalculateOnBarClose() is set to false in the Strategies dialog box accessed via the drop down menu following a right mouse click from within a chart window. If CaclulateOnBarClose() is set to true then the values provided by ParabolicSAR are correct. When testing this I leave all other values at their defaults.

                    Again, it works as expected in NT 6.0, but not in 6.5

                    You can try this with the ParabolicSARTest strategy attached in my prior posting aginst a valid Market Replay file (Apparently I can not upload a Market Replay (*.ntm) file). If you email me I will be glad to send you one you can run this test against.

                    Thanks for all your help,

                    Keith
                    Last edited by kgillis23; 03-24-2008, 05:51 PM.

                    Comment


                      #11
                      Keith,

                      Josh is out for a few days and will follow back up on this later this week.
                      RayNinjaTrader Customer Service

                      Comment


                        #12
                        Hi Keith,

                        I am using your exact data set, but don't know why your print goes all the way to 312. Mine only goes to 310. Please add a Time[0] print to your print list. Here is what my print looks like:
                        Code:
                        12/18/2007 12:00:00 AM 300: ParabolicSar[0]=[1.46317152]
                        12/19/2007 12:00:00 AM 301: ParabolicSar[0]=[1.4582160768]
                        12/20/2007 12:00:00 AM 302: ParabolicSar[0]=[1.453263182976]
                        12/21/2007 12:00:00 AM 303: ParabolicSar[0]=[1.44920181004032]
                        12/23/2007 12:00:00 AM 304: ParabolicSar[0]=[1.44587148423306]
                        12/24/2007 12:00:00 AM 305: ParabolicSar[0]=[1.44314061707111]
                        12/25/2007 12:00:00 AM 306: ParabolicSar[0]=[1.4414]
                        12/26/2007 12:00:00 AM 307: ParabolicSar[0]=[1.4307]
                        12/27/2007 12:00:00 AM 308: ParabolicSar[0]=[1.43204]
                        12/28/2007 12:00:00 AM 309: ParabolicSar[0]=[1.4344916]
                        12/30/2007 12:00:00 AM 310: ParabolicSar[0]=[1.437740272]
                        As you can see, it ends at 12/30. This is correct since the last bar is 12/31 which is the last bar to be used in the data set. Since CalculateOnBarClose is true when backtesting, this last bar is not processed yet.

                        You mentioned .ntm file extension. This suggests to me that you are running on a pretty old version of NT6.5 beta. Please update to the latest version.
                        Josh P.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Pattontje, Yesterday, 02:10 PM
                        2 responses
                        14 views
                        0 likes
                        Last Post Pattontje  
                        Started by flybuzz, 04-21-2024, 04:07 PM
                        17 responses
                        229 views
                        0 likes
                        Last Post TradingLoss  
                        Started by agclub, 04-21-2024, 08:57 PM
                        3 responses
                        17 views
                        0 likes
                        Last Post TradingLoss  
                        Started by TradingLoss, 04-21-2024, 04:32 PM
                        4 responses
                        44 views
                        2 likes
                        Last Post TradingLoss  
                        Started by cre8able, 04-17-2024, 04:16 PM
                        6 responses
                        56 views
                        0 likes
                        Last Post cre8able  
                        Working...
                        X