Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Enum is not available within another indicator/strategy

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Enum is not available within another indicator/strategy

    NOTE: Please see second post before reading all this code. Thank you!

    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:

    Code:
    private int anyIndicatorPeriod = 5;
    private int anyIndicatorSmooth = 1; 
    private int zerovalue = 0;
    private DataSeries AnyInd;
    private zBMIndicatorMethodEnum zmyBMMethod = zBMIndicatorMethodEnum.MOM;
    AnyInd is initialized in Initialize()....

    Body section:

    Code:
    protected override void OnBarUpdate() 
    		{	
    			switch (zmyBMMethod) 
    				{
    				case zBMIndicatorMethodEnum.RSI:
    				
    					AnyInd.Set(RSI(anyIndicatorPeriod,anyIndicatorSmooth)[0]);
    				
    				break;
    					
    				default:
    
    					AnyInd.Set(Momentum(anyIndicatorPeriod)[0]);
    				
    				break;
    				}
    			
    			if (CurrentBar < anyIndicatorPeriod) return;
    			
    		       ZeroLine.Set(zerovalue);
    
                     }
    
    		public enum zBMIndicatorMethodEnum //compiles when placed here within "namespace" 
    		{
    			RSI,
    			MOM
    		}
    		
           
        }
    }
    //public enum zBMIndicatorMethodEnum //followed example in SampleUniversalMovingAverage and placed AFTER namespace but would not compile
    //{
    //	RSI,
    //			
    //	MOM,
    //}
    With the above code it compiled and plotted and the "enum" worked as it should.

    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.

    Code:
    if (CrossAbove(zzzskBMomentumtest(20, 1, NinjaTrader.Indicator.zzzskBMomentumtest+zBMIndicatorMethodEnum.RSI, 50).AnyInd, zzzskBMomentumtest(20, 1, NinjaTrader.Indicator.zzzskBMomentumtest+zBMIndicatorMethodEnum.RSI, 50).ZeroLine, 1))
    When compiling this strategy NT says "The name 'zBMIndicatorMethodEnum' does not exist in the current context". It also suggests my indicator above is a "type", not vaild in the given context.

    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
    Attached Files
    Last edited by Sim22; 05-20-2014, 02:47 AM. Reason: Solved

    #2
    I just placed a "." in place of the "+" and the damn thing worked.

    So, this actually works now. However, I am still not sure as to where an "enum" should be placed, within or outside the "namespace"

    Would someone please clarify that for me.

    Comment


      #3
      Glad to hear you could fix that, for the enum placement the supported approach would be shown in this sample, it's placed outside the NT indicator namespace - http://www.ninjatrader.com/support/f...ead.php?t=3420
      BertrandNinjaTrader Customer Service

      Comment


        #4
        Thanks Bertrand,

        however it won't compile if I place the enum outside of the namespace, below Properties.

        The error I get is CS0426:

        The type name 'zBMIndicatorMethodEnum' does not exist in the type 'NinjaTrader.Indicator.zzzskBMomentumtest'

        Comment


          #5
          Would you mind sending me what you have completed to far to support at ninjatrader dot com so I could give it a quick run on our end?

          Thanks,
          BertrandNinjaTrader Customer Service

          Comment


            #6
            Okay, thanks Bertrand

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by schmidtbc16, Today, 03:36 PM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by RT001, Today, 03:25 PM
            2 responses
            14 views
            0 likes
            Last Post RT001
            by RT001
             
            Started by mbrandau, Today, 01:58 PM
            5 responses
            37 views
            0 likes
            Last Post mbrandau  
            Started by remcovdmeulen, Today, 02:15 PM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_Jim  
            Started by gbrad, Today, 09:57 AM
            7 responses
            16 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X