TIA
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
Accessing NT Methods from a Custom Class?
Collapse
X
-
Accessing NT Methods from a Custom Class?
I'm building an indicator where most of the logic is contained in a custom class. As it is now I need to do all my Print() and draw functions by interfacing with the Indicator class. I was wondering if it possible to access methods and properties from the ninja trader namespace from directly from my class?
TIATags: None
-
I am not sure I understood completely. Do you like to use Print() from within a helper class of your indicator (for example)? In this case you could deliver an instance of your indicator (this) to your helper class by the constructor and store it to a variable. Then you could apply printing from your helper class as variable.Print("abc").
Regards
Ralph
Comment
-
Ralph. I am also running into this problem. I am porting a GMDH algorithm from Excel VBA to NinjaScripit. The algorithm is being coded in it's own class so it will be portable within NinjaScript. Debugging and some interface issues would be made much easier if I could gain access to some NinjaScript properties and methods from within the GMDH class.
Not 100% sure what you mean when you say "deliver an instance of your indicator (this) to your helper class ". I will have to read up 'this' and see if I come can arrive at a better understanding of what you are talking about.
Comment
-
If you want to hand over a global variable to a class instance, I would do that with the constructor. The compiler takes care that you never can forget it . Here is an example:
Code:public class MyInd : Indicator { private HelperClass helperClass = new HelperClass(this); } public class HelperClass { private MyInd myInd; public HelperClass(MyInd mi) { myInd = mi; } private void Print(string str) { myInd.Print(str); } }
Ralph
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Jonker, 04-27-2024, 01:19 PM
|
3 responses
23 views
0 likes
|
Last Post Today, 05:45 PM | ||
Started by businessman1929, 04-29-2024, 01:28 PM
|
2 responses
21 views
0 likes
|
Last Post Today, 05:38 PM | ||
Started by bltdavid, 03-27-2023, 05:32 AM
|
18 responses
347 views
0 likes
|
Last Post
by ETFVoyageur
Today, 05:28 PM
|
||
Started by NM_eFe, Today, 05:15 PM
|
0 responses
5 views
0 likes
|
Last Post
by NM_eFe
Today, 05:15 PM
|
||
Started by vitaly_p, Today, 05:09 PM
|
0 responses
7 views
0 likes
|
Last Post
by vitaly_p
Today, 05:09 PM
|
Comment