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

NT7/NT8 Conversion

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

    NT7/NT8 Conversion

    I'm not sure about the following conversion. In NT7 we have used

    Add(new Plot(Color.Gray, PlotStyle.Dot, "thisDot"));
    thisDot.Set (Close[0]);

    Is it correct to translate it to the following in NT8?

    AddPlot(new Stroke(Brushes.Gray, 2), PlotStyle.Dot, "thisDot");
    thisDot[0] = Close[0];

    #2
    Hello,

    Thank you for the post.

    Yes this is correct, you can find a sample that shows this syntax in the help guide page for AddPlot:



    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks for your answer.

      Is there an detailed guideline for the NT7 to NT8 conversions? It seems that there is a huge crowd which has been changed and even for me, with more than 20 years programming experience, it's difficult and time consuming to figure out all the details...

      Comment


        #4
        Hello,

        We have a Code breaking changes guide which highlights the majority of changes that break code in the platform.

        Otherwise, the majority of NinjaScript has not changed between 7 and 8 aside from some new features and name changes. Most syntax should be able to transition over with little modification.

        You can find the list of code breaking changes here: http://ninjatrader.com/support/helpG...ng_changes.htm

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Further question for the conversion to NT8:

          In NT7:
          int opacity = 3;
          int alpha = 25 * opacity;
          BarBrushes[0] = Brushes.FromArgb(alpha, Brushes.LimeGreen);

          In NT8, how do i get an alpha transparency to the base color of lime green?

          In NT7 there was the Enum DashStyle. If i'm not wrong, this has been replaced by the Enum DashStyleHelper inherited by the NinjaTrader.Gui Namespace right?
          Last edited by Sweet&Sour; 07-20-2017, 03:20 AM.

          Comment


            #6
            Hello,

            Thank you for the reply.

            To get ARGB in NT8 it is a slight process because NT8 now uses WPF.

            Here is a quick sample on converting a ARGB color to a SolidColorBrush without using any additional references.


            Code:
            string html = string.Format("#{0:X2}{1:X2}{2:X2}{3:X2}",
                    33, // alpha
                    Brushes.LimeGreen.Color.R,
                    Brushes.LimeGreen.Color.G,
                    Brushes.LimeGreen.Color.B);
            Print("HTML COLOR: " + html);
            BackBrush = (SolidColorBrush)new BrushConverter().ConvertFrom(html);

            There are other ways that use less code but require that you reference the System.Drawing assembly so I feel that this is a more viable option.

            Regarding DashStyleHelper, you are correct this is the replacement.

            Please let me know if I may be of additional assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Hi Jesse

              Thanks for your answers.

              My learning curve on NT8 is steadily increasing :-)

              Next NT7/NT8 question:
              Add(new Plot(new Pen(Color.CornflowerBlue, 2), PlotStyle.Line, "Plot1"));
              translates into
              AddPlot(new Stroke(Brushes.CornflowerBlue,2), PlotStyle.Line, "Plot1");

              Is that correct?

              Comment


                #8
                Hello,

                Thank you for the post.

                Yes, that seems to be correct as far as the conversion would go.

                I look forward of being of further assistance.
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  I need another confirmation.

                  In NT7 i have the following snippet:
                  lastBar = Math.Min(this.LastBarIndexPainted, Bars.Count - 1);
                  firstBar = this.FirstBarIndexPainted;

                  In NT8 i have converted it to the following:
                  lastBar = Math.Min(ChartBars.ToIndex, Bars.Count - 1);
                  firstBar = ChartBars.FromIndex;

                  According to the NT8 Help guide, FromIndex is represents the first bar index painted on the chart and ToIndex represents the last bar index painted on the chart

                  Is this correct?
                  Last edited by Sweet&Sour; 07-20-2017, 11:30 PM.

                  Comment


                    #10
                    Hello,

                    Thank you for the reply.

                    You are correct, these properties do represent the first and last bars painted.

                    A simple example would be the following:

                    Code:
                    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
                    {
                    	if (Bars == null || Bars.Count == 0) return;
                    
                    	int firstBarPainted = ChartBars.FromIndex;
                    	int lastBarPainted = ChartBars.ToIndex;
                    	for (int idx = firstBarPainted; idx <= lastBarPainted; idx++)
                    	{
                    		float x = chartControl.GetXByBarIndex(ChartBars, idx);
                    		float y = chartScale.GetYByValue(Bars.GetClose(idx));
                    		RenderTarget.DrawEllipse(new SharpDX.Direct2D1.Ellipse(new SharpDX.Vector2(x, y), 5, 5), Brushes.Magenta.ToDxBrush(RenderTarget));
                    	}
                    }

                    There is a really good example of this use in the Pivots indicator as well. Additionally, for other examples of OnRender items the Drawing Objects contain a lot of excellent examples.

                    I look forward to being of further assistance.
                    JesseNinjaTrader Customer Service

                    Comment


                      #11
                      Thanks for your answer.

                      I had a closer look into the Pivot indicator. To keep my life easy, I just hope that i will never have such a requirement :-)

                      Comment


                        #12
                        One more question. In NT7 i have a....

                        Bars intradayBars = Bars.GetBars(Bars.Instrument, new Period(PeriodType.Minute, minutes, MarketDataType.Last), Bars.From, Bars.To, (Session) Bars.Session.Clone(), Bars.SplitAdjust, Bars.DividendAdjust);

                        In NT8 i was able to translate the first part of it:

                        Bars intradayBars = Bars.GetBars(Bars.Instrument,
                        new BarsPeriod
                        {
                        BarsPeriodType = BarsPeriodType.Minute,
                        Value = minutes
                        }, Bars.From, Bars.To, (Session) Bars.Session.Clone(), Bars.SplitAdjust, Bars.DividendAdjust);

                        How can i translate the parameters...
                        "Bars.From, Bars.To, (Session) Bars.Session.Clone(), Bars.SplitAdjust, Bars.DividendAdjust"
                        ...in NT8?

                        Thanks...

                        Comment


                          #13
                          Hello Sweet&Sour,

                          Thanks for your reply.

                          In NT8 to add a bar series, you would use AddDataSeries(). Please see: http://ninjatrader.com/support/helpG...dataseries.htm
                          Paul H.NinjaTrader Customer Service

                          Comment


                            #14
                            In NT7, there was an interface available called IDataSeries, used to get an array of closing prices, an indicator or a user defined data series.


                            What's the replacement for this interface in NT8?

                            Below is a code snippet of NT7 which i would like to convert to NT8:

                            private IDataSeries highAverage;
                            private IDataSeries lowAverage;

                            highAverage = DEMA(High, period);
                            lowAverage = DEMA(Low, period);

                            highAverage = EMA(High, period);
                            lowAverage = EMA(Low, period);

                            highAverage = HMA(High, period);
                            lowAverage = HMA(Low, period);

                            highAverage = LinReg(High, period);
                            lowAverage = LinReg(Low, period);

                            highAverage = SMA(High, period);
                            lowAverage = SMA(Low, period);

                            highAverage = TEMA(High, period);
                            lowAverage = TEMA(Low, period);

                            Thanks...
                            Last edited by Sweet&Sour; 08-06-2017, 03:22 AM.

                            Comment


                              #15
                              Hello,

                              Thanks for your post.

                              You can find this information in the code breaking changes section of the NT8 helpguide.

                              With reference to the helpguides documentation on code breaking changes: http://ninjatrader.com/support/helpG...ng_changes.htm

                              Data Series
                              Previously there had been type specific Data Series implementations (e.g., IntSeries, TimeSeries, BoolSeries, etc). Now there just is a template Series<T> class which could be used generically and even allows support for additional types:
                              Series<double> mySeries = new Series<double>(this);
                              Series<DateTime> myTimeSeries = new Series<DateTime>(this);


                              Further details here:
                              Series helpguide link: http://ninjatrader.com/support/helpG.../?iseriest.htm
                              Series<T> helpguide link: http://ninjatrader.com/support/helpG...s/?seriest.htm
                              Paul H.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Kaledus, Today, 01:29 PM
                              5 responses
                              12 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by Waxavi, Today, 02:00 AM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_LuisH  
                              Started by alifarahani, Today, 09:40 AM
                              5 responses
                              23 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by gentlebenthebear, Today, 01:30 AM
                              3 responses
                              16 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by PhillT, Today, 02:16 PM
                              2 responses
                              7 views
                              0 likes
                              Last Post PhillT
                              by PhillT
                               
                              Working...
                              X