Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

how to format a isGlobal line

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

    how to format a isGlobal line

    I am writing a simple indicator that draws lines but I would need to change the color, dash type and width. Checking the reference I can't find an overload of Draw.Line() that would allow me to draw this line, format it graphically and make it visible on all graphs in the same tool. How is this possible ?
    What solution can I use ?​

    #2
    i know that i can use a custom template and isGlobal together but i need a lot of templates.... it would be better to set the style directly when I draw the line

    Comment


      #3
      Hello sn0z33r,

      You can save the object to a variable and then set properties on it (that are not in the overload parameters).

      For example:

      Draw.Line(NinjaScriptBase owner, string tag, bool isAutoScale, int startBarsAgo, double startY, int endBarsAgo, double endY, bool isGlobal, string templateName)

      if (CurrentBar > 5)
      {
      Line myLine = Draw.Line(this, "myLine" + CurrentBar, true, 5, Close[5], 0, Close[5], true, null);
      myLine.Stroke = new Stroke(Brushes.Green, DashStyleHelper.Dash, 5);
      }

      This comes from the code sample in the help guide.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        thank you, I think that's exactly what I was looking for. I will try it right away !

        Comment


          #5
          ok, it works fine but i had to declare myLine as var and force cast to NinjaTrader.NinjaScript.DrawingTools.Line

          var myLine = Draw.Line(this, "myLine" + CurrentBar, true, 5, Close[5], 0, Close[5], true, null) as NinjaTrader.NinjaScript.DrawingTools.Line;
          myLine.Stroke = new Stroke(Brushes.Green, DashStyleHelper.Dash, 5);

          Comment


            #6
            Hello sn0z33r,

            This may be due to use var as the variable type instead of Line.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            47 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            22 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            33 views
            1 like
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            50 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            42 views
            0 likes
            Last Post CarlTrading  
            Working...
            X