Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

detecting backtest or real time simulation

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

    detecting backtest or real time simulation

    Hi,

    Is there a way to detect in Ninja script whether it's executing in a backtest or real time simulation?

    thanks
    Dave

    #2
    This might be of value: http://www.ninjatrader-support.com/H...istorical.html

    Comment


      #3
      Thanks for that. That's so close, but won't quite do it for me.

      I have this piece of code to return from bar update when running live but processing historical data at startup:

      if (Time[0] < startTimestamp)
      {
      Print("Ignoring: " + Time.ToString());
      return;
      }

      This is so my strategy does not execute trades in the historical data when starting up running live. I have to comment the above code out when running backtest, and was wondering if there's a way I can work out whether I'm in backtest or running live.

      thanks
      Dave

      Comment


        #4
        Not sure I follow. Link I posted should do what you are looking for: not placing trades on the historical part of your bar series

        Comment


          #5
          Correct, that's what I want to do when running live, but when running backtest, I clearly do want all the trades to be placed on historical data otherwise there wouldn't be any trades executed at all.

          Comment


            #6
            On backtest all trades are placed on historical data.

            Comment


              #7
              Yes, but they wouldn't be if I had a line saying "if historical then return", which is the line I need to have in my code to stop historical trades in live mode. I'm running the same strategy here. In live, I want no trades on historical, in backtest, I do - same code! If I detect and reject trades for historical data in live, the same code would reject all trades in backtest.

              Comment


                #8
                Unfortunately this is not supported.

                Comment


                  #9
                  Thanks.

                  I'll be surprised if there isn't some way of doing it. For now I guess I'll just add a parameter to tell the script.

                  Dave

                  Comment


                    #10
                    in my cs i have

                    if ( !Historical || StrategyAnalyzer == "on" ) .....

                    this way I do not process historical data when running live....and when I run a backtest, one of the settings I turn on is my flag/switch StrategyAnalyzer....

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by inanazsocial, Today, 01:15 AM
                    1 response
                    5 views
                    0 likes
                    Last Post NinjaTrader_Jason  
                    Started by rocketman7, Today, 02:12 AM
                    0 responses
                    10 views
                    0 likes
                    Last Post rocketman7  
                    Started by dustydbayer, Today, 01:59 AM
                    0 responses
                    1 view
                    0 likes
                    Last Post dustydbayer  
                    Started by trilliantrader, 04-18-2024, 08:16 AM
                    5 responses
                    23 views
                    0 likes
                    Last Post trilliantrader  
                    Started by Davidtowleii, Today, 12:15 AM
                    0 responses
                    3 views
                    0 likes
                    Last Post Davidtowleii  
                    Working...
                    X