Announcement

Collapse
No announcement yet.

drawTextRelative() question

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

  • drawTextRelative() question

    Hi all,

    Is there a way to have two different texts drawn on the same bar? I have two drawTextRelative() statements in different parts of the program. They have different TagID's but if they both happen to fire on the same bar, only the last statement called shows up.

    thanks in advance.

  • #2
    rw580
    That is done by using TagIDs that are unique to each text object. If you are seeing only one text object drawn that could suggest that either the TagID you are applying is common to both the drawTextRelative() calls used in the script or that you may be drawing both text objects in the same location
    Post the script or a working example that illustrates the issue you are seeing and someone will be able to help you
    Alex

    Comment


    • #3
      Thanks for your reply

      If you run the attached file, it should count every third bar and number it above the bar, and count every fifth bar and number it below the bar. If I understand correctly, I have different TagID's, and it is not drawing in the same place. But, on my end at least, it only draws the red number below the bar on bars that are multiples of 15, where both should show up.

      I hope this makes sense. If you would like a picture, please explain how to do it and I will

      Thanks again

      Randy
      Attached Files

      Comment


      • #4
        Randy
        That is happening because on the bars that are multiples of 15 the two counters ie num and num1 have the same value hence because the TagID is the same only one text will be drawn on that bar specifically the one drawn by the last of the drawTextRelative() calls.
        Change the TagID inside each drawTextRelative() function to [for example] "a"+num and "b"+num1 and you will see both text objects drawn on those bars (see enclosed screenshot)
        Alex


        Comment


        • #5
          Thank you very much Alex

          I had no doubt that I was missing something, but for the life of me I couldn't figure out what.

          Randy

          Comment


          • #6
            Randy
            You are most welcome.
            FWIW unless you have a specific need for maintaining separate counters you could slightly simplify your script by replacing the following lines of code
            PHP Code:
            cnt++;
            cnt1++;
            num++;
            num1++; 
            with the following
            PHP Code:
            var myCounter getCurrentBarCount(); 
            Then in the rest of the script replace each instance of num, num1, cnt and cnt1 with myCounter. The values drawn on the chart will be the same as those generated by the various counters.
            Alex

            Comment

            Working...
            X