Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Reload chart data

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

    Reload chart data

    I have a both a problem and a potential solution that I need some guidence on.

    Problem: I am running a real time strategy and the alerts are significanly differenct than back testing with historical data. It is a 60 min chart and calculateonbarclose = true, PC clock is fine.

    Potential solution: Upon each bar close, I manually reload the chart data with the now historical data through the UI. This aligns my "manually intervened psuedo-realtime strategy" with the historical backtesting.

    Upon bar close I want to redraw with historical data. How can this be accomplished with code? I thought I ran accross this in the forum at one point but cannot locate it.

    Thanks.

    #2
    Hi there, what do you mean by "manually intervened pseudo-realtime strategy"? It is highly recommended that you do not intervene with strategy orders.

    In addition, some real-time vs backtest discrepancies are expected. See this help guide reference for details.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Austin, Thanks for the reply.

      Hi there, what do you mean by "manually intervened pseudo-realtime strategy"? It is highly recommended that you do not intervene with strategy orders.
      What I meant - As an experiment to troubleshoot my issue, I reloaded the chart/strategy data half way through the day. Upon doing this, bars previous to current bar and my plot values changed. The strategy that I am running is single instrument, and uses only the 60 min "Close[0]" data.


      My issue is that I'm not just seeing "some" differences, but rather very significant differences. Differences that negate the usefullness of backtesting. (I've have already read all the info in the link provided previously and it does not accurately describe what I'm seeing.)

      I plot "myIndicator" in the strategy. When it is running realtime the value of "myIndicator" x but when drawn with historical data it is y and the difference is significant.

      Running 60min bars accessing only "Close[0]" data should be as simple as they come, but realtime vs. historical is deviates significantly all the time.

      Is there a way to access historical bar data after every bar close?

      I recently had to switch data vendors due to bad volume data that was confirmed with the vendor. Could this be another data problem?? For a product that relies on data integrity I am blown away by what I am seeing.

      If I cannot get around this by somehow using historical data, I will go through the rigmarole of print statements again to narrow it down.

      Additionally, I'm using data from a data-feed providor. Am I correct to assume it contains a time stamp?
      Last edited by eleven; 08-14-2009, 01:19 PM.

      Comment


        #4
        eleven, just to make sure, you've confirmed the data is not the same after reloading?

        Can you also try reloading just your indicator and not the data (right-click -> Reload NinjaScript)?
        AustinNinjaTrader Customer Service

        Comment


          #5
          Austin, What I know for sure is this:

          I have my strategy running on SPY, 60min. In panel 2, I have my sqiggly line indicator ONLY using Close[0] data manipulated mathmatically. When I reload the data, the data label (or balloon, bubble??) at the right of the panel changes values often by alot on previous bar.

          What I didn't determine if the actual OHLC data changes. If my squiggly line that relies on Close[0] data changes, I would assuem the OHLC data to change as well.

          I will confirm this early next week using print statements and report back. I will also try reloading just the indicator and not the data as you suggest.

          Comment


            #6
            Thank you eleven. When you confirm, please let us know.
            AustinNinjaTrader Customer Service

            Comment


              #7
              I have 3 pictures of 3 different strategies of what I am observing. The 3 strategies are on all 3 pictures.

              (Edit: You cannot read the picture names but they go from left to right)
              Pic#1 - "realtime.jpg": This is a picture of the 3 strategies run in real time during session. (Left picture)

              Pic#2 - "reloadninjascript.jpg": This is a picture of the 3 strategies after I selected reload NinjaScript from the UI after session close.

              Pic#3 - "reloadhistoricaldata.jpg": This is a picture of reloading historical data after I already reloaded NinjaScript.

              Conclusions from the pictures are:
              1. All 3 strategies behave similarly. (the strategies include simple single instrument to complex multiple instrument)
              2. During realtime monitoring the strategies do not work
              3. During historical backtesting or drawing with historical data the strategies do work.
              4. Upon selecting "reload NinjaScript" from the UI it appears to correct the problem and display accurately.
              5. Even though I "reloaded the historical data" (pic#3) after "reloading NinjaScript" (pic#2), I suspect it would have the same effect.
              6. The OHLC data "appears" to be correct and not change (visually).

              I will run this experiment with a built in strategy or from a proven strategy from the file sharing section from the forum next week. I do believe my 3 strategies in the pictures should work fine.

              Any ideas based on this information? I keep going back to it has to be something simple that I'm missing, but I'm out of ideas on what to check.
              Attached Files
              Last edited by eleven; 08-15-2009, 09:23 AM.

              Comment


                #8
                eleven,

                Not sure what you want us to be focusing on with your screenshots. Realtime looks fine.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  I will try to illustrate this better. Here is one picture of strategy "3" with realtime and historical data. Realtime on the left and historical on the right.

                  Notice the large difference of plot line values indicated by the red and blue lines in panel 3 for 8/14. The difference is -2.78 vs -70.17. The day prior on 8/13 they are equal indicated by a yellow line using historical data.

                  Whenever I reload ninjascript or reload historical data selected from the UI the realtime strategy plot value change (as illustrated in the picture). The OHLC data does not appear to change.

                  I need some ideas on what to try next. Today I am running some "stock" strategies found in the forum to see if they exhibit the same behavior.
                  Attached Files

                  Comment


                    #10
                    The strategy plot technique is meant to be used in realtime only, so when you 'reload' it would change results as you have noticed.

                    When running a strategy on a chart you may find the need to plot values onto a chart. If these values are internal strategy calculations that are difficult to migrate to an indicator, you can use the following technique to achieve a plot. NinjaTrader 8 With NinjaTrader 8 we introduced strategy plots which provide the ability
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      As always, I appreciate the prompt reply.

                      Today I've run 2 strategies (dmiMA and SampleMACrossOver) referencing indicators. Realtime matched historical data as you would expect.

                      I am going to run another test.
                      Last edited by eleven; 08-17-2009, 10:27 PM.

                      Comment


                        #12
                        I got a little further on troubleshooting this. I tested each calculation in the strategy realtime vs. historical. Everything was matching up perfectly until an EMA calculation below:

                        double bbhist = EMA(Var2,Smoothing)[0];
                        Var3.Set(bbhist);
                        "Var2" is calculated accurately in realtime but "Var3"is not.

                        Any ideas?
                        Last edited by eleven; 08-18-2009, 02:13 AM.

                        Comment


                          #13
                          Does it change things when you do not use the EMA (that would reach back almost infinitely), but for example an SMA or WMA?
                          BertrandNinjaTrader Customer Service

                          Comment


                            #14
                            I ran a quick test. It looks like SMA and WMA have the same error as EMA. By days end, I will run tests to determine if this is limited to custom dataseries calculations.

                            Am I correct to assume this is a bug? Any ideas on how to overcome this? If this is a bug, can it be resolved?

                            Also, I will try to mathmatically calculate an SMA and EMA within my strategy to determine if I can get it to work realtime. Again, this seems to affect realtime and not historical data.

                            Comment


                              #15
                              eleven, ok please let me know how it goes. To investigate for you a bit further, I would probably need to run this on my end on live data and compare, if you like contact me at support at ninjatrader dot com Attn Bertrand.
                              BertrandNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by pechtri, 06-22-2023, 02:31 AM
                              9 responses
                              122 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by frankthearm, 04-18-2024, 09:08 AM
                              16 responses
                              66 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by habeebft, Today, 01:18 PM
                              1 response
                              5 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by benmarkal, Today, 12:52 PM
                              2 responses
                              14 views
                              0 likes
                              Last Post benmarkal  
                              Started by f.saeidi, Today, 01:38 PM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Working...
                              X