#region Using declarations
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Gui;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Gui.SuperDom;
using NinjaTrader.Gui.Tools;
using NinjaTrader.Data;
using NinjaTrader.NinjaScript;
using NinjaTrader.Core.FloatingPoint;
using NinjaTrader.NinjaScript.DrawingTools;
#endregion
//This namespace holds Indicators in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Indicators
{
public class LevelImporter : Indicator
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Indicator here.";
Name = "Level Importer";
Calculate = Calculate.OnBarClose;
IsOverlay = true;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = true;
DrawVerticalGridLines = true;
PaintPriceMarkers = true;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Overlay;
//Disable this property if your indicator requires custom values that cumulate with each new market data event.
//See Help Guide for additional information.
IsSuspendedWhileInactive = true;
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level1");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level2");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level3");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level4");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level5");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level6");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level7");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level8");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level9");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level10");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level11");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level12");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level13");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level14");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level15");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level16");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level17");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level18");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level19");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level20");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level21");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level22");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level23");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level24");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level25");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level26");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level27");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level28");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level29");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level30");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level31");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level32");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level33");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level34");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level35");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level36");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level37");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level38");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level39");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level40");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level41");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level42");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level43");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level44");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level45");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level46");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level47");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level48");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level49");
AddPlot(new Stroke(Brushes.Orange), PlotStyle.HLine, "Level50");
}
else if (State == State.Configure)
{
}
}
protected override void OnBarUpdate()
{
//Add your custom indicator logic here.
Level1[0] = Level1Value;
Level2[0] = Level2Value;
Level3[0] = Level3Value;
Level4[0] = Level4Value;
Level5[0] = Level5Value;
Level6[0] = Level6Value;
Level7[0] = Level7Value;
Level8[0] = Level8Value;
Level9[0] = Level9Value;
Level10[0] = Level10Value;
Level11[0] = Level11Value;
Level12[0] = Level12Value;
Level13[0] = Level13Value;
Level14[0] = Level14Value;
Level15[0] = Level15Value;
Level16[0] = Level16Value;
Level17[0] = Level17Value;
Level18[0] = Level18Value;
Level19[0] = Level19Value;
Level20[0] = Level20Value;
Level21[0] = Level21Value;
Level22[0] = Level22Value;
Level23[0] = Level23Value;
Level24[0] = Level24Value;
Level25[0] = Level25Value;
Level26[0] = Level26Value;
Level27[0] = Level27Value;
Level28[0] = Level28Value;
Level29[0] = Level29Value;
Level30[0] = Level30Value;
Level31[0] = Level31Value;
Level32[0] = Level32Value;
Level33[0] = Level33Value;
Level34[0] = Level34Value;
Level35[0] = Level35Value;
Level36[0] = Level36Value;
Level37[0] = Level37Value;
Level38[0] = Level38Value;
Level39[0] = Level39Value;
Level40[0] = Level40Value;
Level41[0] = Level41Value;
Level42[0] = Level42Value;
Level43[0] = Level43Value;
Level44[0] = Level44Value;
Level45[0] = Level45Value;
Level46[0] = Level46Value;
Level47[0] = Level47Value;
Level48[0] = Level48Value;
Level49[0] = Level49Value;
Level50[0] = Level50Value;
}
#endregion
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Plots are bunched up
Collapse
X
-
Plots are bunched up
I'm writing an indicator that would allow me to type in up to 50 price levels and then plot them, however when I run it, the levels on the chart just bunch up together and seem to be in the wrong spot.
Code: -
Hello sonnygrapples,
Thank you for your post.
What are you looking to achieve with your indicator? Is my understanding correct that you would like 50 price levels, which are essentially horizontal plotted lines on the chart, that you may set to the desired values in the indicator properties?
Based on your screenshot, the current values go from 4120, 4110, 4100, 4090, and then several are set to zero. When you change the values and click apply, do you see the changes applied? Are you receiving any error messages on the Log tab of the Control center?
I look forward to your reply.
-
> Is my understanding correct that you would like 50 price levels, which are essentially horizontal plotted lines on the chart, that you may set to the desired values in the indicator properties?
Yes that's correct.
> When you change the values and click apply, do you see the changes applied?
Sort of, when I add new levels, they got plotted on the chart but not in the correct place. As you can see, 4090 is being plotted above 4164. The plots are showing up but they are all in the same area except for the plots that are set to zero.
> Are you receiving any error messages on the Log tab of the Control center?
Nothing in the logs or the ninjascript output window.
Comment
-
Hello sonnygrapples,
Thank you for that information.
I am seeing now that you have the ScaleJustification set as follows in State.SetDefaults:
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Overlay;
I suspect the behavior is due to this being set to Overlay. If you set the ScaleJustification to NinjaTrader.Gui.Chart.ScaleJustification.Right this should make it so that your plots are sharing the same scaling as your data series on the chart. For more information, please see the following link:
Please let me know if you have any additional questions or concerns after adjusting the scale justification. Thank you for your patience.
Comment
-
Well the reason I had it set to overlay is that if I set it to right justified and I have a lot of levels, it distorts the chart by trying to fit all those levels on the screen.
Comment
-
Hello sonnygrapples,
Thank you for your reply.
The behavior of trying to fit all of the levels on the screen has to do with the IsAutoScale property; the default is true for indicators, which means that the plots in your indicator will be set to auto scale with the chart's y-axis. You may set IsAutoScale to false in State.SetDefaults:
You may also manually toggle the indicator's properties, including auto scale and scale justification, in the indicator window (SetDefaults just sets what the default option to be selected in this window will be):
Please let us know if we may be of further assistance.
Comment
-
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
579 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
334 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 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
554 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment