Announcement

Collapse
No announcement yet.

drawTextRelative behaving as drawTextAbsolute

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

  • drawTextRelative behaving as drawTextAbsolute

    For High, Low, Close lines, line labels (drawTextRelative) intended to be displayed in the chart margin (bar +2) relative to the line and current bar are instead remaining at a fixed x-axis point (as if drawTextAbsolute was used).

    For example: For a line drawn at the value of the prior day's high.

    var vHigh = getValueAbsolute("High", vIndex, vSymbol);

    The label is coded as:

    drawTextRelative(2, vHigh, " H ", Color.black, Color.lime, Text.BOLD | Text.FRAME | Text.BOTTOM | Text.ONTOP, null, 10, "High");

    Instead of what I want, this places the text box at bar 2 after the period the vHigh value is first obtained (beginning of the day), and that's it. It's in the wrong location, and it never moves. What I want to do is have the text box always display in the chart margin on bar 2 to the right of the associated line, always relative to the current bar. I also can't find a text flag that will cause the text box to display on the line centerline; it only displays TOP or BOTTOM.

    Any suggestions? Thanks in advance.

  • #2
    Lancer
    In the mean time the flag for centering text is Text.VCENTER
    Alex

    Comment


    • #3
      Thanks Alex, geez that was on the Flags list too. Just missed it.

      If it helps, here's the formula I'm working with. The drawTextRelative lines I'm working on start at line 255.
      Attached Files

      Comment


      • #4
        Hello Lancer,

        Did you try drawTextAbsolute()? Let me know if this does what you want.
        Attached Files
        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


        • #5
          That works. I see what I did. I cut and pasted drawTextRelative() lines from another formula, which in that application, displayed correctly. In my application, drawTextAbsolute() was needed. Thanks Jason.

          Comment


          • #6
            Unrelated to drawText, another thing I'd like to fix in this formula (attached in prior post below) has to do with rounding:

            What code is needed (and where) to round the values for pivot lines so that the lines are displayed in increments in which the security trades? Example, for index futures: ES needs rounding to .25 increments; NQ needs rounding to .50 increments.

            Once I understand how the rounding works, I'll change it as needed per symbol. Thanks for any help.
            Last edited by Lancer; 08-14-2003, 12:04 PM.

            Comment


            • #7
              Hello Lancer,

              To accomplish this, I added a custom function, roundIt(), which you will see at the bottom of the formula. On lines 231-250, pass the value of the pivot and the rootSymbol to the function. If the rootSymbol is not ES or NQ the function will not perform any rounding.

              PHP Code:
              function roundIt(vNumrootSymbol) {
                  
              vNum vNum "";
                  
              //return eval(vNum);    // enable this line to return to original numbers.
                  
              var cntr vNum.length;
                  if (
              rootSymbol == "ES ") {          //.25
                      
              var vDiv 25;
                  } else if(
              rootSymbol == "NQ ") {    //.50
                      
              var vDiv 50;
                  }
                  if (
              rootSymbol == "ES " || rootSymbol == "NQ ") {
                      var 
              hold_chr1 vNum.slice(0cntr 3);
                      var 
              hold_chr2 vNum.slice(cntr-2cntr);
                      
              hold_chr2 Math.round(hold_chr2/vDiv) * vDiv;
                      if (
              hold_chr2 == 0hold_chr2 "0" hold_chr2;
                      if (
              hold_chr2 == 100) {
                          
              hold_chr2 "00"
                          
              hold_chr1 = eval(hold_chr1) + 1;
                      }
                      
              vNum hold_chr1 "." hold_chr2
                  }
                  return eval(
              vNum);

              Attached Files
              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
                Wow, nice. That's more than I thought it would require. Thanks Jason. I'm finding though, that about half the time it's not rounding on the increment. Here are the NQ values for the regular session today.

                R5: 1284.66 EFS Rounded: 1285.00 Should be: 1284.50
                R4: 1276.33 EFS Rounded: 1276.50 OK
                R3: 1268.00 EFS Rounded: Same OK
                R2: 1259.51 EFS Rounded: 1259.50 OK
                R1: 1251.33 EFS Rounded: 1251.00 Should be: 1251.50
                P: 1242.16 EFS Rounded: 1242.00 OK
                S1: 1233.83 EFS Rounded: 1233.50 Should be: 1234.00
                S2: 1224.66 EFS Rounded: 1224.50 OK
                S3: 1216.33 EFS Rounded: 1216.00 Should be: 1216.50
                S4: 1208.00 EFS Rounded: Same OK
                S5: 1199.66 EFS Rounded: 1199.00 Should be 1199.50

                ES values for the regular session show similar results, for example:

                R5: 1020.58 EFS Rounded: 1020.75 Should be 1020.50
                R1: 991.91 EFS Rounded: 991.75 Should be 992.00
                (and more)

                Can you identify the problem?

                Comment


                • #9
                  Hi Lancer,

                  Found the problem. Here's the new file.
                  Attached Files
                  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


                  • #10
                    Hmmm. Now getting value and rounding errors on just about every line. For NQ after-hours session today:

                    R1: 1255.83 EFS Rounded: 1255.50 Should be 1256.00
                    P: 1245.16 EFS Rounded: 1245.00 OK
                    S1: 1234.83 EFS Rounded: 1234.50 Should be 1235.00
                    S2: 1224.16 EFS Rounded: 1224.00 OK
                    S3: 1213.83 EFS Rounded: 1213.50 Should be 1214.00
                    S4: 1203.50 EFS Rounded: 1203.00 Should be 1203.50
                    S5: 1193.16 EFS Rounded: 1192.50 Should be 1193.00
                    and so on.. (on 50% midpoint lines too).

                    Comment


                    • #11
                      Hi Lancer,

                      Now we should have if fixed. The problem was that some of the pivots were getting rounded and then used in subsequent pivot calculations. Now it will do all the pivot calculations first and then apply the rounding.
                      Attached Files
                      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


                      • #12
                        Jason K

                        I use the following to round up or down to the nearest fractional part of the es

                        handle=0.25;
                        var1Round=Var1-Var1%handle+handle;

                        That line rounds up. To round down, just

                        handle=0.25;
                        var1Round=Var1-Var1%handle;

                        Comment


                        • #13
                          Hi David,

                          Very cool and efficient method. I've never even looked at that operator before. Thanks for sharing that with us.
                          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


                          • #14
                            Jason, it looks great. All rounding and values are correct for ES, NQ, and equity symbols. Thank you very much for the help.

                            David, way to go on that "very cool" from the EFS master.

                            Comment

                            Working...
                            X