Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Strategy Dispose()
Collapse
X
-
Strategy Dispose()
I would like to perform some tasks when a strategy running in the Strategies Tab, is stopped, or removed. 'public override void Dispose()' does no seem to be executed inside my strategy on these events. How do I perform cleanup tasks when a strategy is topped or removed?Tags: None
-
Progress on Dispose( ) ?
Hi guys,
I too would like to run some cleanup code on strategy termination. Was the Dispose() bug fixed in 6.5.1000.3. If not when is it likely to be fixed?
If you have any other suggestions for how to run code automatically once a strategy has been terminated I would welcome your suggestions.
many thanks
Comment
-
Hi guys,
I tried calling Dispose but its behaviour is not what I would have expected. This is how I've implemented it.
public class myStrategy : Strategy
{
// variables go here
// Initialize() goes here.
public override void Dispose( )
{
// do useful things here
MessageBox.Show( "Dispose() called." );
base.Dispose( );
}
// OnBarUpdate goes here.
}
When I use Strategy Analyzer and execute the strategy in a backtest, the message box doesn't show once the strategy has finished running through all the data. If I then click on my chosen instrument and execute the backtest again, the message box does show and in fact does so 3 times before running the backtest.
Am I not using this properly or is there some other explanation?
many thanks
Comment
-
Please see this reference for how Dispose should be used: http://www.ninjatrader-support.com/v...ead.php?t=5965Josh P.NinjaTrader Customer Service
Comment
-
Sorry Josh but that doesn't help.
I am already using Dispose() as demonstrated in your reference sample. It doesn't seem to be called unless I want to run a backtest on a strategy again.
This suggests to me that in Strategy Analyser if you run a backtest, the strategy object is not destroyed even though it has run through the prescribed data set. Only when you want to run a backtest again does Dispose() seem to be called.
Is there any other method I can use that can guarantee to execute code once the run through a data set in Strategy Analyzer is complete?
many thanks
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
582 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
338 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
103 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
554 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
552 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment