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 jaybedreamin, Today, 05:56 PM
      0 responses
      7 views
      0 likes
      Last Post jaybedreamin  
      Started by DJ888, 04-16-2024, 06:09 PM
      6 responses
      18 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by Jon17, Today, 04:33 PM
      0 responses
      4 views
      0 likes
      Last Post Jon17
      by Jon17
       
      Started by Javierw.ok, Today, 04:12 PM
      0 responses
      12 views
      0 likes
      Last Post Javierw.ok  
      Started by timmbbo, Today, 08:59 AM
      2 responses
      13 views
      0 likes
      Last Post bltdavid  
      Working...
      X