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

Help Converting NT 7 Indicator to NT 8

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

    Help Converting NT 7 Indicator to NT 8

    I'm attempting to convert an NT 7 indicator to NT 8.

    I have created a new indicator in NT 8 and have copied properties and Plots from the NT 7 indicator.

    Next I'm working on "On Bar Update".

    I'm bringing in the following code:

    LinRegCurve.Set(LinReg(base.Input,length)[0]);



    I have made the code breaking changes to yield the following :

    LinRegCurve(0) = LinReg(base.Input,length)[0];


    The compiler error when running this is "the name LinRegCurve" does not exist.

    In NT 7 I had:

    Private DataSeries LinRegCurve (in the Variables )

    LinRegCurve = new DataSeries(this); (in the Initialize)


    Where do these go in NT 8?


    Thanks
    taddypole...






    #2
    Hi, DataSeries should be in "State.DataLoaded", in "OnStateChange".

    if (State == State.DataLoaded)
    {
    LinRegCurve = new DataSeries(this);
    }
    sidlercom80
    NinjaTrader Ecosystem Vendor - Sidi Trading

    Comment


      #3
      Originally posted by sidlercom80 View Post
      Hi, DataSeries should be in "State.DataLoaded", in "OnStateChange".

      if (State == State.DataLoaded)
      {
      LinRegCurve = new DataSeries(this);
      }
      LinRegCurve = new Series<double>(this);

      Comment


        #4
        per the attachment...
        I still get LinRegCurve does not exist..????
        Attached Files

        Comment


          #5
          Originally posted by Taddypole View Post
          The compiler error when running this is "the name LinRegCurve" does not exist.

          In NT 7 I had:

          Private DataSeries LinRegCurve (in the Variables )

          LinRegCurve = new DataSeries(this); (in the Initialize)

          Where do these go in NT 8?
          private Series<double> LinRegCurve; // in the variables, at the top

          Comment


            #6
            Thanks for the suggestions above... I am not on my way to converting this indicator....


            I have another question. How do I deal with color variables?


            see attachment:

            Click image for larger version

Name:	convert Colors to NT 8.png
Views:	214
Size:	184.6 KB
ID:	1184957




            Comment


              #7
              Hello Taddypole,

              NinjaTrader 8 uses Series<double> as the variable type and new Series<double> to instantiate a custom series within State.DataLoaded and AddDataSeries() for adding another instrument or timeframe as dataseries.



              Colors, once used for Forms, is now Brushes with WPF (Windows Presentation Foundation).
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by Taddypole View Post
                I have another question. How do I deal with color variables?
                I suggest you look at the source code for the indicator @VolumeZones.cs.
                Study this standard indicator in your NT8 indicators folder.

                Why that indicator?
                Because that indicator shows how to define user-defined colors as properties,
                which in NT8 is technically user-defined brushes. You get several benefits by
                seeing how the brushes are used in various circumstances.

                But the really great thing?
                You can also look at the older NT7 version of the same indicator, and get a
                feel how it was changed to work with NT8.

                You can also try studying @VolumeProfile.cs.
                As well as NT7's @CustomPlotSample.cs vs NT8's @SampleCustomRender.cs.

                Good luck!


                Comment


                  #9
                  I'm advancing through my code and all your help is greatly appreciated.

                  In the first attachment I have two lines of code for DrawLine and DrawText. They are not compiling and I think its due to the StTermColor term.

                  In the second attachment I show where I tried to define the Color (Brushes) parameters.

                  Any suggestions that might help me compile without errors?


                  Click image for larger version

Name:	problem with StTermColor.png
Views:	321
Size:	739.8 KB
ID:	1185079Click image for larger version

Name:	Color Parameters.png
Views:	296
Size:	499.0 KB
ID:	1185080

                  Comment


                    #10
                    Hello Taddypole,

                    Below is a link to a forum post on porting scripts. Be sure to look up items in the Code Breaking Changes in the help guide.


                    DrawLine() is now Draw.Line().

                    DrawText() is now Draw.Text().


                    Colors are now Brushes. See post #7.

                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      I fixed the Draw.Text and Draw.Line and am still left with the StTermColor not being able to be converted.
                      Click image for larger version

Name:	Fixed DrawText and DrawLine.png
Views:	225
Size:	584.0 KB
ID:	1185141

                      Comment


                        #12
                        Originally posted by Taddypole View Post
                        I fixed the Draw.Text and Draw.Line and am still left with the StTermColor not being able to be converted.
                        What, specifically, is your question?
                        Last edited by bltdavid; 01-11-2022, 04:35 AM.

                        Comment


                          #13
                          I'm thinking my declaration of StTermColor is not correct for NT 8 and that is the reason for my compiler error.

                          And how do I resolve the compiler error... (Argument 8: cannot convert from 'System.Windows.Media.Brushes' to 'System.Windows.Media.Brush')




                          Click image for larger version  Name:	Color Parameters.png Views:	0 Size:	499.0 KB ID:	1185176
                          Last edited by Taddypole; 01-11-2022, 07:52 AM.

                          Comment


                            #14
                            Hello Taddypole,

                            private Brush myBrush;

                            myBrush = Brushes.Green;
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Thanks ChelseaB...
                              That helped....

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Brevo, Today, 01:45 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post Brevo
                              by Brevo
                               
                              Started by aussugardefender, Today, 01:07 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post aussugardefender  
                              Started by pvincent, 06-23-2022, 12:53 PM
                              14 responses
                              241 views
                              0 likes
                              Last Post Nyman
                              by Nyman
                               
                              Started by TraderG23, 12-08-2023, 07:56 AM
                              9 responses
                              384 views
                              1 like
                              Last Post Gavini
                              by Gavini
                               
                              Started by oviejo, Today, 12:28 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post oviejo
                              by oviejo
                               
                              Working...
                              X