Please let me know if I may be of further assistance.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Strategy States - changing
Collapse
X
-
You ask "is there a way I am running cloned strategy?" - what are the results when you test it out? The UI instances of the strategy do not reach State.Configure; that state is only reached once the user clicks "Apply" or "OK" on the strategy window to configure the strategy. More details about states and state management are described in the best practices here, which is a link I did not share previously:Originally posted by kujista View Post
Please let me know if I may be of further assistance.
-
Hello Pavel,Originally posted by kujista View Post
Thank you for the video.
Does State.DataLoaded work for your needs? This should only be called once and only when the strategy is enabled; State.Configure could be called when the user clicks Apply or OK without the strategy being enabled. Please test out State.DataLoaded and feel free to reach out with any additional questions or concerns.
Thank you for your time and patience.
Comment
-
Hello Pavel,Originally posted by kujista View PostThe Problem is, that I also need to get from strategy data series which will be used.. and i have to do it in cofigure state which is run 3 times...
Thank you for your reply.
You can get the data series which will be used from State.DataLoaded as well. It is not exclusive to State.Configure. Are there any other reasons you require State.Configure in particular? If not, please test it in State.DataLoaded and monitor the results to see if they behave as expected or not.
Please let me know if I may be of further assistance.
Comment
-
Adding a data series dynamically is not supported. Our support team will not be able to assist you with what you are trying to achieve. You can test it yourself, though you must understand that since it is unsupported results may very and you should only do so at your own risk. More information is noted in the help guide here:Originally posted by kujista View PostI am affraid, you don't understand what I mean.
I will add dataseries dynamically after connectin to database server using this code:
I cannot use AddDataSeries when strategy in DataLoaded state...Or can I add Data Series?
See:
- https://ninjatrader.com/support/help...dataseries.htm
- "Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided. Trying to load bars dynamically may result in an error similar to: Unable to load bars series. Your NinjaScript may be trying to use an additional data series dynamically in an unsupported manner."
Thank you for using NinjaTrader.
Comment
- https://ninjatrader.com/support/help...dataseries.htm
-
OMG... This was not about adding dataseries... this all is about being able not to run 3 times code with green comment?? can you forget the part about adding dataseries? and could you tell me if I am able to detect if part with green comment is run for first time or second time?
I can do it by geting data from db, and see if there are 2 previous attempts but that is pretty stupid. I am looking for cleaner solution.
Or is this something you also are not allowed to help with?
Comment
-
I am not aware of a way to detect if the if (IsEnabled) condition in State.Configure has been hit one, two, or three times. Even if you add an int variable and increment the int when it is State.Configure, it gets reset:Originally posted by kujista View PostOMG... This was not about adding dataseries... this all is about being able not to run 3 times code with green comment?? can you forget the part about adding dataseries? and could you tell me if I am able to detect if part with green comment is run for first time or second time?
I can do it by geting data from db, and see if there are 2 previous attempts but that is pretty stupid. I am looking for cleaner solution.
Or is this something you also are not allowed to help with?
If you are able to find a workaround with your database, then that is likely the route you will need to take. I am not aware of any supported/documented solutions that would help you in this scenario.Code:public class SampeMAPrints : Strategy { private SMA smaFast; private SMA smaSlow; private int configureCount = 0; protected override void OnStateChange() { if (State == State.SetDefaults) { Description = NinjaTrader.Custom.Resource.NinjaScriptStrategyDescriptionSampleMACrossOver; Name = "SampeMAPrints"; Fast = 10; Slow = 25; // This strategy has been designed to take advantage of performance gains in Strategy Analyzer optimizations // See the Help Guide for additional information IsInstantiatedOnEachOptimizationIteration = false; } else if (State == State.Configure) { Print("SampleMAPrints State.Configure"); configureCount++; if (IsEnabled) { Print("Strategy is enabled. configureCount: " + configureCount); } }
I sincerely appreciate your time and patience.
Comment
-
It's clear that configureCount cannot work, because there are created 3 encapsuled instances... I thought there might be some property IsCloned - which tells me it is not "the first" strategy but the third one.
There is no one in developers team, you could ask or consult with? Someone who has more experiences with this?
I really don't the way using database to this..
Comment
-
As I mentioned, there is no supported or documented NinjaScript method or property that does this. If you'd like, I could submit a feature request to the development team on your behalf and provide you with a tracking number to see if/when the feature is implemented in a future version of NinjaTrader. Otherwise, you will need to use a different approach to achieve what you are looking for. Please let me know if a feature request interests you and I will gladly submit it.Originally posted by kujista View PostIt's clear that configureCount cannot work, because there are created 3 encapsuled instances... I thought there might be some property IsCloned - which tells me it is not "the first" strategy but the third one.
There is no one in developers team, you could ask or consult with? Someone who has more experiences with this?
I really don't the way using database to this..
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
62 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
134 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
75 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
45 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
50 views
0 likes
|
Last Post
|

Comment