Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

test multiple indicators

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

    test multiple indicators

    It is probably obvious but I haven't found an answer in the forum and I am not sure what I should be looking for.

    I saw that NT offers more than a dozen moving averages (SMA, EMA, DEMA, HAMA, etc.) and I would like to test them in my custom strategy

    For example:
    Code:
    EMA(10).Overlay = true;
    EMA(10).Plots[0].Pen.Color = Color.DarkOrange;
    Add(EMA(10));
    [...]
    && CrossAbove(EMA(10), EMA(40), 1)
    Now if I want to test a "DEMA" I've to replace all "EMA" by "DEMA". Not very efficient.

    How can I create a "private variable" I would define and thus I would have only 1 change to make to test a new moving average?

    I've tried this but it generates CS0130 errors
    Code:
    private string vmyma = @"EMA"; // Default setting for Vmyma
    [...]
    Vmyma(Vma1).Overlay = true;
    Vmyma(Vma1).Plots[0].Pen.Color = Color.DarkOrange;
    Add(Vmyma(Vma1));
    [...]
    && CrossAbove(Vmyma(Vma1), Vmyma(Vma2), 1)
    [...]
    [Description("")]
    [GridCategory("Parameters")]
    public string Vmyma
    {
                get { return vmyma; }
                set { vmyma = value; }
    }
    I am not sure how far I am from the truth and hope you'll be able to advise me.

    All the best,
    Chris

    #2
    GM Chris, I would suggest you check into this sample we have for the purpose - http://www.ninjatrader.com/support/f...ead.php?t=3420

    Comment


      #3
      Hi Bertrand, I looked at it and (unfortunately) this is too advanced/complex for me.

      Is there anything simpler out there? Can you help me with some keywords to narrow my searches in the forum?

      Comment


        #4
        From the concept not really, the enums are pretty handy - you can see more (and more complete) implementations under the 'slope box' and 'moving average cross tester' entries in the strategy section sharing here on our forums :

        Comment


          #5
          Ok, last question on the subject; is it possible to do it "my way" i.e. by defining a private variable (string? int?)?

          Comment


            #6
            That would not be possible. If you don't like the enums, then use an integer input for a switch.

            If the user enter 0, you use an SMA in the calcs, if they enter 1 an EMA and so on.

            Comment


              #7
              so it is possible to reference an indicator with an integer in a strategy? Would you have an example in the forum, again I've searched and did not found anything? sorry B

              Comment


                #8
                Yes, you would do this all in your custom code:

                if (myInteger = 0)
                myMA = SMA.....

                if (myInteger = 1)
                myMA = EMA.....

                You can then make a public user input of this integer and control this via optimization what value is finally used in the myMA calcs which you would in turn use in the strategy conditions.

                Comment


                  #9
                  It looks neat and clean :-)

                  You also need to define myMA somehow so it can be called in the strategy conditions no?

                  Maybe you mean you can use a custom variable (myMA) to call an indicator (e.g. EMA)?

                  Comment


                    #10
                    Right, that would be a variable that holds your MA value as a double. You can then express your conditions using this variable MA placeholder.

                    Comment


                      #11
                      Thank you Bertrand, I am not sure we're on the same wavelength here so I'll do more searching in the forum to better refine my thinking. That's all for now. Have a good day. C

                      Comment


                        #12
                        Ok, sure : what I thought you would like to do is select via user input if an EMA or SMA is used in your strategy calculations. The enums would be the most elegant way or switching but the numeric / integer input I offered would do the job as well. If that's not what you seek I would appreciate if you could clarify.

                        TIA,

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by argusthome, 03-08-2026, 10:06 AM
                        0 responses
                        70 views
                        0 likes
                        Last Post argusthome  
                        Started by NabilKhattabi, 03-06-2026, 11:18 AM
                        0 responses
                        42 views
                        0 likes
                        Last Post NabilKhattabi  
                        Started by Deep42, 03-06-2026, 12:28 AM
                        0 responses
                        25 views
                        0 likes
                        Last Post Deep42
                        by Deep42
                         
                        Started by TheRealMorford, 03-05-2026, 06:15 PM
                        0 responses
                        28 views
                        0 likes
                        Last Post TheRealMorford  
                        Started by Mindset, 02-28-2026, 06:16 AM
                        0 responses
                        54 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Working...
                        X