Announcement

Collapse
No announcement yet.

drawing lines relative to the top/bottom

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • drawing lines relative to the top/bottom

    is it possible to draw lines relative to the top/bottom in pixels? for example. from (0, 100) to (-20, 200), where 100 and 200 are pixels?


    Clearpicks

  • #2
    Hello Clearpicks,

    You can use the Text.RELATIVETOTOP or Text.RELATIVETOBOTTOM flags with the drawText... functions to accomplish what you need. When these flags are present, the y parameter becomes a pixel value. There is also a Text.RELATIVETOLEFT flag which turns the x parameter into the number of bars from the left of the window.

    You might also want to try using the drawTextPixel(xBar, yValue, Text, [FGColor], [BGColor], [Flags], [FontName], [FontSize], [TagName]) function. This allows you specify a x/y location in pixels. It assumes relative to top and left of the window, but you can also use the Text.RELATIVETOBOTTOM flag.

    PHP Code:
    function main() {
        if (
    getCurrentBarIndex() != 0) return;
        
        
    drawTextPixel(0100"drawPixel"Color.whiteColor.navynullnull12"myText1");
        
    drawTextRelative(0100"drawTextRelative"Color.whiteColor.navy
            
    Text.RELATIVETOTOPnull12"myText2");
        
    drawTextRelative(-20100"drawTextRelative"Color.whiteColor.navy
            
    Text.RELATIVETOTOPnull12"myText3");
        
        return;

    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


    • #3
      Hi Jason,

      Are there corresponding flags for drawing lines relative to the top/bottom? Thanks.


      Clearpicks


      Originally posted by JasonK
      Hello Clearpicks,

      You can use the Text.RELATIVETOTOP or Text.RELATIVETOBOTTOM flags with the drawText... functions to accomplish what you need. When these flags are present, the y parameter becomes a pixel value. There is also a Text.RELATIVETOLEFT flag which turns the x parameter into the number of bars from the left of the window.

      You might also want to try using the drawTextPixel(xBar, yValue, Text, [FGColor], [BGColor], [Flags], [FontName], [FontSize], [TagName]) function. This allows you specify a x/y location in pixels. It assumes relative to top and left of the window, but you can also use the Text.RELATIVETOBOTTOM flag.

      PHP Code:
      function main() {
          if (
      getCurrentBarIndex() != 0) return;
          
          
      drawTextPixel(0100"drawPixel"Color.whiteColor.navynullnull12"myText1");
          
      drawTextRelative(0100"drawTextRelative"Color.whiteColor.navy
              
      Text.RELATIVETOTOPnull12"myText2");
          
      drawTextRelative(-20100"drawTextRelative"Color.whiteColor.navy
              
      Text.RELATIVETOTOPnull12"myText3");
          
          return;

      Comment


      • #4
        Tall lines...

        Clearpicks,

        In my ECF code, I'm doing something like this, but I resolved the problem by drawing from 0 to 99999. There is no other real solution (that I'm aware of), just force in the values that will draw the lines you want.

        B
        Brad Matheny
        eSignal Solution Provider since 2000

        Comment


        • #5
          Hello Clearpicks,

          No, the drawLine... functions do not have a flag input parameter, but that would be a good suggestion for [email protected].
          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


          • #6
            Hello Clearpicks,

            Just thought of another idea for you to try. Add this non-price study to your chart and then overlay it onto the price window. This will give you the relative affect you're looking for. In this case the 80 and 20 would represent the percentage of the window from the bottom.


            PHP Code:
            function preMain() {
                
            setStudyTitle("Fixed Lines");
                
            setShowCursorLabel(false);
                
            setStudyMax(100);
                
            setStudyMin(0);
                
                
            addBand(80PS_SOLID2Color.red"top");
                
            addBand(20PS_SOLID2Color.red"bottom");
            }

            function 
            main() {
                return;

            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


            • #7
              Thanks.

              Originally posted by JasonK
              Hello Clearpicks,

              Just thought of another idea for you to try. Add this non-price study to your chart and then overlay it onto the price window. This will give you the relative affect you're looking for. In this case the 80 and 20 would represent the percentage of the window from the bottom.


              PHP Code:
              function preMain() {
                  
              setStudyTitle("Fixed Lines");
                  
              setShowCursorLabel(false);
                  
              setStudyMax(100);
                  
              setStudyMin(0);
                  
                  
              addBand(80PS_SOLID2Color.red"top");
                  
              addBand(20PS_SOLID2Color.red"bottom");
              }

              function 
              main() {
                  return;

              Comment

              Working...
              X