Any advice on how to do this in NT8?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
convert NT7 MA "instantaneous slope" calc to NT8
Collapse
X
-
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
-
#
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
-
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
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
602 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
347 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
103 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
559 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
558 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment