How to apply expiration date in backtest mode?

 
The normal solution 
if(TimeCurrent()>expiry_date) return INIT_FAILED;
does not apply in backtest mode! Do you think there is a solution?
 

Move it to OnTick/OnCalculate.

Don't try to use any price (or indicator) or server related functions in OnInit (or on load or in OnTimer before you've received a tick), as there may be no connection/chart yet:

  1. Terminal starts.
  2. Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
  3. OnInit is called.
  4. For indicators OnCalculate is called with any existing history.
  5. Human may have to enter password, connection to server begins.
  6. New history is received, OnCalculate called again.
  7. A new tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
 
Yashar Seyyedin: The normal solution  does not apply in backtest mode! Do you think there is a solution?

Do you mean that you want to check the current real time of the trade server and not the simulated time in the tester?

I don't think that is possible. You may be able to use DLL calls to get the current time of the computer however.

 
Fernando Carreiro #:

Do you mean that you want to check the current real time of the trade server and not the simulated time in the tester?

I don't think that is possible. You may be able to use DLL calls to get the current time of the computer however.

Yes. That is what I meant. Thanks 
 
William Roeder #:
Don't try to use any price (or indicator) or server related functions in OnInit (or on load or in OnTimer before you've received a tick), as there may be no connection/chart yet:

Does your statement apply to _Point and _Digits too?

I think this can be used in OnInit() as it is static properties of the symbol.
 
Fernando Carreiro #:

Do you mean that you want to check the current real time of the trade server and not the simulated time in the tester?

I don't think that is possible. You may be able to use DLL calls to get the current time of the computer however.

Well, can be done by creating a file, getting the property "created" and deleting the file.

Edit: without DLLs


 
Dominik Christian Egert #:
Well, can be done by creating a file, getting the property "created" and deleting the file.

Edit: without DLLs


Thanks 
Reason: