Announcement

Collapse
No announcement yet.

Drawing lines and text in window space

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

  • Drawing lines and text in window space

    Hi,

    Does anyone have any examples of drawing objects such as lines and text with window based parameters rather than bar relative parameters? Is this possible at all?

    Thanks,

    Rich Leung

  • #2
    Hello Rich,

    You can do this with Shapes, Images and Text, but not lines. You need to use the flags RELATIVETOLEFT and RELATIVETOBOTTOM. There is also RELATIVETOTOP. When you use these flags, the first input parameter becomes the number of bars from the left edge of the window for RELATIVETOLEFT. With RELATIVETOTOP or RELATIVETOBOTTOM, the second input parameter becomes the number of pixels from the top or bottom edge of the window.

    PHP Code:
    function preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("test");
        
    setShowCursorLabel(false);
        
    }

    var 
    bEdit true;

    function 
    main() {

        if (
    bEdit == true && getCurrentBarIndex() == 0) {
            
    drawShapeAbsolute(320Shape.CIRCLEnullColor.lime
                
    Shape.RELATIVETOLEFT|Shape.RELATIVETOBOTTOM"myShape");
            
    drawImageAbsolute(520"SystemHappyFace"null
                
    Image.RELATIVETOLEFT|Image.RELATIVETOBOTTOM"myImage");
            
    drawTextAbsolute(720"Text"Color.whiteColor.navy
                
    Text.RELATIVETOLEFT|Text.RELATIVETOBOTTOMnull12"myText");
            
    bEdit false;
        }
        
        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
      Fantastic, thanks Jason

      Thanks,

      Rich Leung

      Comment


      • #4
        ReltiveX-AbsoluteY

        Hi Jason,

        Is there a way to Draw a RelativeX-AbsoluteY text/Image/etc.?

        The idea is to be attached to a bar (like in Relative) but have fixed Y in chart (like in Absolute/DrawPixel).

        Note: I tried "RELATIVETOTOP/BOTTOM" flags in DrawRealtiveText and does not work.

        Thank you.
        Mihai Buta
        Mihai Buta

        Comment


        • #5
          Mihai
          Unless I misunderstood your question the following line should write TEST at relative bar index -5 and fixed Y coordinate of 100 pixels from the top of the chart.
          drawTextRelative(-5, 100, "TEST", Color.blue, null, Text.RELATIVETOTOP|Text.BOLD, "Arial", 11, "test");
          Alex

          Comment


          • #6
            It should and it does, except when you are dumb enough to name one of your vars "Text" [or any other reserved name].

            Thank you Alex,
            Mihai
            Mihai Buta

            Comment

            Working...
            X