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
    BertrandNinjaTrader Customer Service

    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 :

        BertrandNinjaTrader Customer Service

        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.
            BertrandNinjaTrader Customer Service

            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.
                BertrandNinjaTrader Customer Service

                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.
                    BertrandNinjaTrader Customer Service

                    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,
                        BertrandNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by aussugardefender, Today, 01:07 AM
                        0 responses
                        1 view
                        0 likes
                        Last Post aussugardefender  
                        Started by pvincent, 06-23-2022, 12:53 PM
                        14 responses
                        238 views
                        0 likes
                        Last Post Nyman
                        by Nyman
                         
                        Started by TraderG23, 12-08-2023, 07:56 AM
                        9 responses
                        383 views
                        1 like
                        Last Post Gavini
                        by Gavini
                         
                        Started by oviejo, Today, 12:28 AM
                        0 responses
                        1 view
                        0 likes
                        Last Post oviejo
                        by oviejo
                         
                        Started by pechtri, 06-22-2023, 02:31 AM
                        10 responses
                        125 views
                        0 likes
                        Last Post Leeroy_Jenkins  
                        Working...
                        X