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 judysamnt7, 03-13-2023, 09:11 AM
                      4 responses
                      59 views
                      0 likes
                      Last Post DynamicTest  
                      Started by ScottWalsh, Today, 06:52 PM
                      4 responses
                      36 views
                      0 likes
                      Last Post ScottWalsh  
                      Started by olisav57, Today, 07:39 PM
                      0 responses
                      7 views
                      0 likes
                      Last Post olisav57  
                      Started by trilliantrader, Today, 03:01 PM
                      2 responses
                      21 views
                      0 likes
                      Last Post helpwanted  
                      Started by cre8able, Today, 07:24 PM
                      0 responses
                      10 views
                      0 likes
                      Last Post cre8able  
                      Working...
                      X