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

Recalling Function in Indicators

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

    Recalling Function in Indicators

    How can I recall the built-in indicators in a customized indicator?

    For example if I want to use the Exponential Moving Average in a new indicator, how can I do it?

    Thanks for any answers.

    #2
    imported post

    Max,

    Please see this link - http://www.ninjatrader-support.com/H...verageEMA.html

    Ray
    RayNinjaTrader Customer Service

    Comment


      #3
      imported post

      I've seen the example and works correcltly, nevertheless I've got a problem to use EMA with my function.

      EX:

      double value = EMA(Close,Period)[0];
      double value2 = EMA(value,Period)[0];


      There is an error on the second string.
      Does the function accept any parameter?


      Comment


        #4
        imported post

        Thanks for the example, no the function only accepts input in the form of an ojbect that implements the IDataSeries interface.

        Basically, it only accepts a DataSeries as input.

        Input;
        High;
        Low;
        Close;
        Volume;
        Indicator; etc...

        You can createa custom dataseries and pass that value in.

        Createa variable under the Variables section.

        private IndicatorSeries mySeries;

        In the Initialize() method:

        mySeries = new IndicatorSeries(this);

        In the OnBarUpdate():

        mySeries.Set(EMA(Close, Period)[0]);
        double value2 = EMA(mySeries, Period)[0];

        Alternatively you can do this:

        double value2 = (EMA(EMA(Close, Period), Period)[0];
        RayNinjaTrader Customer Service

        Comment


          #5
          imported post

          It doesn't work.

          In both cases I've got always the same value and the same plot.
          There is no difference between:

          double value = EMA(Close,Period)[0];

          and

          double value1 = EMA(EMA(Close, Period), Period)[0];

          neither following the DataSeries example.

          Comment


            #6
            imported post

            Max,

            I can't comment on why you would see two different values since I can't see your entire code however, if you look at the attached sample, you will note that two different values are generated and plotted on a chart.

            Ray
            Attached Files
            RayNinjaTrader Customer Service

            Comment


              #7
              imported post

              How can I open your attachment?

              Comment


                #8
                imported post

                It's a zip file. Just click on the link to download it to your PC. Then click on the file to extract the contents.
                RayNinjaTrader Customer Service

                Comment


                  #9
                  imported post

                  I know, I mean how to read a .cs file.

                  Must I import the file into a folder in Ninja?


                  Comment


                    #10
                    imported post

                    Copy the file to C:\Program Files\NinjaTrader 5\bin\custom\indicator

                    You can then open it via Tools-->EditNinjaScript and compile, then add to a chart.

                    Ray
                    RayNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by andrewtrades, Today, 04:57 PM
                    1 response
                    5 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Started by chbruno, Today, 04:10 PM
                    0 responses
                    5 views
                    0 likes
                    Last Post chbruno
                    by chbruno
                     
                    Started by josh18955, 03-25-2023, 11:16 AM
                    6 responses
                    436 views
                    0 likes
                    Last Post Delerium  
                    Started by FAQtrader, Today, 03:35 PM
                    0 responses
                    7 views
                    0 likes
                    Last Post FAQtrader  
                    Started by rocketman7, Today, 09:41 AM
                    5 responses
                    19 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Working...
                    X