Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calculating y Pos of DrawText with autoScale=true

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

    Calculating y Pos of DrawText with autoScale=true

    I use DrawText() to draw values above or below the bars with autoScale=ture, otherwise the text may be outsize of the visible panel.

    In this situation it is challenging to calculate the offset of the text below or above the bar, since out-of-school change the value.

    I also would like to draw a line from the end of the bar to the bottom of the text, but that position is very hard to calculate.

    Is there any way to get the actual text rectangle position when autoScale=true?

    #2
    Hello Shai Samuel,

    Thank you for your post.

    Would you not use the offset value DrawText() to draw the line? How are you currently calculating the offset for the DrawText()? How does the offset become hard to calculate when using AutoScale = True?

    I look forward to your response.

    Comment


      #3
      Would you not use the offset value DrawText() to draw the line?
      Patrick, when I use offset, and my text is a few lines (using \n), the text got to hide or cut the top of bottom of the panel some of the times.

      What I do is a combination of yOffset and yPos which works, but not always.

      HTML Code:
      int 	textOffsetXspace = 4;
      int 	textOffsetX = 3;
      double 	textOffsetY = 20;
      int		yTextOffset = 5;
      int 	textBgOpacity = 2;
      Color 	tradeResultColor = trendLineColor;
      Color	textColor = Color.Black;
      StringAlignment textAlign = StringAlignment.Center;
      int 	xPos = iLast+textOffsetX;
      double	yPos = this.MAX(this.High, textOffsetX + textOffsetXspace)[iLast] + textOffsetY * this.TickSize;
      double	yTextPos = yPos + System.Convert.ToDouble(yTextOffset * this.TickSize);
      IText text = this.DrawText(iName+".ResultText", true, resultText, xPos, yTextPos, 
      yTextOffset, textColor, textFont, textAlign, tradeResultColor, tradeResultColor, textBgOpacity);
      if (text != null)
      	text.Locked = false;
      this.DrawLine(iName+".ResultGuide", true, xPos-1, yTextPos, 
      			iLast, this.Close[iLast], tradeResultColor, DashStyle.Dash, 1);
      The result is attached.
      Attached Files

      Comment


        #4
        Hello Shai Samuel,

        Thank you for your response.

        I am not aware of a method to pull the rectangle position when using DrawText. However, you can pull the Y value using the IText object. Can you provide an example when the Panel is cutting off the text in the rectangle of the DrawText?

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        563 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        329 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        547 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        547 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X