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

Market Replay

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

    Market Replay

    Hi,

    How do I know if I am using market replay?

    Thanks

    #2
    Hello kezyclaire,

    Thank you for your inquiry.

    Using Market Replay data is a process that you would be very aware of. You have to first download or record the data, and then connect to a special connection called the Playback Connection in order to use it.

    Please view publicly available the video tutorial at the link below for a demonstration of how to use the Playback connection;

    https://www.youtube.com/watch?v=OHwR...el=NinjaTrader

    Additional information for setting up and using Playback may be found in our help guide, which I've provided at the link below;

    https://ninjatrader.com/support/help...connection.htm
    Zachary S.NinjaTrader Customer Service

    Comment


      #3
      Hi Zachary,

      I mean, how do I code in a strategy if I am using Market Replay. I can't find State for Market Replay.


      Thanks

      Comment


        #4
        Hi, thanks for your question. The account name will always be "Playback101" while connected to playback:

        if(Account.Name == "Playback101")
        Print("Running in playback mode");
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          or

          Code:
          if ( Cbi.Connection.PlaybackConnection != null ) {  bool _MarketReplay = true; }

          Comment


            #6
            Hi balltrader,

            Great! Thanks!

            Comment


              #7
              I log playback bar time and time played


              A few snippets I use in all my code

              private string BarTime;
              private bool isPlayBack = false; ///private string BarTime=@"1900-01-01";​


              else if (State == State.DataLoaded)
              {
              ema01 = EMA(EmaTrailPeriod);
              sma30 = SMA(30);
              stdDev30 = StdDev(30);
              if (Connection.PlaybackConnection==null) {
              Print("---------------------------------------------------------------------------------------NOT Playback---------------------------------->");
              isPlayBack=false; }
              else {
              Print("---------------------------------------------------------------------------------------YES Playback==================================>");
              isPlayBack=true;
              }//
              isPlayBack=true;
              }​

              protected override void OnBarUpdate()
              {
              BarsRequiredToPlot = 20;
              if (BarsInProgress != 0) return;
              if (isPlayBack) { BarTime = Bars.GetTime(CurrentBar).ToString() +","+ DateTime.Now.ToString() +","; }
              else { BarTime = DateTime.Now.ToString() +","+ BarTime +","; }///Calc and re-use
              BarTime=DateTime.Now.ToString();
              }

              Print(BarTime+" WhatEVER... "+Instrument.FullName);​

              Comment


                #8
                Eat my Shorts. Your code in OBU has design issues

                Comment


                  #9
                  Can you elaborate? Can you fix. It has worked for me. I can always improve my code. ALWAYS.

                  Comment


                    #10
                    Hi BartMan,

                    Why do you need to check if you're in Market Replay? I think, other with more experience will likely chime in with counter examples, that a strategy should not care if it is in Market Replay.

                    If you're looking for the current time, either in Market Replay or live, then use Time[0]. That will provide either the current Market Replay time or live time, as appropriate.

                    If you're looking to avoid your strategy executing trades on the close of bars when loading the strategy, then do this:

                    protected override void OnBarUpdate() {
                    if (CurrentBar < BarsRequiredToTrade || State == State.Historical) return;

                    // If your code is executing here, then you know you have either started the replay or live!
                    ... {your strategy code} ...
                    }

                    ​State == State.Historical
                    will be true up until the point of your Playback control Start Date and Time (or the Go to... date/time).

                    Hope that helps!
                    Matt

                    Comment


                      #11
                      Here is what you want to know:

                      bool IsPlayback = (Cbi.Connection.PlaybackConnection != null);
                      DateTime PlaybackTime = (IsPlayback ? Cbi.Connection.PlaybackConnection.Now : DateTime.MinValue);
                      Bruce DeVault
                      QuantKey Trading Vendor Services
                      NinjaTrader Ecosystem Vendor - QuantKey

                      Comment


                        #12
                        Thanks Bruce!

                        Matt, Why do I care what account? I log the account for my entries and exits I use playback to validate my signals. I had 113 signals worth > $500 in playback. I log signals and trades to a DB.
                        I logged 108,810 signals from March 9 forward.


                        I trade 2 accounts both made >$600/day.

                        I have if (State == State.Historical) return; in some of my code (my strategies) but that will help not populating the DB with Garbage. I log directly from my indicator. I need to add that there.

                        Comment


                          #13
                          I should probably note that the playback time is only accurate to the nearest second. It does not have milliseconds, even if there are milliseconds in the data.
                          Bruce DeVault
                          QuantKey Trading Vendor Services
                          NinjaTrader Ecosystem Vendor - QuantKey

                          Comment


                            #14
                            Please do not post more than once - this is a duplicate of https://forum.ninjatrader.com/forum/...95#post1246395
                            Bruce DeVault
                            QuantKey Trading Vendor Services
                            NinjaTrader Ecosystem Vendor - QuantKey

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Christopher_R, Today, 12:29 AM
                            0 responses
                            9 views
                            0 likes
                            Last Post Christopher_R  
                            Started by sidlercom80, 10-28-2023, 08:49 AM
                            166 responses
                            2,235 views
                            0 likes
                            Last Post sidlercom80  
                            Started by thread, Yesterday, 11:58 PM
                            0 responses
                            3 views
                            0 likes
                            Last Post thread
                            by thread
                             
                            Started by jclose, Yesterday, 09:37 PM
                            0 responses
                            8 views
                            0 likes
                            Last Post jclose
                            by jclose
                             
                            Started by WeyldFalcon, 08-07-2020, 06:13 AM
                            10 responses
                            1,415 views
                            0 likes
                            Last Post Traderontheroad  
                            Working...
                            X