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

Automated strategy: live simulated, strategy analysis, market replay. HELP ME

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

    Automated strategy: live simulated, strategy analysis, market replay. HELP ME

    Hello I am creating an automatic strategy with builder that according to my backtesting gives very good results.
    The thing is that I put it live with a sim account, I trade from 9:07 AM to 21:19 PM Spanish time.

    At the end of the day I downloaded the market data and made an analysis with the strategy analyzer with the same start and end time with the same parameters and it gave me quite different results.

    then I put my strategy in market replay and it also gave me different results than when I traded live.

    the results of the replay are quite similar to the analyzer but in live the results are disastrous many trades coincide in the time that is executed but others do not.

    I use UNIRENKO charts and buy and sell to market with a limit order.

    I am attaching some EXEL exported from ninjatrader of the results and trades made from live trades, with strategy analyzer and market replay.

    so that you can check the results and trades and tell me how I can solve this problem.

    I would like to be able to analyze a strategy and get results more or less equal to my backtesting, or at least 99% similar.

    PS: the instrument and the parameters are the same, in fact I did a test of the MES instrument and the same thing happened to me, the results are totally different.

    Can you help me?


    Translated with www.DeepL.com/Translator (free version)
    Attached Files

    #2
    Hello JesusSanchez,

    Thank you for your post.

    Please review the help guide document on the differences on real-time vs backtest (historical).
    http://ninjatrader.com/support/helpG...ime_vs_bac.htm

    When in historical data, only the Open, High, Low, and Close will be available 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' and the script will not have the intra-bar information to accurately fill an order at the exact price and time.

    Below is a link to the help guide on Calculate.
    https://ninjatrader.com/support/help.../calculate.htm

    To improve the accuracy of a backtest, you may use Tick Replay along with an added 1-tick series to have logic processed intra-bar and have orders filled intrabar.

    Tick Replay would be used to have the logic process OnEachTick or OnPriceChange with historical data, but this does not allow for intra-bar order fills. You would need to add a single tick data series and submit orders to that single tick data series for a strategy that uses Tick Replay.

    High Order Fill Resolution allows for intra-bar order fills with historical processing, but is not compatible with Tick Replay.

    Please reference the SampleIntrabarBacktest example and the following Help Guide links for more information.

    SampleIntrabarBacktest 'Backtesting NinjaScript Strategies with an intrabar granularity' - https://ninjatrader.com/support/helpGuides/nt8/backtesting_ninjascript_strate.htm

    Using Playback with Market Replay data — https://ninjatrader.com/support/help...WithReplayData

    TickReplay - http://ninjatrader.com/support/helpG...ick_replay.htm

    Developing for Tick Replay - http://ninjatrader.com/support/helpG...ick_replay.htm

    Additional information may be found in this NinjaTrader Forum post —
    https://ninjatrader.com/support/foru...mance?t=102504

    Please let us know if we may be of further assistance.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      It is not very clear to me. Let's go by parts please.

      OnBarUpdate is the current bar?

      1) ok I added an additional data series of 1 TICK, this data series goes as the main? (attached screenshot)

      2) i have set the calculation of the bar to OnEachTick (attached screenshot)

      *now with these two steps it will calculate my strategy in historical with more precision?
      *next step to execute orders in the market replay I need to download SampleIntrabarBacktest for NT8

      3) I have already downloaded SampleIntrabarBacktest, it is placed in strategies, I get 2 parameters fast and slow. (attached screenshot)

      *What parameters do I have to put in Slow and Fast?

      4) in the serious data of my chart I have to put the UNIRENKO and one of 1 tick for it to work (attached screenshot)


      5) is it ok? Correct me if I am wrong, what are the next steps to make it work in market replay?


      PS: the following links don't work it tells me that it didn't find the page

      http://ninjatrader.com/support/helpG...ime_vs_bac.htm
      https://ninjatrader.com/support/help.../calculate.htm



      Translated with www.DeepL.com/Translator (free version)
      Attached Files

      Comment


        #4
        Hello JesusSanchez,

        Thank you for your note.

        OnBarUpdate() is a method that the strategy processes when a new bar is formed. The frequency at which OnBarUpdate() calculates is determined by the Calculate mode you use (OnBarUpdate, OnEachTick, OnPriceChange). Below is a link to the help guide on Calculate.

        Calculate - https://ninjatrader.com/support/helpGuides/nt8/calculate.htm

        You would not be able to accomplish adding intrabar granularity using the Strategy Builder. You would have to unlock your code from the Strategy Builder using the 'Unlock code' button followed by manually coding this into your strategy. The SampleIntrabarBacktest script is an example of how to add intrabar granularity. To view the code for SampleIntrabarBacktest, open a New > NinjaScript Editor window, double-click the Strategies folder, and select the SampleIntrabarBacktest script.

        See the help guide links below for more information.

        Discrepancies between realtime vs backtest (historical) - https://ninjatrader.com/support/help...ime_vs_bac.htm
        Backtesting strategies with intrabar granularity - https://ninjatrader.com/support/help...ipt_strate.htm
        Developing for Tick Replay - https://ninjatrader.com/support/help...ick_replay.htm

        Additional information may be found in this NinjaTrader Forum post —
        https://ninjatrader.com/support/foru...mance?t=102504

        Let us know if we may assist further.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          I understand, I have to unlock the code of my strategy and from SampleIntrabarBacktest copy and paste the code to my strategy.

          But where does the code go? I don't understand programming.

          If I copy and paste the code, will it be all there?

          If I unlock the strategy then I can't make adjustments with the strategy builder?

          Comment


            #6
            Hello JesusSanchez,

            Thank you for your note.

            You would not necessarily copy and paste the code for the SampleIntrabarBacktest strategy into your script. That strategy is meant to be an example of how to add intrabar granularity to a strategy. The way this script works is we use AddDataSeries() in State.Configure to add 1-Tick series to the strategy. Then a BarsInProgress == 0 check is used to determine that current data series that is processing is the primary series. Our order conditions are then created and we submit the order to the added secondary Tick series (BarsInProgress 1).

            In your script, you would need to use AddDataSeries() within State.Configure to add a 1-Tick data series, then in OnBarUpdate() you would use a BarsInProgress == 0 check before your order entry conditions, you would set up your order entry conditions, and use something like EnterLong() with a value of 1 for the barsInProgress parameter for your entry order.

            See the help guide links below for more information.
            AddDataSeries - https://ninjatrader.com/support/help...dataseries.htm
            BarsInProgress - https://ninjatrader.com/support/help...inprogress.htm
            EnterLong - https://ninjatrader.com/support/help.../enterlong.htm

            Please note that you would not be able to make adjustments to the strategy using the Strategy Builder if you unlock the code from the Strategy Builder.


            You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our NinjaTrader Ecosystem team follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request.

            Let us know if we may assist further.


            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              Is the professional NinjaScript consultant to help me for free?

              Comment


                #8
                Hello JesusSanchez,

                Thank you for your note.

                I cannot say for sure as each consultant is different. However, if you have questions about NinjaScript consultants and their services, please write in to VendorSupport [AT]ninjatrader.com and they will be able to assist you.

                Please let us know if you have further questions.
                Brandon H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by FrazMann, Today, 11:21 AM
                0 responses
                2 views
                0 likes
                Last Post FrazMann  
                Started by geddyisodin, Yesterday, 05:20 AM
                8 responses
                51 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by cmtjoancolmenero, Yesterday, 03:58 PM
                10 responses
                36 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by DayTradingDEMON, Today, 09:28 AM
                4 responses
                24 views
                0 likes
                Last Post DayTradingDEMON  
                Started by George21, Today, 10:07 AM
                1 response
                19 views
                0 likes
                Last Post NinjaTrader_ChristopherJ  
                Working...
                X