Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trying to migrate to NT8

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

    Trying to migrate to NT8

    I trader with years ago and stopped. I am trying to get back into it. I am also trying to migrate from NT 7 to NT8. I have a few silly but needed indicators I created for charts and filters in analyzer. I see they are not compiling in NT8. I have been away long enough to have no clue how to code this stuff anymore.

    Anyway, can someone help me see where th code changes need to be in this simple line? Mayb I can correct the few others.

    protected override void OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.
    if (CurrentBar < 2)
    return;

    double DesiredValue = (Low[1] <= Low[2] && High[1] <= High[2] && Low [1] <= Low[0]) ? 1.0 : 0;

    if (DesiredValue == 1.0 && MASlopePlot(SlopePlotAverageType.EMA,SlopePlotType .NTS,30)[0] > 0) DrawTriangleUp(CurrentBar.ToString(), false, 0, Low[0] - (TickSize * 10), Color.Lime);
    if (DesiredValue == 0) RemoveDrawObject(CurrentBar.ToString());



    }

    #2
    Hello reedstickets,

    Thanks for your post.

    There are a few key items to look for when converting your scripts from NinjaTrader 7 format to NinjaTrader 8, and we keep a Code Breaking Changes table updated in the NinjaTrader 8 Help Guide to assist in identifying changes or new implementations of familiar methods and properties from NinjaTrader 7: http://ninjatrader.com/support/helpG...ng_changes.htm

    Some notable items to consider when converting your code will be the following:
    • Initialization has changed significantly. Initialize() has been replaced with OnStateChange(), which can be used to filter out different stages of the entire life cycle of a script (SetDefaults, Configure, Historical, Realtime, Terminated, etc.) OnStateChange() is fully covered in the Help Guide.
    • The names of many methods and properties have changed slightly, so you will need to refactor these in your code. The Code Breaking Changes table can make this task much easier, and there is also an alphabetical reference in the Help Guide that can help to find new method/property names: http://ninjatrader.com/support/helpG..._reference.htm
    • In numerous instances, you now have direct access to objects, where in NinjaTrader 7 you had to work with interfaces. For example, rather than the IOrder interface, you now have direct access to an Order object and its related fields. This will require a change in the way items like this are handled in your code.

    As always, we are more than happy to help out with tips and advice in this area, although we do not offer full script conversion services.

    It looks like you are calling another indicator (MASlopePlot()) which also would need to be converted to NT8 if not already. The DrawTriangleUp() method has changed to Draw.TriangleUp(), here is a link to the help guide section on the method: https://ninjatrader.com/support/help...triangleup.htm The other parts of your code should be fine.

    Comment


      #3
      Okay, let me see if I can get it figured out. I can't trade without these few things. They are all small simple codes, but I am not a coder, I figured this out years ago on my own through necessity.

      BTW, I do not need that MA part so it looks like I can just pull it out and it wont cause a problem? TIA

      Comment


        #4
        Hello reedstickets,

        Thanks for your reply.

        If you do not need the MASlopePlot indicator converted then yes that would help simplify your conversion effort.

        An alternative for you would be to hire a 3rd party programmer and if requested we can provide references to 3rd party coders who would be able to meet your needs.

        Comment


          #5
          Thanks. I have bout 3 very small codes like this that basically help me to filter analyzer for trades. You can send me references , but I would be looking for very inexpensive. I do not have time to relearn this but I know how simple it is to do. I am sure someone who knows what thy re doing could fix them for NT8 in under 15 minutes. If the price is worth it to me I will pay to just get moving.

          Actually in NT8 is there a way to see where a stock is trading within it's range for the day?

          Thanks,

          Comment


            #6
            Hello reedstickets,

            Thanks for your reply.

            I will ask our sales team to provide the references.

            Of the code you have displayed, the only complexity was the MASlopePlot(). If you are disregarding that then of the code you have displayed only the Draw method for the triangle has changed and then the change is very slight and I recommend you compare the NT7 help guide for the method to the NT8 method which I had previously provided a link.

            In NT7 it looks like: DrawTriangleUp(CurrentBar.ToString(), false, 0, Low[0] - (TickSize * 10), Color.Lime);
            In NT8 ir looks like: Draw.TriangleUp(this, CurrentBar.ToString(), false, 0, Low[0] - (TickSize * 10), Brushes.Lime);

            As you can see not much has changed except the need to change the method name from DrawTriangleUp to Draw.TriangleUp, adding the word "this" to the beginning, and then changing Color to Brushes.

            I would suggest using the Ninjascript wizard (in NT8 the wizard is used to create all types of files) to create the basic structure of the indicator and then place you OnBarUpdate() code in with adjustments for NT8. Here is a link to the NT8 wizard: https://ninjatrader.com/support/help...?ns_wizard.htm Note that you will want to have any inputs and outputs identified/defined so that when the wizard asks it can include those as well making the building easier for you.


            Comment


              #7
              Hello reedstickets,

              This is Chris following up on behalf of Paul.

              You can employ the services of a third-party NinjaScript programming consultant to help you convert code from NinjaTrader 7 to NinjaTrader 8. You can search our extensive library of NinjaScript consultants 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.

              The 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.

              Let me know if I may be of further assistance.

              Comment


                #8
                Thank you, I will play around with it.

                Comment


                  #9
                  Okay, got that one working. The next one I have to do it is "where in todays range" the stock is trading. NT7 never had a solution so I created a code for it. Does NT8 have a way to show/filter where a stock is trading within it's days range?

                  Comment


                    #10
                    What is the change to "Plot0.Set?

                    Plot0.Set((Close[0] - CurrentDayOHL().CurrentOpen[0]) / (CurrentDayOHL().CurrentOpen[0]) * 100);

                    I read and tried :Plot[0] instead with no luck. I placed :: AddPlot(Brushes.Orange, "Plot"); :: in OnStateChange as well, no luck.

                    TIA

                    I did get 2 indicators working so far though.

                    Comment


                      #11
                      Hello reedstickets,

                      Thanks for your replies, glad to hear of your progress.

                      Regarding, "Okay, got that one working. The next one I have to do it is "where in todays range" the stock is trading. NT7 never had a solution so I created a code for it. Does NT8 have a way to show/filter where a stock is trading within it's days range?" I do not understand your question, what is your definition of "where in todays range" (what defines "todays range"?).

                      Regarding, "What is the change to "Plot0.Set?" In NT7 .Set() was used to provide the value to the plot series. In NT8 you would use the plots name and current bar index to assign the value to the plot. I would suggest not using Plot for the name as that may cause issues. If changing the name does not resolve, please post (or attach) your complete code.

                      Comment


                        #12
                        (what defines "todays range"?).

                        If the stock opened at $1 and traded to $10 then retracted to $7 then it is in the upper half of it's range for the day.

                        Here is my NT7 code: (I am assuming this one will not compile because of the Plot0.Set?)


                        double myValue = ((CurrentDayOHL().CurrentHigh[0] - Close[0]) / (CurrentDayOHL().CurrentHigh[0] - CurrentDayOHL().CurrentLow[0])) * -100;


                        Plot0.Set(myValue);
                        }

                        Comment


                          #13
                          Hello reedstickets,

                          Thanks for your reply.

                          Sorry, I meant to say what is your NT8 coding so far. I recommend attaching the .cs file of the indicator you have created.

                          Comment


                            #14
                            I do not really have any NT8 yet, still trying to understand Plot0.Set and what that has become in NT8. I have read to code break stuff and tried a couple things with no luck.

                            Comment


                              #15
                              I was trying to change Plot0.Set to Plot[0]

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              563 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              329 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              101 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              547 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              548 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X