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:	125
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 Mindset, 04-21-2026, 06:46 AM
        0 responses
        44 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        54 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        34 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        95 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        57 views
        0 likes
        Last Post PaulMohn  
        Working...
        X