NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 06-17-2009, 06:43 AM   #1
BillCh
Member
 
Join Date: Feb 2009
Posts: 68
Thanks: 0
Thanked 0 times in 0 posts
Default 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
BillCh is offline  
Reply With Quote
Old 06-17-2009, 07:01 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,414
Thanks: 252
Thanked 978 times in 961 posts
Default

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.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 06-18-2009, 07:43 AM   #3
BillCh
Member
 
Join Date: Feb 2009
Posts: 68
Thanks: 0
Thanked 0 times in 0 posts
Default

Good thoughts. Thx for the hints.
BillCh is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Back Testing vs Live Sim BigDog008 Strategy Development 1 03-20-2009 10:53 AM
Trying to understand a gap between replay testing and Live Sim ... Learning1 Strategy Analyzer 6 12-03-2008 09:55 AM
Bad trade in live testing. skellington Strategy Development 4 08-06-2008 08:03 AM
Different Results between Backtesting and Live Testing vivienne Automated Trading 2 05-03-2007 03:45 AM
Different Results between Backtesting and Live Testing vivienne Miscellaneous Support 0 12-31-1969 06:00 PM


All times are GMT -6. The time now is 12:18 AM.