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

Putting verbiage in Indicator selection

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

    Putting verbiage in Indicator selection

    I have code that selects various moving averages from the Indicator. Right now I select a number (int) and then use the MA identified with that selection.
    .....See code below
    [Description("1=EMA 2=SMA 3=WMA 4=HMA 5=ZLEMA 6=TEMA 7=TMA 8=VWMA 9=ADXVMA")]
    [GridCategory("Parameters")]
    public int SlowMA
    {
    get { return slowMA; }
    set { slowMA = Math.Max(1, value); }
    }

    .....see attached .png file for the visual


    I'd like to have the actual letters ("EMA' SMA, etc,) show up in the selection instead of simply choosing a number. Is there a way to do that?

    Thanks......................
    Attached Files

    #2
    Hello,

    I believe you want to do an enum method. Please go here for details on this:


    If that doesn't cover it, please let me know.
    DenNinjaTrader Customer Service

    Comment


      #3
      Thanks!!!
      ....(as always a fast helpful response)

      I'll take a look......

      Comment


        #4
        Oh my gosh....that works GREAT!!!

        Thanks......

        Comment


          #5
          Ooopss.... Next Question.....
          I have two plot lines.....(Fast & slow). I successfully set up both enums and have two Moving average cases, but I'm having trouble getting the correct Moving average value set with the appropriate plot line.

          Comment


            #6
            Hello photog53,

            Can you share some of the code you're working with so we can see what might be causing this? Can also attach the .cs file found in 'Documents\NinjaTrader\bin\custom\indicator'.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Certainly....(should have done that sooner)
              Attached Files

              Comment


                #8
                You will need to setup more cases, you only have it defined for the enum to be the EMA choice hence it only works for this then.
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Got it.......(a bit of trial and error helped me understand your suggestions)

                  As always....GREAT ASSISTANCE!!!!!!
                  ....corrected code

                  switch (fastMA)
                  {
                  case UniversalFastMA.EMA: {FastLine.Set (EMA(fastPeriod)[0]); break; }
                  case UniversalFastMA.SMA: {FastLine.Set (SMA(fastPeriod)[0]); break;}
                  case UniversalFastMA.WMA: {FastLine.Set (WMA(fastPeriod)[0]); break;}
                  case UniversalFastMA.HMA: {FastLine.Set (HMA(fastPeriod)[0]); break;}
                  case UniversalFastMA.ZLEMA: {FastLine.Set (ZLEMA(fastPeriod)[0]); break;}
                  case UniversalFastMA.TEMA: {FastLine.Set (TEMA(fastPeriod)[0]); break;}
                  case UniversalFastMA.TMA: {FastLine.Set (TMA(fastPeriod)[0]); break;}
                  case UniversalFastMA.VWMA: {FastLine.Set (VWMA(fastPeriod)[0]); break;}
                  case UniversalFastMA.DEMA: {FastLine.Set (DEMA(fastPeriod)[0]); break;}
                  case UniversalFastMA.EhlersFilter: {FastLine.Set (EhlersFilter(fastPeriod)[0]); break;}
                  }

                  --------------Earlier message----------------
                  Apologies....but I didn't quite understand your suggestion.
                  (I am still learning C#....so my understanding of basic syntax is not great)

                  Did I mess up the default value.....or do I have to add a "case" for each MA type

                  / -------------------- Fast MA Case Function --------------------------------
                  switch (fastMA)
                  {
                  case UniversalFastMA.EMA:
                  {
                  FastLine.Set (EMA(fastPeriod)[0]);
                  break;
                  }

                  case UniversalFastMA.SMA:
                  FastLine.Set(SMA(fastPeriod)[0]);
                  break;
                  }
                  case UniversalFastMA.WMA:
                  {
                  FastLine.Set(WMA(fastPeriod)[0]);
                  break;
                  }
                  etc.................



                  Also this version of my code does not plot the second moving average line (slowLine). Not sure what I did wrong there.

                  Thanks for the help!!!!
                  Last edited by photog53; 05-24-2010, 12:57 PM.

                  Comment


                    #10
                    You don't have to add a case for every MA type, but you should add a case for every type that you've defined in your enum.


                    There won't be any difference with the implementation fast/slow. Whatever you did on the fast line, duplicate for the slow.
                    Ryan M.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by alifarahani, Today, 09:40 AM
                    6 responses
                    31 views
                    0 likes
                    Last Post alifarahani  
                    Started by Waxavi, Today, 02:10 AM
                    1 response
                    17 views
                    0 likes
                    Last Post NinjaTrader_LuisH  
                    Started by Kaledus, Today, 01:29 PM
                    5 responses
                    14 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by Waxavi, Today, 02:00 AM
                    1 response
                    12 views
                    0 likes
                    Last Post NinjaTrader_LuisH  
                    Started by gentlebenthebear, Today, 01:30 AM
                    3 responses
                    17 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Working...
                    X