Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

convert NT7 MA "instantaneous slope" calc to NT8

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

    convert NT7 MA "instantaneous slope" calc to NT8

    I have the attached code from NT7 that calculated the "Instantaneous Slope" of a moving average. This is not the same as Angle, Degree, or Radian!

    Any advice on how to do this in NT8?

    Attached Files

    #2
    Because this code came from NT7, most of the code is commented out. Have not tried to compile it in NT8

    so, the double slash "//" in NT7 would not be commented

    four slashes "////" was commented in NT7


    Comment


      #3
      I will pull out all the variables I need and post here

      Comment


        #4
        Hello llanqui,

        Thank you for your post.

        If this is not a script that you have written, I would recommend you contact the vendor that creates the NT7 version and inquire if there is a new version available for NT8.

        If this is a script you have created that you would like to port to NT8, my advice is to start by creating as much of the script as possible in NinjaTrader 8 using the Strategy Builder (or Strategy Wizard).

        This will create the framework of the indicator or strategy which has large changes from NT7 to NT8.

        Then copy all code from the NT7 scripts OnBarUpdate to the OnBarUpdate of the NT8 script.

        This will introduce errors that will need to be resolved. The help guide will be the best way to see how things have changed from nt7 to nt8.

        Below I am including a link to a list of the code breaking changes from NT7 to NT8.


        When first starting to port scripts, I myself would open the NT7 help guide and the NT8 help guide to the same sections so that I could compare.

        The majority of code supported by NinjaTrader is included in the help guides.

        While NT7 renders in GDI+ in the Plot override, NinjaTrader 8 renders with SharpDx using OnRender(). Below is the HG Page for OnRender():



        If you get stuck at anytime looking for equivalent code for NT8, please let us know what particular code you are having trouble converting.
        Last edited by NinjaTrader_Gaby; 09-09-2024, 08:26 AM.

        Comment


          #5
          this originally came from the Big Mike Trading forum, some time ago....

          what I need to do is to identify the variables needed from ChartTrader / Panel and then see if I can map these to NT8


          Comment


            #6
            Hello Ilanqui,

            I'm not seeing anything in the code posted that references the ChartTrader, what in specific are you trying to obtain?

            Comment


              #7
              #

              this is NT7 code from the long ago Big Mike Trading forum

              the arguments for the method CalcSlope prefixed by a_ come from Plot Override

              region Plot.Override
              // public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
              // {
              // int bars;
              //
              // // Default plotting in base class.
              // base.Plot(graphics, bounds, min, max);
              //
              // if (Historical)
              // return;
              //
              // if (!p_DisplaySlopesBR)
              // return;
              //
              // if (base.Bars == null)
              // return;
              //
              //// bars = CalculateOnBarClose ? (ChartControl.BarsPainted - 2) : (ChartControl.BarsPainted - 1);
              //
              //// bars = ChartControl.BarsPainted - 1;
              //
              // bars = ChartControl.BarsPainted;
              //
              // CalcSlope (graphics, bounds, min, max, this.EMA13, 4, Color.Green, bars);
              // CalcSlope (graphics, bounds, min, max, this.SMA20, 3, Color.Orange, bars);
              // CalcSlope (graphics, bounds, min, max, this.SMA50, 2, Color.Brown, bars);
              // CalcSlope (graphics, bounds, min, max, this.SMA100, 1, Color.Red, bars);
              // }
              #endregion​

              ================================================== =================================================

              region CalcSlope
              // private void CalcSlope (Graphics a_graphics, Rectangle a_bounds, double a_min, double a_max, DataSeries a_MASeries, int a_BoxNum, Color a_boxColor, int a_Bars)
              // {
              // int degrees = 0;
              // int index = -1;
              // double slope = 0;
              // bool found = false;
              // int barx = a_Bars;

              // while (barx >= 0)
              // {
              // index = ((ChartControl.LastBarPainted - ChartControl.BarsPainted) + 1) + barx;
              // if (ChartControl.ShowBarsRequired || ((index - base.Displacement) >= base.BarsRequired))
              // {
              // double val = a_MASeries.Get(index);
              // if (!double.IsNaN(val) && (val != 0))
              // {
              // int y2 = (a_bounds.Y + a_bounds.Height) - ((int) (((val - a_min) / ChartControl.MaxMinusMin(a_max, a_min)) * a_bounds.Height));
              // val = a_MASeries.Get(index+1);
              // if (!double.IsNaN(val) && (val != 0))
              // {
              // int y1 = (a_bounds.Y + a_bounds.Height) - ((int) (((val - a_min) / ChartControl.MaxMinusMin(a_max, a_min)) * a_bounds.Height));

              // val = a_MASeries.Get(index+2);
              // if (!double.IsNaN(val) && (val != 0))
              // {
              // if (!found)
              // {
              // found = true;
              // slope = ((180/Math.PI) *(Math.Atan((a_MASeries.Get(index)-((a_MASeries.Get(index+1)+a_MASeries.Get(index+2))/2))/1.5/TickSize)))*-1;
              // degrees=(int) slope;
              // break;
              // }
              // }
              // }
              // }
              // }
              // barx--;
              // }​

              Comment


                #8
                Hello,

                I'm not seeing anything in this code referencing ChartTrader per your last post, do you mean ChartControl?

                Below is the equivalent Help Guide documentation for ChartControl for NT8:



                NinjaTrader 8 renders with SharpDx using OnRender() instead of Plot(). The HG page for OnRender is included in Post #4.

                Comment


                  #9
                  sorry, I meant ChartControl

                  Comment


                    #10
                    probably I can find what I need in the help page you sent

                    I can't always navigate well in your help system

                    I think you also offer a PDF Help...can I download that?

                    Comment


                      #11
                      muchas gracias

                      Comment


                        #12
                        Unfortunately at this time there is no downloadable version of the Help Guide.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        596 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        343 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        103 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        556 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        554 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X