• 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

globalLine

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

    globalLine

    hi, within my indicator, I need to identity all manually drawn horizontal line objects drawn on my chart ... specifically the price level they are drawn at and the color of the line. Can you provide me some direction on this. thank you

    #2
    Hello,
    For User Drawn Objects you could use the code below to find all user drawn horizontal lines and print out the value the user drawn horizontal line is drawn at and the color of the horizontal line.

    foreach(IDrawObject draw in DrawObjects)
    {
    if(draw.UserDrawn)
    {Print(draw.DrawType.ToString());//you can get the tag of the object to help narrow down results
    if(draw.DrawType == DrawType.HorizontalLine)//if the object type is a horizontal line do this
    {
    IHorizontalLine horizontalLine = draw as IHorizontalLine; //neeed to re define the IDrawingObjects as a Horizontal line to access corect values
    Print(horizontalLine.ToString() + horizontalLine.Pen.Color);
    }
    }
    }

    For more information on IDrawObject please see the following link, http://www.ninjatrader.com/support/h...drawobject.htm
    For more information on IHorizonatalLine please see the following link, http://www.ninjatrader.com/support/h...zontalline.htm

    If we can be of any other assistance please let me know.
    Cody B.NinjaTrader Customer Service

    Comment


      #3
      thank you ... very helpful. Is there a way I can extract just the price and the color ... for example

      56.21, Magenta

      Comment


        #4
        Hello,
        You can print out the value and color by changing the print command to the one below.
        Print(horizontalLine.Y.ToString() + " "+ horizontalLine.Pen.Color);

        If we can be of any other assistance please let me know.
        Cody B.NinjaTrader Customer Service

        Comment


          #5
          One more request ... is there a way to print the "horizontalLine.Y.ToString()" without a comma?

          Comment


            #6
            Hello,
            Can you clarify where you are seeing the comma?
            If you are seeing this as where the decimal place is you could use the following to have the value print without any decimal places.
            Print(horizontalLine.Y.ToString("#") + " "+ horizontalLine.Pen.Color);

            This will print out just the integer value of the Y value. If you wanted to print out with decimals up to a certain point, say up to two decimal places for example, you would format it as ToString("##.##");

            You can view more information on Numeric Formatting at the following link, https://msdn.microsoft.com/en-us/lib...vs.110%29.aspx
            Cody B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by [email protected], Yesterday, 07:45 AM
            1 response
            8 views
            0 likes
            Last Post koganam
            by koganam
             
            Started by tgn55, Today, 07:22 AM
            0 responses
            2 views
            0 likes
            Last Post tgn55
            by tgn55
             
            Started by U0000999, Today, 05:17 AM
            0 responses
            4 views
            0 likes
            Last Post U0000999  
            Started by Prataturry89, Today, 03:40 AM
            0 responses
            5 views
            0 likes
            Last Post Prataturry89  
            Started by UltraFastKetoBoost28, Today, 02:43 AM
            0 responses
            6 views
            0 likes
            Last Post UltraFastKetoBoost28  
            Working...
            X