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:	121
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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        127 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        73 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        115 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        109 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        88 views
        0 likes
        Last Post CarlTrading  
        Working...
        X