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

Price parameter in Moving Average

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

    Price parameter in Moving Average

    Hi,
    I would like to plot a displaced simple moving average of: (O + C)/2

    How would I modify the Simple Moving Average ninjascript code to effect this change?

    thanks,
    Ben

    #2
    Hi,

    You would have to create a new indicator and create a DataSeries, lets call it displacedData and set its values on each call to the OnBarUpdate() method.

    Something like:

    displacedData.Set((Open[0] + Close[0]) / 2);

    Then you would do something like:

    Plot0.Set(SMA(displacedData, 20)[0]);
    RayNinjaTrader Customer Service

    Comment


      #3
      Could I take the existing Simple Moving Average file make a copy and rename it and add the (O+C)/2 code to it?

      Comment


        #4
        Just open the original SMA file, right click, save as and name it whatever you want. Then just edit the new file and compile it. Make sure to change the indicator references at the top and then you should be good to go.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Hi uacvax,

          Thanks for the help. Can you be more specific about which references need to be changed?

          Thanks,
          Ben

          Comment


            #6
            The class name and display name.
            RayNinjaTrader Customer Service

            Comment


              #7
              MA Angle

              Can someone please help me, in strategy:

              How I can write if I want a certain MA to cross at a Certain "ANGLE"

              say 30 degrees, not less

              Thanks
              Zee

              Comment


                #8
                Hi Zee,

                I have started a new thread specific to your topic here.

                RayNinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Ray View Post
                  Hi,

                  You would have to create a new indicator and create a DataSeries, lets call it displacedData and set its values on each call to the OnBarUpdate() method.

                  Something like:

                  displacedData.Set((Open[0] + Close[0]) / 2);

                  Then you would do something like:

                  Plot0.Set(SMA(displacedData, 20)[0]);
                  I'm not a C# programmer, can you possibly provide any more assistace in creating this indicator?

                  Thanks,

                  Ben

                  Comment


                    #10
                    Unfortunately are unable to provide assistance in programming implementation.

                    Take a look at some of our system indicators such as Stochastics to get an idea of how to use a DataSeries object.
                    RayNinjaTrader Customer Service

                    Comment


                      #11
                      Alternatively,

                      You can contact one of our NinjaScript consultants to help as well.

                      RayNinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by bortz, 11-06-2023, 08:04 AM
                      47 responses
                      1,605 views
                      0 likes
                      Last Post aligator  
                      Started by jaybedreamin, Today, 05:56 PM
                      0 responses
                      8 views
                      0 likes
                      Last Post jaybedreamin  
                      Started by DJ888, 04-16-2024, 06:09 PM
                      6 responses
                      18 views
                      0 likes
                      Last Post DJ888
                      by DJ888
                       
                      Started by Jon17, Today, 04:33 PM
                      0 responses
                      4 views
                      0 likes
                      Last Post Jon17
                      by Jon17
                       
                      Started by Javierw.ok, Today, 04:12 PM
                      0 responses
                      13 views
                      0 likes
                      Last Post Javierw.ok  
                      Working...
                      X