Announcement

Collapse
No announcement yet.

DrawTextRelative() question

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

  • DrawTextRelative() question

    Is there some way to insert a linefeed into a drawText statement? I tried \n, but that didn't work. The problem is that I want to stack two pieces of data. Currently using two drawText statements and what works on one interval for Y-axis spacing doesn't on another. For example, it works great at 21T and merges together at 1 min. Would like to avoid a complex algorithm based on the HL average. Looking for something simple that is not CPU intensive.

    Example:

    10454
    COVER

    Thanks.

  • #2
    Try...

    Try using drawTextPixel()....

    drawTextPixel(ButtonxStart+192, ButtonYStart+15, "PT + .25" + "@URL=EFS:TPTPlusSwitch", Color.black, Color.RGB(0xE0, 0xE0, 0xFF), Text.FRAME | Text.ONTOP | Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM, null, null, "TPTPlus");

    The above is an example from one of my efs files..

    B
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Perhaps I am missing something, but I don't see a linefeed anywhere in that piece of code.

      Comment


      • #4
        Use..

        Use this type of code to STACK text on a chart. like this....

        drawTextPixel(10, 5, "MyText1", Color.black, Color.RGB(0xE0, 0xE0, 0xFF), Text.FRAME | Text.ONTOP | Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM, null, null, "Text1");

        drawTextPixel(10, 15, "MyText2", Color.black, Color.RGB(0xE0, 0xE0, 0xFF), Text.FRAME | Text.ONTOP | Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM, null, null, "Text2");

        This will allow you to create text boxes that do not auto-scale as you change the y axis.

        Try it.
        Brad Matheny
        eSignal Solution Provider since 2000

        Comment


        • #5
          I tried drawTextPixel and the text went off the chart. As I understand drawTextPixel it is for drawing text at specific points on the chart. It does not handle drawing text relative to price bars. Please let me know if this is incorrect.

          Perhaps I am not making myself clear. I want to draw text relative to the Price (high(), low(), etc.). In a single drawText statement I want to stack the text. For example I want one text block that is tied to Xspace from the high() that looks like this:

          COVER
          10459
          +23

          The given block has two linefeeds. I do not want to use three statements. I do not want to put the text at the bottom of the chart or to the left of the chart. I want it tied to a specific price bar. I already have a fairly efficient algorithm to handle the spacing between the price bar and the text as the interval changes.

          I tried using the pixel spacing controls (cx, cy) in drawTextRelative, but they do not appear to be operational at this time. Even if they were, they do not accomplish what I am really after. A linefeed.

          Thanks for your help.

          Comment


          • #6
            My mistake...

            I did not realize that you NEEDED it anchored to price. You'll have to wait for an actual esignal support person to reply.

            My suggestion to use the "pixel" feature would have worked (if you did not need it anchored to price). It is just another way to accomplish TEXT functions.

            Sorry for the confusion.

            B
            Brad Matheny
            eSignal Solution Provider since 2000

            Comment


            • #7
              Hello Gavishti,

              The only way I can think of to accomplish what you need is to use multiple calls to a drawText### function. These functions do not accept JavaScript line feed commands within the string, such as \r or \n. If they did, then this would be very easy. I don't know if it would be possible to modify the drawText### functions to accept the line feeds, but you could drop a suggestion for this to
              [email protected]. I'll add this to my wish list as well.

              As an alternative, I would recommend using the RELATIVETOBOTTOM and/or RELATIVETOTOP flags to display your information. This will allow you to control spacing much easier. See the chart and code example below. Hope this helps.

              PHP Code:
              function preMain() {
                  
              setPriceStudy(true);
                  
              setStudyTitle("Multi-line text");
                  
              setShowCursorLabel(false);
              }

              var 
              bEdit true;

              function 
              main() {
                  if (
              bEdit == true && getCurrentBarIndex() == -5) {
                      var 
              sType "COVER";
                      var 
              nPrice high().toFixed(2);
                      var 
              sAmt "+23";
                      var 
              nSpace getTextHeight(sType14)+1;
                      
                      
              drawTextRelative(00sAmtColor.whiteColor.blue,
                          
              Text.BOTTOM|Text.LEFT|Text.RELATIVETOBOTTOM
                          
              null14"myText1");
                      
              drawTextRelative(0nSpacenPriceColor.whiteColor.blue,
                          
              Text.BOTTOM|Text.LEFT|Text.RELATIVETOBOTTOM
                          
              null14"myText2");
                      
              drawTextRelative(0, (2*nSpace), sTypeColor.whiteColor.blue,
                          
              Text.BOTTOM|Text.LEFT|Text.RELATIVETOBOTTOM
                          
              null14"myText3");
                      
                      
              bEdit false;
                  }


              Jason K.
              Project Manager
              eSignal - an Interactive Data company

              EFS KnowledgeBase
              JavaScript for EFS Video Series
              EFS Beginner Tutorial Series
              EFS Glossary
              Custom EFS Development Policy

              New User Orientation

              Comment


              • #8
                Thanks. Message sent to [email protected].

                Comment


                • #9
                  Response from eSignal Development Team:

                  I've added this to my EFS development list to see if we can get it in one of the next few releases.

                  Comment

                  Working...
                  X