Announcement

Collapse
No announcement yet.

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.

    Comment


      #3
      Good thoughts. Thx for the hints.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      174 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      328 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      252 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      355 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      181 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Working...
      X