• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get ChartHorizontalLie color propierty

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

    Get ChartHorizontalLie color propierty

    Hi

    How can I get the line's color in the chart?

    I do:

    foreach (ChartObject CO in this.ChartControl.ChartObjects)
    {
    if (CO is NinjaTrader.Gui.Chart.ChartHorizontalLine)
    {
    }
    }

    But I can't get the Color Property.

    Best Regards
    David

    #2
    Hello,

    If you are trying to access a drawing object from script I will provide an example below.

    You need to cast the object as the correct type to get its Pen property, there is not a Color property for any of the drawing objects as they use Pens. The color is in turn defined in the pen along with other parameters for the lines style.

    Code:
    foreach (IDrawObject draw in DrawObjects)
    {
    	if(draw.DrawType == DrawType.HorizontalLine)
    	{
    		IHorizontalLine hLine = draw as IHorizontalLine;	
    		Print(hLine.Pen.Color.ToString());
    		if(hLine.Pen.Color == Color.Blue)
    			hLine.Pen.Color = Color.Red;
    	}
    }
    For all of the drawing object types, they basically all just start with a capital I, or IRay, IHorizontalLine, etc...

    If you do not cast the object to the correct type of object that it is, you will be missing the additional drawing object specific properties from the options that you are presented with.

    Please let me know if I may be of additional assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi David,

      Here is a similar approach if you decide to use unsupported methods:


      foreach (ChartObject CO in this.ChartControl.ChartObjects) {
      ChartHorizontalLine line = CO as ChartHorizontalLine;
      Color lineColor;
      if (line != null) lineColor = line.Pen.Color;
      }
      Last edited by ninZa; 01-27-2015, 11:06 PM.
      ninZa
      NinjaTrader Ecosystem Vendor - Ninza

      Comment


        #4
        Hi David,

        I have edited my answer. The correct use is: line.Pen.Color

        Cheers.
        Pi
        ninZa
        NinjaTrader Ecosystem Vendor - Ninza

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by ketoproplus, Today, 05:08 AM
        0 responses
        3 views
        0 likes
        Last Post ketoproplus  
        Started by asmmbillah, Today, 03:55 AM
        0 responses
        4 views
        0 likes
        Last Post asmmbillah  
        Started by cmarkb, Today, 12:04 AM
        0 responses
        6 views
        0 likes
        Last Post cmarkb
        by cmarkb
         
        Started by supernova0219, Yesterday, 07:48 PM
        0 responses
        10 views
        0 likes
        Last Post supernova0219  
        Started by qwfxny, Yesterday, 07:20 PM
        0 responses
        12 views
        0 likes
        Last Post qwfxny
        by qwfxny
         
        Working...
        X