Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Default ConstantLines plots - make plots global?

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

    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.

    #2
    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)

    Comment


      #3
      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:
      Click image for larger version

Name:	image.png
Views:	110
Size:	105.8 KB
ID:	1331978

      Comment


        #4
        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
        581 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        338 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
        554 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        552 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X