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!
See more
See less

Partner 728x90

Collapse

Adding indicators dynamically

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

    Adding indicators dynamically

    My strategy needs to add indicators based on a drop down. So in order to do this I need to know an interface that I can use that allows me to do this:

    Code:
    switch(Strategy) {
    	case EntryStrategy.A:
    		indicator = SMA(20);
    		break;
    	case EntryStrategy.B:
    		indicator = EMA(20);
    		break;
    	case EntryStrategy.C:
    		indicator = DMA(20);
    		break;
    	default:
    		break;
    	}
    			
    Add(indicator);
    I tried IDataSeries but the compiler won't have any of it.

    I once accomplished this somehow but unfortunately don't remember where I did it or how.... any help would be most welcome.
    Last edited by molecool; 02-27-2013, 09:09 AM.

    #2
    Hello molecool,

    Thank you for your post.

    You will need to use an enum to create a user-defined parameter type (drop down menu). For a reference sample on this item please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=3420

    Please let me know if I may be of further assistance.

    Comment


      #3
      I think you misunderstood Patrick. I already have the dropdown based on my enum (I called it Strategy - see my code). That was the easy part.

      What I need to do is to add an indicator of which I don't know the type in advance. Could be an SMA, could be a MACD or something else. I need a common interface. Does this make sense?

      It tried IDataSeries but am running into trouble with the compiler.

      Comment


        #4
        Never mind...

        I figured it out - just used IndicatorBase and now it works fine. You guys don't have any documentation on that one and I think you ought to provide it as interfacing is a basic requirement of any API. Just my 2 cents.

        Comment


          #5
          Hello molecool,

          Thank you for posting this item.

          As you mentioned this undocumented and is unsupported within NinjaScript.

          Please let me know if you have any questions.

          Comment


            #6
            Originally posted by NinjaTrader_PatrickH View Post
            Hello molecool,

            Thank you for posting this item.

            As you mentioned this undocumented and is unsupported within NinjaScript.

            Please let me know if you have any questions.
            Fortunately the compiler gave it away ;-)

            Comment


              #7
              Originally posted by molecool View Post
              Fortunately the compiler gave it away ;-)
              I wonder if you would care to document this in the "Undocumented/Unsupported Ninja Tips and Tricks " thread.

              Just so we can find it again the next time we forget?

              Comment


                #8
                Won't I get into trouble with the Ninjas? ;-)

                Comment


                  #9
                  molecole, we always appreciate users helping other users where we're unable to comment. Please feel free to share any unsupported areas.
                  MatthewNinjaTrader Product Management

                  Comment


                    #10
                    Originally posted by molecool View Post
                    Won't I get into trouble with the Ninjas? ;-)
                    NT is the only company I know of that allows users to share and post unsupported tricks (are they really hacks?), on their own support forum. I am sure that there might be others, but if there are any others, I just do not know of them.

                    Comment


                      #11
                      Originally posted by koganam View Post
                      NT is the only company I know of that allows users to share and post unsupported tricks (are they really hacks?), on their own support forum. I am sure that there might be others, but if there are any others, I just do not know of them.
                      Oh, I got a few tricks up my sleeve... ;-)

                      Comment


                        #12
                        Re: IndicatorBase variable

                        Just to complete molecool's note, his sample code posted below should work after including the variable "private IndicatorBase indicator;".

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by burtoninlondon, Today, 12:38 AM
                        0 responses
                        5 views
                        0 likes
                        Last Post burtoninlondon  
                        Started by AaronKoRn, Yesterday, 09:49 PM
                        0 responses
                        14 views
                        0 likes
                        Last Post AaronKoRn  
                        Started by carnitron, Yesterday, 08:42 PM
                        0 responses
                        11 views
                        0 likes
                        Last Post carnitron  
                        Started by strategist007, Yesterday, 07:51 PM
                        0 responses
                        13 views
                        0 likes
                        Last Post strategist007  
                        Started by StockTrader88, 03-06-2021, 08:58 AM
                        44 responses
                        3,983 views
                        3 likes
                        Last Post jhudas88  
                        Working...
                        X