I am having trouble with referencing another indicator within a strategy because the "enum" is not recognized.....
Here is the partial code of the primary indicator, one which allows to choose between a RSI or momentum plot:
Variables section:
[COLOR="Blue"]private int[/COLOR] anyIndicatorPeriod = 5; [COLOR="blue"]private int[/COLOR] anyIndicatorSmooth = 1; [COLOR="blue"]private int[/COLOR] zerovalue = 0; [COLOR="blue"]private[/COLOR] DataSeries AnyInd; [COLOR="blue"]private[/COLOR] zBMIndicatorMethodEnum zmyBMMethod = zBMIndicatorMethodEnum.MOM;
Body section:
[COLOR="blue"]protected override void[/COLOR] OnBarUpdate() { [COLOR="blue"]switch[/COLOR] (zmyBMMethod) { [COLOR="blue"]case[/COLOR] zBMIndicatorMethodEnum.RSI: AnyInd.Set(RSI(anyIndicatorPeriod,anyIndicatorSmooth)[0]); [COLOR="blue"]break[/COLOR]; [COLOR="blue"]default[/COLOR]: AnyInd.Set(Momentum(anyIndicatorPeriod)[0]); [COLOR="blue"]break[/COLOR]; } if (CurrentBar < anyIndicatorPeriod) [COLOR="blue"]return[/COLOR]; ZeroLine.Set(zerovalue); } [COLOR="blue"]public enum[/COLOR] zBMIndicatorMethodEnum [COLOR="SeaGreen"]//compiles when placed here [U]within[/U] "[COLOR="Blue"]namespace[/COLOR]" [/COLOR] { RSI, MOM } } } [COLOR="SeaGreen"]//public enum zBMIndicatorMethodEnum //followed example in SampleUniversalMovingAverage and placed AFTER namespace but would not compile //{ // RSI, // // MOM, //}[/COLOR]
So.... I tried accessing this indicator within a host strategy using "AnyInd" crossing above "ZeroLine" letting the NinjaTrader strategy wizard do the code for me.
if (CrossAbove(zzzskBMomentumtest(20, 1, NinjaTrader.Indicator.zzzskBMomentumtest[COLOR="Red"][B]+[/B][/COLOR]zBMIndicatorMethodEnum.RSI, 50).AnyInd, zzzskBMomentumtest(20, 1, NinjaTrader.Indicator.zzzskBMomentumtest[COLOR="red"][B]+[/B][/COLOR]zBMIndicatorMethodEnum.RSI, 50).ZeroLine, 1))
Notice the "+" in the above code. When I add a "." here instead, the "enum" is not recognized by Intellisense.
I am still confused about where to place the "public enum" in the indicator to be publically available to my host strategy. The SampleUniversalMovingAverage actually has the "public enum" outside of "namespace". Mine does not compile if I do this. I am simply a 'cut and paste' coder with an understanding of logic so maybe I am missing something so simple.
I am in asian timezone so I may not get back to you until US evening.
Thank you in advance
Simon
Comment