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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      647 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      368 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      108 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      571 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      573 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X