1. Print() inside a class
When debugging the code inside class 'bar' in indicator 'foo', I cannot use the Print() method. I get error CS0038, "Cannot access a non-static member of outer type 'NinjaTrader.Indicator.IndicatorBase' via nested type 'NinjaTrader.Indicator.foo.bar'.
If I try to create an instance of IndicatorBase to use internally in class 'bar' to have access to Print(), I get error CS0144, "Cannot creat an instance of the abstract class or interface 'NinjaTrader.Indicator.IndicatorBase'.
Is there any way to send anything to the Output window from inside a class? Use stdout or stderr with fprintf() or something?
2. public named constants inside a class
Inside indicator 'foo', I have a public class 'bar'. The indicator 'foo' creates several different instances of 'bar'. Class 'bar' includes several public exposed variables that can show current status as some pre-defined named constants defined in the indicator 'foo'. For example, I have this constant in 'foo':
public const int TYPE_FORMING = 3;
All well and good, my instances of 'bar' refer to these named constants without problems.
I run into problems when trying to reference these public constants by name from another indicator. Say I have another indicator 'xyz' that calls 'foo' and needs access to the exposed values inside all the 'bar' instances within 'foo'. How do access the public constant by name in 'xyz'? Suppose inside foo there's an instance of bar called 'b'. Then in 'xyz' I tried for example:
//variables private foo f; protected void override OnStartUp() { f = foo(); } protected void override OnBarUpdate() { // error CS0176, TYPE_FORMING cannot be accessed with an instance reference, qualify it with a type name instead if (f.b.type == f.TYPE_FORMING) { // etc. } }
if (f.b.type == foo.TYPE_FORMING) // error CS0119, conflict with the foo() method
-Alex
Comment