Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Default ConstantLines plots - make plots global?
Collapse
X
-
Default ConstantLines plots - make plots global?
I recently stumbled through customizing the default ConstantLines indicator to include all the levels I identify during my morning analysis and as the day progresses. I use multiple timeframes for the same instrument on independent chart tabs - 1M, 5M, 15M, etc. and would like to avoid having to reload the indicator template on each one whenever I update my levels. Is there a way to make the ConstantLines horizontal line plots global options that will then display on all the other timeframes of the same instrument? Thanks!Last edited by WileCoyote; 01-22-2025, 07:23 AM.Tags: None
-
Hello WileCoyote,
With how the indicator is coded it cannot make global lines, you could make a copy of the indicator and then edit it to use horizontal drawing objects, those can be set to global.
Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.
Draw.HorizontalLine(NinjaScriptBase owner, string tag, double y, bool isGlobal, string templateName)
-
Jesse,
Thanks for the response. I'm not a coder but was able to customize a copy for what I want to do (just added more lines and re-labeled them). I don't know where to add what you mentioned. Screenshot below:
Comment
-
Hello WileCoyote,
That need sto go in the OnBarUpdate region, if you look at the original code:
protected override void OnBarUpdate()
{
if (Line1Value != 0) Line1[0] = Line1Value;
if (Line2Value != 0) Line2[0] = Line2Value;
if (Line3Value != 0) Line3[0] = Line3Value;
if (Line4Value != 0) Line4[0] = Line4Value;
}
You can add code after that point for example
protected override void OnBarUpdate()
{
if (Line1Value != 0) Line1[0] = Line1Value;
if (Line2Value != 0) Line2[0] = Line2Value;
if (Line3Value != 0) Line3[0] = Line3Value;
if (Line4Value != 0) Line4[0] = Line4Value;
Draw.HorizontalLine(this, "line1", Line1Value, true, "MyTemplateNameForTheColor");
Draw.HorizontalLine(this, "line1", Line2Value, true, "MyTemplateNameForTheColor");
Draw.HorizontalLine(this, "line1", Line3Value, true, "MyTemplateNameForTheColor");
Draw.HorizontalLine(this, "line1", Line4Value, true, "MyTemplateNameForTheColor");
}
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
557 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
324 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
545 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
547 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment