Release file on force backtest stop

 

I am using sqlite database in my EA.

When I force stop backtest process agent hangs and never accepts new jobs until I restart MetaTrader.

I figured out that after force stop agent still keeps sqlite database file open. I've added file release in both OnDeinit and in destructor of database operations class but they fire only on regular backtest end or ExpertRemove. OnDeinit nor destructor are being called on force backtest stop. Is there any way to handle force stop I EA code?

 
alter-ego:

I am using sqlite database in my EA.

When I force stop backtest process agent hangs and never accepts new jobs until I restart MetaTrader.

I figured out that after force stop agent still keeps sqlite database file open. I've added file release in both OnDeinit and in destructor of database operations class but they fire only on regular backtest end or ExpertRemove. OnDeinit nor destructor are being called on force backtest stop. Is there any way to handle force stop I EA code?

Why do you want to force stop the backtest ?
 
Alain Verleyen:
Why do you want to force stop the backtest ?
For example I notice something wrong in Graph tab and don't want to wait for completion.
 
alter-ego:
For example I notice something wrong in Graph tab and don't want to wait for completion.
Alain Verleyen:
Why do you want to force stop the backtest ?

Is there some kind of callback for force stop?

For me it's unclear why OnDeinit is not called.

 
alter-ego:

Is there some kind of callback for force stop?

For me it's unclear why OnDeinit is not called.

Because a forced stop is a forced stop, nothing is called, you have to deal with it.

If you want to have control, you need to check your "stop conditions" in your code and use ExpertRemove() or TesterStop().

Eventually find an other way to release your sqlite file, or an other way to "force stop" your backtest.

 
By force stop I mean pressing “stop” button in terminal. Why this kind of stop does not call OnDeinit?
 

Finally solved it by creating `keep_alive` function in dll which I execute on every tick. If keep_alive isn't executed for 1 second after last execution DLL force stops its process.

 
I agree that it is strange that there is no call-back function for pressing stop in the strategy tester