- Create an empty indicator.
- Write only your lines adjusting code.
- Load the indicator on a chart.
- Save the chart as the Default Template.
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!
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
NinjaTrader
Set Right Margin Horizontal Gridlines via NinjaScript
Collapse
X
-
Originally posted by koganam View Post- Create an empty indicator.
- Write only your lines adjusting code.
- Load the indicator on a chart.
- Save the chart as the Default Template.
Thanks for your help.
Take care,
Aventeren
Comment
-
Quick Update:
I created a "Base" indicator that I now plug into all of my charts. I am able to control the horizontal grid lines to a dollar value of my choosing. However, I have been setting up my chart with a monthly data series in panel 1, a weekly data series in panel 2 and a daily data series in panel 3, and I for the life of me can't get all three panels to display the correct grid line intervals.
My indicator uses the following code to set the gridlines:
Code:#region Using declarations using System; using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.ComponentModel; using System.Xml.Serialization; using NinjaTrader.Data; using NinjaTrader.Gui.Chart; #endregion namespace NinjaTrader.Indicator { [Description("Indicator to hold the base elements for use on all charts.")] public class AventerenBase : Indicator { private double valueGrid = 500; protected override void Initialize() { ClearOutputWindow(); Overlay = true; DrawOnPricePanel = true; } protected override void OnStartUp() { ChartControl.HorizontalGridLines = true; ChartControl.HorizontalGridLinesIntervalRight = Convert.ToInt32(ValueGrid/(Instrument.MasterInstrument.TickSize * Instrument.MasterInstrument.PointValue)); } protected override void OnBarUpdate() { } #region Properties [Description("Period")] [GridCategory("Parameters")] public double ValueGrid { get { return valueGrid; } set { valueGrid = Math.Max(1, value); } } #endregion } }
So as you can see, the Monthly panel 1 grid lines are correct, as I have the grid value set at 500, so the gridlines would be $500/$12.50/tick = 40 ticks. But panels 2 and 3 are wrong.
Does anyone have an idea on how I might control the horizontal grid line intervals on panels 2 and 3?
Thanks,
Aventeren
Comment
-
This is untested code so I wouldn't know of any consequences of using such, but you can create a new instance of the data panels and set the value from there:
Code:protected override void OnStartUp() { ChartControl.HorizontalGridLines = true; PanelData panels = new Gui.Chart.PanelData(); panels.HorizontalGridLinesIntervalRight = Convert.ToInt32(ValueGrid/(Instrument.MasterInstrument.TickSize * Instrument.MasterInstrument.PointValue)); }
MatthewNinjaTrader Product Management
Comment
-
Originally posted by NinjaTrader_Matthew View PostThis is untested code so I wouldn't know of any consequences of using such, but you can create a new instance of the data panels and set the value from there:
Code:protected override void OnStartUp() { ChartControl.HorizontalGridLines = true; PanelData panels = new Gui.Chart.PanelData(); panels.HorizontalGridLinesIntervalRight = Convert.ToInt32(ValueGrid/(Instrument.MasterInstrument.TickSize * Instrument.MasterInstrument.PointValue)); }
It's weird, sometimes panel 1 is right and then sometimes panel 1 won't print any grid lines or axis values at all. Same with panels 2 and 3. Sometimes I'll get a combination of 1 and 2 that are right but panel 3 will be wrong. Then I switch instruments (i.e., ES to CL), and gridlines and axis values disappear.
Let me know if you or anyone else on your Team has any other ideas.
Thanks,
Aventeren
Comment
-
Originally posted by aventeren View PostQuick Update:
I created a "Base" indicator that I now plug into all of my charts. I am able to control the horizontal grid lines to a dollar value of my choosing. However, I have been setting up my chart with a monthly data series in panel 1, a weekly data series in panel 2 and a daily data series in panel 3, and I for the life of me can't get all three panels to display the correct grid line intervals.
My indicator uses the following code to set the gridlines:
Code:#region Using declarations using System; using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.ComponentModel; using System.Xml.Serialization; using NinjaTrader.Data; using NinjaTrader.Gui.Chart; #endregion namespace NinjaTrader.Indicator { [Description("Indicator to hold the base elements for use on all charts.")] public class AventerenBase : Indicator { private double valueGrid = 500; protected override void Initialize() { ClearOutputWindow(); Overlay = true; DrawOnPricePanel = true; } protected override void OnStartUp() { ChartControl.HorizontalGridLines = true; ChartControl.HorizontalGridLinesIntervalRight = Convert.ToInt32(ValueGrid/(Instrument.MasterInstrument.TickSize * Instrument.MasterInstrument.PointValue)); } protected override void OnBarUpdate() { } #region Properties [Description("Period")] [GridCategory("Parameters")] public double ValueGrid { get { return valueGrid; } set { valueGrid = Math.Max(1, value); } } #endregion } }
[ATTACH]30398[/ATTACH]
So as you can see, the Monthly panel 1 grid lines are correct, as I have the grid value set at 500, so the gridlines would be $500/$12.50/tick = 40 ticks. But panels 2 and 3 are wrong.
Does anyone have an idea on how I might control the horizontal grid line intervals on panels 2 and 3?
Thanks,
Aventeren
However, for starters, you are using an int for ChartControl.HorizontalGridLinesIntervalRight. It is supposed to be a double. Yes, using an int instead of a double can throw off your calculations.
Without more precise, detailed information, that is all that I can say for now.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Rapine Heihei, Today, 08:19 PM
|
1 response
8 views
0 likes
|
Last Post Today, 08:30 PM | ||
Started by Rapine Heihei, Today, 08:25 PM
|
0 responses
6 views
0 likes
|
Last Post Today, 08:25 PM | ||
Started by f.saeidi, Today, 08:01 PM
|
1 response
9 views
0 likes
|
Last Post Today, 08:17 PM | ||
Change colour of Stop market and limit orders to red and green via indicator script
by Rapine Heihei
Started by Rapine Heihei, Today, 07:51 PM
|
0 responses
8 views
0 likes
|
Last Post Today, 07:51 PM | ||
Started by frslvr, 04-11-2024, 07:26 AM
|
5 responses
98 views
1 like
|
Last Post
by caryc123
Today, 07:47 PM
|
Comment