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 Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
558 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
324 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 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
545 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
547 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|


Comment