Announcement

Collapse
No announcement yet.

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.

                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 sjsj2732, 03-23-2026, 04:31 AM
                    0 responses
                    42 views
                    0 likes
                    Last Post sjsj2732  
                    Started by NullPointStrategies, 03-13-2026, 05:17 AM
                    0 responses
                    295 views
                    0 likes
                    Last Post NullPointStrategies  
                    Started by argusthome, 03-08-2026, 10:06 AM
                    0 responses
                    290 views
                    0 likes
                    Last Post argusthome  
                    Started by NabilKhattabi, 03-06-2026, 11:18 AM
                    0 responses
                    135 views
                    1 like
                    Last Post NabilKhattabi  
                    Started by Deep42, 03-06-2026, 12:28 AM
                    0 responses
                    98 views
                    0 likes
                    Last Post Deep42
                    by Deep42
                     
                    Working...
                    X