Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Strategy exit handle
Collapse
X
-
"There is not a universal method that will clean up a strategy's resources."
Thank you, you answered my question.
Gunars
-
Hello gunars.kepe,
Thanks for your reply.
There is not a universal method that will clean up a strategy's resources. Class level variables will be cleaned up by garbage collection after the strategy is disabled and custom resources will have to be handled on their own in State.Terminated to assure they are cleaned up.
You can disable a strategy programmatically with SetState(State.Terminated);
SetState() - https://ninjatrader.com/support/help.../?setstate.htm
Please let me know if I can be of further assistance.
Leave a comment:
-
Thank you for your detailed reply.
I'm using State.Terminated to clean up resources.
My question is, is there any method that cleans up all strategy resources? Idea is to close strategy, clean up all strategy resources without writing additional cleanup when exiting strategy and without worrying that some resources are still running. To make 100% sure all resources are cleaned up.
Leave a comment:
-
Hello gunars.kepe,
Welcome to the forums!
NinjaScripts are designed so they can have their resources created when enabled and destroyed when they are disabled. Strategies follow certain defined behavior in the options menu to determine what it should do with any active orders when it is disabled.
When recreating and destroying your own resources in the context of a strategy, the State system should be used. State.DataLoaded is a good time for the strategy to create new resources while State.Terminated can be used to clean up resources when the strategy exits.
LifeCycle - http://ninjatrader.com/support/helpG...fecycle_of.htm
OnStateChange() - http://ninjatrader.com/support/helpG...tatechange.htm
Strategy Options - http://ninjatrader.com/support/helpG...riptProperties
If you have any additional questions, please don't hesitate to ask.
Leave a comment:
-
Strategy exit handle
Hi everyone,
I'm a new developer with Ninja 8. What is good practice to exit, close, destroy, release strategy from the code?
I'm using Threads and singleton pattern in my strategy and they do not get destroyed or released from memory on strategy exit.
I used functions like:
Application.Exit
Application.Shutdown
but in that case, whole Ninja application is closed. I'm looking to close only my strategy.
Workaround to really release all strategy is to recompile it, then everything is clean.
My question is what is good practice to exit, close, destroy, release strategy from the code?
Thank you in advance,
GunarsLast edited by gunars.kepe; 08-31-2017, 04:46 AM.Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by judysamnt7, 03-13-2023, 09:11 AM
|
4 responses
59 views
0 likes
|
Last Post
by DynamicTest
Today, 08:25 PM
|
||
Started by ScottWalsh, Today, 06:52 PM
|
4 responses
36 views
0 likes
|
Last Post
by ScottWalsh
Today, 07:40 PM
|
||
Started by olisav57, Today, 07:39 PM
|
0 responses
7 views
0 likes
|
Last Post
by olisav57
Today, 07:39 PM
|
||
Started by trilliantrader, Today, 03:01 PM
|
2 responses
22 views
0 likes
|
Last Post
by helpwanted
Today, 07:25 PM
|
||
Started by cre8able, Today, 07:24 PM
|
0 responses
10 views
0 likes
|
Last Post
by cre8able
Today, 07:24 PM
|
Leave a comment: