Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator with SMA

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

    Indicator with SMA

    I want to make an indicator something like the Ninja MACrossBuilder indicator...but with 4 different moving averages (instead of 2) plotting.

    I don't need to have the period, et cetera, selectable in the parameters...they would be fixed in the code as they don't change.

    Any examples to look at?

    #2
    Turtle Trader, I think you can take the template from Ryan here - http://www.ninjatrader.com/support/f...h=cross&desc=1

    and then just dont expose the parameters as public properties, but instead hardcode their values into the method calls.

    Of course you then also need to add extra plots as per your needs.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      reply

      hi Bertrand,

      That link does not go anywhere, can you repost it?

      Thank you.

      Comment


        #4
        The link goes to our sharing, which contains an MA cross builder shared by our RyanM, this could be a template for your works - http://www.ninjatrader.com/support/f...catid=4&id=426
        BertrandNinjaTrader Customer Service

        Comment


          #5
          reply

          Hi Bertrand,

          I clicked again and the link worked...search results. thank you.

          Though, I'm a newbie a Ninja coder....can you give me an example of how to assign attributes, like Period, MA Type, et cetera, to a Plot in the code? And assign a DataSeries to a Plot?

          I've read the MA Cross Builder and don't see where those are being applied...they are in the parameters but not assigned to the DataSeries in the code..?

          And, how is a DataSeries applied to a Plot?

          Is there a class I can take to know these things?

          Thank you.

          Comment


            #6
            If you're new to coding in NinjaScript, best would be checking through those tutorials for indicator coding we have prepared - http://www.ninjatrader.com/support/h.../tutorials.htm

            Those would cover the basics needed for custom work and modifications.

            The MA Builder code shared uses so called user defined inputs to set paramters - a tip in the education section explains those further - http://www.ninjatrader.com/support/f...ead.php?t=5782

            If you just want to hardcode a period in, then assign the parameter in your MA method call for example - double mySMA = SMA(Close, 10)[0]; >> here the period is hardcoded to 10, there be no exposed user input dictating what is used, it will always be the coded in 10.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              thank you

              thank you Bertrand

              Comment


                #8
                You're welcome, if you run into any walls on this project please post and let us know.
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  unable to get attached code to plot....

                  four SMAs in one indicator....probably a simple error....or left something out???

                  thank you!
                  Attached Files

                  Comment


                    #10
                    Looks to be just a simple issue in your plot width assignments in the Initialize(), please try instead here -

                    Plots[0].Pen.Width = 2;
                    Plots[1].Pen.Width = 2;
                    Plots[2].Pen.Width = 2;
                    Plots[3].Pen.Width = 2;
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      where?

                      Hi Bertrand,

                      Yes, it appears the Pen.Width assignment should not be in the Initialize...but your message didn't state where to put them...

                      :-)

                      thank you.

                      Comment


                        #12
                        That's not the point, they can either go to OnStartUp() or Initialize(), but you've had incorrect index values assigned - so your last one pointed to a Plot array of 4 which does not exist > hence your issue loading the indicator, there was a corresponding Log tab entry noted by NT as well on it. If you use my version posted, it would work.
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          I am an idiot!

                          come from a programming background where 0 is not a valid index....my brain was in two places...thank you!!

                          :-)

                          Comment


                            #14
                            No worries, glad to assist.
                            BertrandNinjaTrader Customer Service

                            Comment


                              #15
                              ....

                              Next time I'm in Berlin I will buy you a beer...

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Unsuitable, Today, 07:26 PM
                              0 responses
                              1 view
                              0 likes
                              Last Post Unsuitable  
                              Started by jvanelli, Today, 06:36 PM
                              1 response
                              7 views
                              0 likes
                              Last Post jeronymite  
                              Started by twitch251, Today, 05:14 PM
                              1 response
                              5 views
                              0 likes
                              Last Post NinjaTrader_ShawnB  
                              Started by robforee2, Today, 05:07 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post robforee2  
                              Started by blar58, Today, 03:16 PM
                              1 response
                              6 views
                              0 likes
                              Last Post NinjaTrader_Melissa  
                              Working...
                              X