View Full Version : Accessing NT Methods from a Custom Class?
darckeen
03-18-2009, 10:06 AM
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?
TIA
NinjaTrader_Josh
03-18-2009, 10:26 AM
darckeen,
Unfortunately this is outside the scope of what we can offer support for.
Ralph
03-19-2009, 03:22 AM
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
scjohn
03-23-2009, 08:01 AM
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.
Ralph
03-23-2009, 08:44 AM
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:
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);
}
}
Regards
Ralph
darckeen
03-24-2009, 01:50 AM
Thats exactly what i was looking for, Thanks.