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

Building a Simple Indicator For NT8

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

    Building a Simple Indicator For NT8

    Hello,

    I have no coding knowledge but need to build a simple indicator for Ninja Trader 8.

    I want the indicator to plot a line on chart based on following calculation:
    (Highest high of last X bars - Lowest low of last X bars) / 2
    I would appreciate if someone can help me with this.

    Regards,

    Bleda

    #2
    Hello Bld55,

    Welcome to the forums!

    There will be some programming required to create this NinjaScript, but I could show you how that calculation can be made in NinjaScript so you can create this indicator.

    You would want to use MAX() and MIN() to tell you the highest high and the lowest low.

    Values[0][0] = (MAX(High, Period)[0] - MIN(Low, Period)[0]) / 2;

    This calculation is then assigned to Values which is an array of Series<double>'s for each Plot in an indicator. The first [0] would represent the first plot added in the indicator with the index "0" and the second [0] represents the barsAgo index of that plot. 0 would be the current bar in a barsAgo reference. Plots are typically added with the AddPlot() method in OnStateChange() under State.SetDefaults.

    I've included some educational resources on C# and creating indicators from the NinjaTrader 7 helpguide. NinjaScripts are different between NinjaTrader 7 and NinjaTrader 8, but the concepts are still relevant.

    Programming Basics - https://ninjatrader.com/support/help...g_concepts.htm
    Developing Indicators - https://ninjatrader.com/support/help...indicators.htm
    Indicator tutorials - https://ninjatrader.com/support/help...ndicators2.htm

    I will also provide links to the NinjaTrader 8 documentation on the items used to create this indicator.

    Series<t> - https://ninjatrader.com/support/help...us/seriest.htm
    MAX() - https://ninjatrader.com/support/help...aximum_max.htm
    MIN() - https://ninjatrader.com/support/help...inimum_min.htm
    AddPlot() - https://ninjatrader.com/support/help...us/addplot.htm
    Values - https://ninjatrader.com/support/help...-us/values.htm

    Making sure enough bars exist - https://ninjatrader.com/support/foru...ead.php?t=3170

    We also have a webinar on using the NinjaScript Editor.
    Live Webinar - https://ninjatrader.com/Webinar/NinjaScript-Editor-401
    Recorded Video - https://www.youtube.com/watch?v=BA0W4ECyVdc

    Additionally, if you are looking for services to have someone write the code for you, I can have a member of our Business Development team reach out with a list of NinjaScript Consultants who would be happy to create this or any other script at your request.

    Please let me know if I may be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thanks for the detailed reply Jim. I solved my specific requirement but will refer to these info in future.

      Regards,

      Bleda

      Comment


        #4
        I'd be interested in the consultant list. Thanks

        Comment


          #5
          Hello diver,

          You can search our extensive library of vendors who provide programming services through the link below. Simply enter a consultant name or search by using our filter categories. Once you have identified your consultants of choice, please visit each consultant's site for more information or contact them directly to learn more!

          You can locate the contact information for the consultants on their direct websites for any additional questions you may have. Since these consultants are third party services for NinjaTrader all pricing and support information will need to be obtained through the consultant.

          This NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The companies and services listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.

          Please let me know if you have any questions, concerns or if I can provide any further assistance by responding to this thread at your convenience.
          Ryan L.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_Jim View Post
            Hello Bld55,

            Welcome to the forums!

            There will be some programming required to create this NinjaScript, but I could show you how that calculation can be made in NinjaScript so you can create this indicator.

            You would want to use MAX() and MIN() to tell you the highest high and the lowest low.

            Values[0][0] = (MAX(High, Period)[0] - MIN(Low, Period)[0]) / 2;

            This calculation is then assigned to Values which is an array of Series<double>'s for each Plot in an indicator. The first [0] would represent the first plot added in the indicator with the index "0" and the second [0] represents the barsAgo index of that plot. 0 would be the current bar in a barsAgo reference. Plots are typically added with the AddPlot() method in OnStateChange() under State.SetDefaults.

            I've included some educational resources on C# and creating indicators from the NinjaTrader 7 helpguide. NinjaScripts are different between NinjaTrader 7 and NinjaTrader 8, but the concepts are still relevant.

            Programming Basics - https://ninjatrader.com/support/help...g_concepts.htm
            Developing Indicators - https://ninjatrader.com/support/help...indicators.htm
            Indicator tutorials - https://ninjatrader.com/support/help...ndicators2.htm

            I will also provide links to the NinjaTrader 8 documentation on the items used to create this indicator.

            Series<t> - https://ninjatrader.com/support/help...us/seriest.htm
            MAX() - https://ninjatrader.com/support/help...aximum_max.htm
            MIN() - https://ninjatrader.com/support/help...inimum_min.htm
            AddPlot() - https://ninjatrader.com/support/help...us/addplot.htm
            Values - https://ninjatrader.com/support/help...-us/values.htm

            Making sure enough bars exist - https://ninjatrader.com/support/foru...ead.php?t=3170

            We also have a webinar on using the NinjaScript Editor.
            Live Webinar - https://ninjatrader.com/Webinar/NinjaScript-Editor-401
            Recorded Video - https://www.youtube.com/watch?v=BA0W4ECyVdc

            Additionally, if you are looking for services to have someone write the code for you, I can have a member of our Business Development team reach out with a list of NinjaScript Consultants who would be happy to create this or any other script at your request.

            Please let me know if I may be of further assistance.
            Hello Jim,
            I noticed that the indicator manual and tutorials are for NT7. Does anything exists for NT8?

            Thanks

            Petr

            Comment


              #7
              Hello Petr,

              We do not have the same tutorials like we have had for NinjaTrader 7. Our Code Breaking Changes page of the help guide gives a good overview for NinjaScripts in NinjaTrader 8, and the AddPlot documentation (linked post 2) can give further direction for creating and setting plot values. I may also recommend referencing our open source indicators as well as our reference samples for additional direction.

              Code Breaking Changes - https://ninjatrader.com/support/help...ng_changes.htm

              Reference Samples - https://ninjatrader.com/support/help...ce_samples.htm

              We do have a pending feature request to have these tutorials created, and I will add a vote on your behalf. The ticket ID is SFT-1929. We cannot offer an ETA or promise of fulfillment, but we are tracking interest and the ticket ID number will be noted in the help guide when a new build gets released with the feature implemented.

              Release Notes - https://ninjatrader.com/support/help...ease_notes.htm

              The help guide information linked above is publicly available.

              Please let us know if there is anything else we can do to help.
              JimNinjaTrader Customer Service

              Comment


                #8
                I'd like to revive this old thread, it's been a couple of years, have the tutorials been made? Are there any links? I prefer written tutorials, videos take forever.

                What I'm trying to do, is make an indicator on indicator, that plots when the component indicators all agree and do not conflict. I have like 8 in mind to go in it. I have started out with the Wizard, and got almost everything I need there because I know the calculations. I also have the indicator code. My question is, what needs to be included in OnStateChange() section when I copy over the code for a simple slow stochastic, for instance. The stochastic code itself goes after OnBarUpdate() right? And that seems like that would do it. Ideally I'd like to do this for all 8 indicators in mind, and use an if else if format. Can you throw out a template or shell for me to use? Thanks so much.

                Andy

                Comment


                  #9
                  Hello chinaexpert1a,

                  Currently we do not have indicator tutorials for NinjaTrader 8. I may suggest following the NinjaTrader 7 tutorials and then to reference the Code Breaking Changes page of the NinjaTrader 8 Help Guide to review implementation differences.

                  The Strategy Builder can be used to generate logic that adds indicators to the script and can also perform comparisons on those indicator values. I may suggest setting up the logic here and then to set a bool when the condition for an indicator meets your criteria. You can then move the code to an indicator, and if all the bools are true, you can assign a plot a "1" to signal that all are true.

                  Further information on adding plots and assigning values can be found here - https://ninjatrader.com/support/help...8/?addplot.htm

                  You may also use a New Indicator Wizard in the NinjaScript Editor to create a template that has plots added. You would then just need to assign the plot values with what you have set up in the Strategy Builder.

                  Using New NinjaScript Wizards - https://ninjatrader.com/support/help.../ns_wizard.htm

                  We look forward to assisting.
                  JimNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Radano, 06-10-2021, 01:40 AM
                  19 responses
                  606 views
                  0 likes
                  Last Post Radano
                  by Radano
                   
                  Started by KenneGaray, Today, 03:48 AM
                  0 responses
                  4 views
                  0 likes
                  Last Post KenneGaray  
                  Started by thanajo, 05-04-2021, 02:11 AM
                  4 responses
                  470 views
                  0 likes
                  Last Post tradingnasdaqprueba  
                  Started by aa731, Today, 02:54 AM
                  0 responses
                  5 views
                  0 likes
                  Last Post aa731
                  by aa731
                   
                  Started by Christopher_R, Today, 12:29 AM
                  0 responses
                  11 views
                  0 likes
                  Last Post Christopher_R  
                  Working...
                  X