Announcement

Collapse
No announcement yet.

Drawing Volume

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

  • Drawing Volume

    I been trying to draw Today's Volume on Bottom of the chart, but it seems like code that I've done seem to repeat multiple time on the bottom of the screen. How would I have just one and on Dead center , bottom of the chart? Second, how would I do it if I want to draw on bottom of X-Axis, where Time and Days are.

    Thanks,

    Billy

    Here is my code: Please direct me to right direction. Thanks.

    function preMain() {
    setPriceStudy(true);
    setComputeOnClose();
    }

    // initialization flag
    var bInit = false;

    // global variables for series objects
    var xVolume = null;


    function main(myAlerts) {

    if (bInit == false) { // initialization routine occurs only once.
    xVolume = volume(inv("D"));
    bInit = true;
    }

    var tVolume = xVolume.getValue(0);

    //Drawing
    drawText(tVolume , BottomRow1, Color.blue, Text.BOLD);
    }

  • #2
    Billy
    The reason the text is repeated multiple times is because you are not using a tagID parameter in the drawText() command (see the description ar the linked article). Try replacing it with the following
    drawText(tVolume , BottomRow1, Color.blue, Text.BOLD,"Text");
    Once you do that the command will assign the same "Text" tagID for each graphic object thereby leaving only the last one on the chart as there cannot be multiple graphic objects with the same tagID
    You cannot draw graphic objects on the x-Axis (ie where the date and time is displayed)
    Alex

    Comment


    • #3
      Changing Setting

      Thank you Alex for all the questions you helped me answer.

      I have another question. How would you make the text bottom, center of the chart with different font size and font type? It seems to me it's stuck on very right side of the chart, it doesn't look that pretty and it blocks out most current bars. Is there different function I need to call inorder to do accomplish that?

      Thanks,

      Billy
      Last edited by buzybill; 07-14-2007, 12:16 PM.

      Comment


      • #4
        Billy

        It seem do me it's stuck in very right side of the chart.
        The drawText() function does not use a bar index parameter and draws only on the bar on which the function is called. In the case of your script that would be the most recent bar which is why it appears to the right side of the chart. If however you scroll the chart to the left you should see the text move in conjunction with the last bar (to which it is anchored).

        Is there different function I need to call inorder to do accomplish that?
        You need to use drawTextRelative()
        Alex

        Comment


        • #5
          Unsuccessful Attemts

          Dear Alex,

          Thanks for all your help. I give many thanks to you.

          As usual, I am stuck again. I been trying to use drawTextRelative with no success.

          drawTextRelative( -30, BottomRow2, tVolume+"%", Color.blue, null, Text.CENTER | Text.BOLD | Text.FRAME, "Arial", 10);

          I'm trying to draw 30 bars from right bottom, with color blue, centered, bold, & framed. tVolume is a variable. What am I doing wrong here?

          Thanks,

          Billy
          Last edited by buzybill; 08-07-2007, 06:08 AM.

          Comment


          • #6
            Billy
            You are missing the Text.PRESET flag which is required when using the location flags AboveBar1, BelowBar1, BottomRow1, etc
            For information on the syntax required by the drawTextRelative() function please refer to the linked article I indicated in my prior reply
            Alex

            Comment

            Working...
            X