BillCh
06-17-2009, 06:43 AM
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
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
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
For real time trading I have set time restrictions like
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
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