Announcement

Collapse
No announcement yet.

text is not drawn at correct position under certain flag combination

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

  • text is not drawn at correct position under certain flag combination

    I just found sometimes the text is not drawn by drawText() at the correct position. For example, in my testing EFS, if I use Text.RELATIVETOBOTTOM | Text.BOTTOM, the text is drawn at a position higher than it should be.


    - Clearpicks
    Attached Files

  • #2
    clearpicks
    As I understand it the vertical location of the text appears to be correct. If you use Text.BOTTOM you are aligning the bottom of the text to its location which is set by the height of the font.
    Here is a modified copy of your script where you can see the effects of using the TOP, VCENTER and BOTTOM flags. Keep in mind that if you do not enter a vertical alignement flag it will position it as if you had used the Text.TOP flag
    Alex

    PHP Code:
    var isDone false;

    function 
    preMain(){
        
    setPriceStudy(true);
    }

    function 
    main(){
        if ( 
    getBarState() == BARSTATE_NEWBAR && getCurrentBarIndex() == ) {
            if ( 
    isDone == false ) {
                
    isDone true;
                
    drawTextRelative(-10"Text.VCENTER"Color.whiteColor.redText.RELATIVETOBOTTOM Text.BOLD |
                                
    Text.ONTOP Text.VCENTER Text.CENTER"Arail"16"1");
                
    drawTextRelative(-200"Text.TOP"Color.whiteColor.redText.RELATIVETOBOTTOM Text.BOLD |
                                
    Text.ONTOP Text.TOP Text.CENTER"Arail"16"2");
                
    drawTextRelative(-300"Text.BOTTOM"Color.whiteColor.redText.RELATIVETOBOTTOM Text.BOLD |
                                
    Text.ONTOP Text.BOTTOM Text.CENTER"Arail"16"3");
            }
            else {
            }
        }




    Originally posted by clearpicks
    I just found sometimes the text is not drawn by drawText() at the correct position. For example, in my testing EFS, if I use Text.RELATIVETOBOTTOM | Text.BOTTOM, the text is drawn at a position higher than it should be.


    - Clearpicks

    Comment


    • #3
      Thank you, Alex. I thought the base line was the one specified by y. Actually it seems it should be y+font height.

      Comment


      • #4
        clearpicks
        You are welcome.
        It needs to be related to the font height else if you used the Text.TOP flag the text would not be visible or if you used the bar locations (ie AboveBarX, BelowBarX) the text would end up in the incorrect location(s)
        Alex


        Originally posted by clearpicks
        Thank you, Alex. I thought the base line was the one specified by y. Actually it seems it should be y+font height.

        Comment

        Working...
        X