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

Detecting live or non live mode (replay/back testing)

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

    Detecting live or non live mode (replay/back testing)

    How can my script detetct whether it runs in live trading or in replay resp. back testing mode?

    For real time trading I have set time restrictions like

    Code:
     
    if ( (alsoOutsideRegularHours == false && ToTime(DateTime.Now) >= eStartTime && ToTime(DateTime.Now) < eStopTime) || (alsoOutsideRegularHours == true) )
    entryTimeOK = true;
    else
    entryTimeOK = false;
    When in replay mode or backtesting this does not work so I have then

    Code:
     
    if ( (alsoOutsideRegularHours == false && ToTime(Time[0]) > ToTime( 9, 30, 0) && ToTime(Time[0]) <= ToTime(14, 50, 0)) || (alsoOutsideRegularHours == true) )
    entryTimeOK = true;
    else
    entryTimeOK = false;
    As I continually develop my scripts so I dont want to always enter the code and comment out the one part and uncomment the other wheter I use it for life trading or testing.

    So is there a way to check for replay true/fals or back testing true/false, even with a trick?

    Thx

    #2
    To check whether it's running on realtime or historical data, you can work with Historical() - http://www.ninjatrader-support.com/H...istorical.html

    To check if you're in the 'Strategy Analyzer' for example, you can add an input that you can set to 'true' if you're working there and then check for this in your code.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Good thoughts. Thx for the hints.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by George21, Today, 10:07 AM
      0 responses
      2 views
      0 likes
      Last Post George21  
      Started by Stanfillirenfro, Today, 07:23 AM
      8 responses
      23 views
      0 likes
      Last Post Stanfillirenfro  
      Started by DayTradingDEMON, Today, 09:28 AM
      2 responses
      16 views
      0 likes
      Last Post DayTradingDEMON  
      Started by navyguy06, Today, 09:28 AM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by cmtjoancolmenero, Yesterday, 03:58 PM
      8 responses
      32 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X