It seems to me a Strategy ultimately inherits StrategyBase. Is theree a way to redirect that so it inherits from a class I define in a DLL (that then inherits from StrategyBase)? I Would like the chance to to some cleanup in StrategyBase (add events for the "events", dump exceptions to Print etc.) for everything.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Replace Strategy Base Class
Collapse
X
-
Replace Strategy Base Class
Hello,
It seems to me a Strategy ultimately inherits StrategyBase. Is theree a way to redirect that so it inherits from a class I define in a DLL (that then inherits from StrategyBase)? I Would like the chance to to some cleanup in StrategyBase (add events for the "events", dump exceptions to Print etc.) for everything.Tags: None
-
Please explain how injecting a new class into an inheritance hierarchy is identical to "changing" an internal class. I am sure me and a lot of people in the OO world would like to know.
More specific, if I read up on the @Strategy.cs that you have so nicely in your files (NT6.5 in MyDocuments, then Bin/Custom/Strategy - where all the other items are saved).... then I see:
public partical class Strategy : StrategyBase
and then in my own class, I can see:
public partial class MyStrategy : Strategy
Now, if I go in and change @Strategy to NOT inherit from StrategyBase, but from MyStrategyBase, which in turn inherits from StrategyBase...
...then by all respect, i have NOT CHANGED ANY INTERNAL CLASS. What I did is inject my own base class into the dynamically compiled inheritance tree.
Seriously, this is not the same as changing an internal class. Not per definition. Which, btw., is not something you or me decide - the termini used in object orientation are well defined, and the termini used in the .NET world are even more well defined. Changing an internal class would be something different (and that can also be done, but it is REALLY tricky).
So, the question still stands. Thanks for a first level support answer. I hope you got a point for that. Any place I can put up "that answer was not helpfull, not on topic and not even technically correct" complaint?
Btw., the correct answer seems to be:
* It seems to be trivial to do. The @Strategy.cs class is the base class linked in by the compiler. This can be changed simply in the strategy class. Funny, btw., how @Strategy... defines an ADX Indicator.
* Naturally it is best then to copy the code if the @Strategy class and put it into the base class in the referenced assembly.
* And naturally one will have to be careull not to do any changes that break behavior of the base class. But then, this is the case everywhere.
* And naturally NT world class support will gladly jump on a "not supported" in any question coming up anywhere in NinjaTrader from then on.
Seems it is easier than I thought, as the base class is actually available in code
Comment
-
Dierk,
Do you have a hotkey set to "This is not supported", lol.
Do you mean to say that what the poster suggests won't "work", or that if it does work, we shouldn't look to NT for support?
Your standard/stock reply is very ambigous. Could you please elaborate?
It's as though you want to cut off any progress for those who are trying to work around the shortcomings of NT. E.g. Advanced Order Handling's bugs, etc.
Instead, it might be more helpful to stop killing threads and putting out the fire, and instead offer some direction. Saying it's not supported is beyond annoying at this point and does not serve the community as a whole.
It is hard enough to do anything, much less with someone trying to get you off the path of what may or may not be your solution. I constantly see some great threads get killed because of your stock reply. It's very old Dierk and not helpful.
PLEASE try to provide more explaination in regards to what you mean by "this is not supported".
Thank you in advance,
Comment
-
NetTexture,
I am doing this already for some time.
In my case I do:
public partical class AndreasLongStrategy : StrategyWithScenarios
and again:
public partial class StrategyWitScenarios: TradeStrategy
and finally:
public partial class TradeStrategy: Strategy
be carefull to call always the base class in the Dispose method,
Dispose(){
doyourdisposestuff();
base.Dispose()
}
I am using the above scheme for about 6 month already in daily trading and I have no problems.
In my case I have the .cs files all in the \Strategy directory.
You want to put your classes inherited from Strategy into an external assembly (dll), which I have not tried. I have other code in external libraries and that works flawless.
.. wait: There is a pitfall: Your external dll must reference NinjaTrader.Core.Dll, and this reference is tied to the version number of NinjaTrader. Hence if you compile your dll against 6.5.0.12 then the code will not run under Ninja 6.5.0.13
Good luck
Andreas
P.S. Hello r2kTrader! How are you doing? Dierk probably knows a lot about C# as I recall his TraderMagic tecnology was added to NinjaTrader. Probably he is just afraid of opening the box of pandora by giving too much info.
Read the C# info in the internet , msdn, codeproject, bytes, stackoverflow and the likes and you will find out all this.
Comment
-
Andreas,
There is a difference between the fear of opening Pandora's box, and keeping people in a box ;-)
I'm doing well, learning C# more and more each day. There is so much to know and learn it seems never ending. I am sure I will reach a point where I will gather the 80% of things I need to do over and over and begin to make more progress. I have learned a lot and have been able to write some classes now and instantiate them without having to have one big fat file.
Let's stay connected! Thanks for your posts, you are helping many.
Originally posted by zweistein View Post
P.S. Hello r2kTrader! How are you doing? Dierk probably knows a lot about C# as I recall his TraderMagic tecnology was added to NinjaTrader. Probably he is just afraid of opening the box of pandora by giving too much info.
Read the C# info in the internet , msdn, codeproject, bytes, stackoverflow and the likes and you will find out all this.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
648 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
369 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
108 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
572 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
574 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment