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 all historical data

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

    reload all historical data

    hello

    is there a script where I can put in the code to reload all historical data after every trade? because when I reload manually the chart and entries/exit are different than what happened in real life.

    #2
    Hello babouin77,

    Thank you for your reply.

    While there is a ReloadAllHistoricalData method, this is not supported to be called outside of OnConnectionStatusUpdate and may cause undesired behavior.

    https://ninjatrader.com/support/help...oricaldata.htm

    The better question is are the order prices/times shown changing from the submission price shown on the log tab?

    Keep in mind that reloading all historical data will stop and restart your running strategies. When the strategy is restarted, it won't show you the actual live trades that were taken, it will show you what it calculated as historical trades on that data. When processing over historical data, it's essentially running a backtest, much like if you tested the strategy using the Strategy Analyzer. Fills on the historical data are determined based on 4 data points, OHLC of a bar since that is the only information that is known and there will be no intra-bar data. This means actions cannot happen intra-bar, fills cannot happen intra-bar. All prices and actions come from and occur when the bar closes as this is all the information that is known.

    Because of this, OnBarUpdate will only update 'On bar close' as it does not have the intra-bar information necessary for 'On price change' or 'On each tick'.

    Also, here is a link to the differences on real-time vs backtest (historical).
    http://ninjatrader.com/support/helpG...ime_vs_bac.htm

    Adding intra-bar granularity can help with this.

    Intra-bar granularity adds a second data series such as a 1 tick series so that the strategy has finer granularity in the historical data in between the OHLC of the primary series. This allows for more accurate trades by supplying the correct price at the correct time for the order to fill with.

    In NinjaTrader 8, there have been two new enhancements so that programmers do not have to manually add this secondary series and code the script to for high accuracy fills (Order Fill Resolution) and for intra-bar actions (TickReplay).

    Here is a link to our forums that goes into depth on using Order Fill Resolution and Tick Replay to ensure your backtests are as close to real time results as possible:

    https://ninjatrader.com/support/foru...mance?t=102504

    High Fill Order Resolution and TickReplay cannot be used together. If it is necessary to have both, it is still possible to add intra-bar granularity to a script in the code itself for order fill accuracy and use TickReplay to update indicators with Calculate set to OnPriceChange or OnEachTick historically.

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      well the strategy is for the indicators and even the indicators positions and pricing is changing when i reload all data and sometimes the trades that were taken for example when adx cross 21 is not taken because when i reload adx never crossed 21...

      Comment


        #4
        Hello babouin77,

        Thank you for your reply.

        Can you supply screenshots of the discrepancies you're experiencing?

        Thanks in advance; I look forward to assisting you further.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          the first image notice how ADX dips below the 21... that one is with data reloaded... a trade was taken
          the second image is adx above 21 and never dips below 21... if I reload it will be fixed... no trades on this one

          the indicator is DM on NQ.

          Attached Files

          Comment


            #6
            Hello babouin77,

            Thank you for your reply.

            Is your PC clock properly synced? I ask because I am seeing differences between the bars on the two charts.

            Please use the steps below to change/check your Time Zone and sync the PC clock:
            • Shutdown NinjaTrader
            • Right-click the clock in the lower right corner of your desktop
            • Select Adjust date/time
            • For Windows 10 click 'Date, Time, and regional formatting' -> Then click 'Additional date, time, and regional settings' -> then click 'Set the time and date'
            • Select the 'Internet Time' tab at the top
            • Set the server to time.nist.gov and then click Update.
            • If the message that appears says successful your PC clock should now be updated.
            • If not, select a different server from the Server: drop-down and try again (repeat until one of the servers is successful)

            After updating the PC clock, please restart NinjaTrader, then right-click the chart and select Reload All Historical Data. Once complete, please test with the same strategy on real time data without refreshing, take a screenshot, then refresh the historical data and take another screenshot.

            Thanks in advance; I look forward to assisting you further.
            Kate W.NinjaTrader Customer Service

            Comment


              #7
              ok i did. time synced properly and reloaded NT... i will test tomorrow and see if I get different trades before reloading... does it have to do because im using heikenashi candles?
              Attached Files

              Comment


                #8
                Hello babouin77,

                Thank you for your reply.

                The Heiken-Ashi candle presents false information concerning each candle.

                Here is how the Heiken-ashi is calculated:
                HAClose = ((Open[0] + High[0] + Low[0] + Close[0]) * 0.25); // Calculate the close
                HAOpen = ((HAOpen[1] + HAClose[1]) * 0.5); // Calculate the open
                HAHigh = (Math.Max(High[0], HAOpen[0])); // Calculate the high
                HALow = (Math.Min(Low[0], HAOpen[0])); // Calculate the low

                When you place an order it can only fill on real price data.

                When you reload the historical data NinjaTrader does not know what the base data is that created the Heiken-Ashi bar and it will process the updated historical data based on the false information presented.

                A work around would be to use the indicator HeikenAshi8 in your strategy and use standard bars in the chart/analyzer so that the backtest results are based on real data points and your strategy can use the Heiken-ashi values for the conditional entries.

                The HeikenAshi8 indicator can be found on our publicly available User App Share here: https://ninjatraderecosystem.com/use...heiken-ashi-8/

                Please let us know if we may be of further assistance to you.

                The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
                Kate W.NinjaTrader Customer Service

                Comment


                  #9
                  so ur saying to use regular candles on the chart and over lay this indicator? will that affect the strategy etc? because i notice when I have heikenashi candles the indicators show different values than the regular candles.

                  Comment


                    #10
                    like when you say use the indicator in your strategy... im not sure I am following you

                    Comment


                      #11
                      so currently I use 1 min heikenashi and i have the indicator DM that all my entries are based on the indicator DM... how can I use the indicator DM with the heikenashi8 indicator you suggested?

                      Comment


                        #12
                        Hello babouin77,

                        Thanks for your replies.

                        It's a little late in the day today, but I will work up an example showing how to use the HeikenAshi8 values to calculate indicators from within a strategy. I should have that for you tomorrow.

                        Thanks in advance for your patience; I look forward to assisting you further.
                        Kate W.NinjaTrader Customer Service

                        Comment


                          #13
                          ok thank you. i appreciate it. but what I was trying to say is that I do not use the candles to enter or exit... i use the DM to enter trades and the parabolic SAR to exit.

                          Comment


                            #14
                            please dont forget about me today. thank you

                            Comment


                              #15
                              Hello babouin77,

                              Thank you for your patience.

                              In looking into the indicators you're using both of these will use the underlying High, Low, Open and Close of the data series to process and you can't just use the HeikenAshi8 indicator as an input since it has 4 plots, for the calculated OHLC of the heiken ashi bars it creates. You'd need a modified version of the indicator. I've created modified versions of these that are hardcoded to use the HeikenAshi8 values and then created an example script you can test that enters long if the ADX plot of the DM indicator is below 21 and submits a stop order that follows the path of the modified Parabolic SAR. I'd take a look at the modified indicators to understand how to use the HeikenAshi8 values to modify similar indicators.

                              Please let us know if we may be of further assistance to you.
                              Attached Files
                              Kate W.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by tkaboris, Today, 08:01 AM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by Lumbeezl, 01-11-2022, 06:50 PM
                              31 responses
                              817 views
                              1 like
                              Last Post NinjaTrader_Adrian  
                              Started by xiinteractive, 04-09-2024, 08:08 AM
                              5 responses
                              15 views
                              0 likes
                              Last Post NinjaTrader_Erick  
                              Started by swestendorf, Today, 11:14 AM
                              2 responses
                              6 views
                              0 likes
                              Last Post NinjaTrader_Kimberly  
                              Started by Mupulen, Today, 11:26 AM
                              0 responses
                              7 views
                              0 likes
                              Last Post Mupulen
                              by Mupulen
                               
                              Working...
                              X