Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
access strategy data from another class
Collapse
X
-
access strategy data from another class
I wrote some generic code that I put in another strategy. I just call the constructor directly and use it as a regular class (not a strategy). This works however there are a few minor issues arising from the fact that the utility class doesn't have access to the same data as the strategy. For example, in the utility class I try to draw on the chart but it doesn't work. I try to get Time[0] but it doesn't work. I understand why this doesn't work but I'd like to know if there is a way to make it work? I'd love to be able to draw in my utility class.Tags: None
-
I'm trying and I run into a problem.Originally posted by NinjaTrader_Josh View Postcunparis,
I have never tried, but I believe you can.
I created a base class for all my strategy. I created a log method in this class which will prefix all my Print()s with a timestamp.
So I made my user defined methods partial class but it cannot access the log method. I tried to make my partial class extend the base class for my strategy but that made a circular reference. I'm at my limit of C# knowledge now (Java doesn't have partial class).
Maybe instead of putting my log method in the base class I should put it in a partial class too?
Comment
-
Thanks for the links. I had already read those.Originally posted by NinjaTrader_Josh View Postcunparis,
Please do everything in the partial class. There are two samples in the Help Guide you can check out in regards to UserDefinedMethods.
http://www.ninjatrader-support.com/H...6/Sample2.html
The only issue remaining is how to version my common code. If I put it in the partial class it's available to all classes. With my base class I version it so I have BaseStrategy1, 2, 3, etc. So I think one has to be careful of putting it into the partial class. other than that I think it's a good solution.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CarlTrading, 03-31-2026, 09:41 PM
|
1 response
67 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
36 views
0 likes
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
60 views
1 like
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|
||
|
Started by CarlTrading, 03-30-2026, 11:51 AM
|
0 responses
62 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:51 AM
|
||
|
Started by CarlTrading, 03-30-2026, 11:48 AM
|
0 responses
53 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:48 AM
|


Comment