Draw lines and areas. Label lines

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #254599 quote
    theunpredictable
    Participant
    New
    // =======================================
    // DAILY-WERTE
    // =======================================
    timeframe(daily)
    
    // Tages-Eröffnung
    dailyOpen = Open
    
    // Linien-Level
    up65    = dailyOpen + 65
    up75    = dailyOpen + 75
    up115   = dailyOpen + 115
    up125   = dailyOpen + 125
    up160   = dailyOpen + 160
    
    
    down65  = dailyOpen - 65
    down75  = dailyopen - 75
    down115 = dailyOpen - 115
    down125 = dailyOpen - 125
    down160 = dailyOpen - 160
    
    // =======================================
    // ZURÜCK ZU M15
    // =======================================
    timeframe(default)
    
    // Linien nur von 08:00 bis 13:00 anzeigen
    IF Time >= 080000 AND Time <= 130000 THEN
    
    // ===== OBERHALB DES OPENS =====
    DRAWSEGMENT(barindex, up65,  barindex + 1, up65)    COLOURED(255,0,0)style(line,2)
    DRAWSEGMENT(barindex, up75,  barindex + 1, up75)   COLOURED(255,0,0)style(dottedline,2)
    DRAWSEGMENT(barindex, up115,  barindex + 1, up115)   COLOURED(255,0,0)style(line,2)
    DRAWSEGMENT(barindex, up125, barindex + 1, up125)  COLOURED(255,0,0)style(dottedline, 2)
    DRAWSEGMENT(barindex, up160, barindex + 1, up160)  COLOURED(0,0,0)style(line,2)
    
    DRAWRECTANGLE(barindex, down65, barindex+1, down75) fillcolor(200,200,255,230) coloured(200,200,255,230)
    DRAWRECTANGLE(barindex, down115, barindex+1, down125) fillcolor(200,200,255,230) coloured(200,200,255,230)
    DRAWRECTANGLE(barindex, up65, barindex+1, up75) fillcolor(200,200,255,230) coloured(200,200,255,230)
    DRAWRECTANGLE(barindex, up115, barindex+1, up125) fillcolor(200,200,255,230) coloured(200,200,255,230)
    
    // ===== UNTERHALB DES OPENS =====
    
    DRAWSEGMENT(barindex, down65,  barindex + 1, down65)  COLOURED(0,0,255)style(line,2)
    DRAWSEGMENT(barindex, down75,  barindex + 1, down75)  COLOURED(0,0,255)style(dottedline,2)
    DRAWSEGMENT(barindex, down115, barindex + 1, down115) COLOURED(0,0,255)style(line,2)
    DRAWSEGMENT(barindex, down125, barindex + 1, down125) COLOURED(0,0,255)style(dottedline,2)
    DRAWSEGMENT(barindex, down160, barindex + 1, down160) COLOURED(0,0,0)style(line,2)
    
    ENDIF
    RETURN
    

    Hello everyone, I have been trying to build an indicator for lines and zones derived from the day’s opening price. I am able to draw lines, but I am unable to display the price value of the line on the right side of the line. I also haven’t been able to figure out how to fill in the zones cleanly. Does anyone have a simple trick for how to do this?

    Thx in advance…

    Best regards,

    Björn

    #254603 quote
    robertogozzi
    Moderator
    Master

    Use DrawText, like this example of your first line plotted:

    // ===== OBERHALB DES OPENS =====
    DRAWSEGMENT(barindex, up65,  barindex + 1, up65) COLOURED(255,0,0)style(line,2)
    IF IsLastBarUpdate THEN
       DrawText("#up65#", barindex + 3, up65, dialog, bold, 10) COLOURED(255,0,0)
    ENDIF

    more details at https://www.prorealcode.com/documentation/drawtext/.

    theunpredictable and Iván González thanked this post
    #254604 quote
    robertogozzi
    Moderator
    Master

    see the attached picture.

    theunpredictable thanked this post
    #254606 quote
    theunpredictable
    Participant
    New

    Thank you for the very fast reply.

    The line is now labeled, but each finished candle generates a new number.
    Can this number, which is determined from the opening price in the morning, be displayed only once for the entire day?

    Regards, Björn

    #254616 quote
    robertogozzi
    Moderator
    Master

    Add this line at the very beginning of your code:

    DEFPARAM DrawOnLastBarOnly = true

    but this will remove all previous segments and rectangles.

    If this is fine for you, then it’s the best solution, otherwise you will need to use two copies of the same indicator, one that draws all the segments and rectangles (it’s the one you are using now), the other one is the same, but will only plot the text at each new bar, which is this one:

    DEFPARAM DrawOnLastBarOnly = true
    // =======================================
    // DAILY-WERTE
    // =======================================
    timeframe(daily)
     
    // Tages-Eröffnung
    dailyOpen = Open
     
    // Linien-Level
    up65    = dailyOpen + 65
    up75    = dailyOpen + 75
    up115   = dailyOpen + 115
    up125   = dailyOpen + 125
    up160   = dailyOpen + 160
     
     
    down65  = dailyOpen - 65
    down75  = dailyopen - 75
    down115 = dailyOpen - 115
    down125 = dailyOpen - 125
    down160 = dailyOpen - 160
     
    // =======================================
    // ZURÜCK ZU M15
    // =======================================
    timeframe(default)
     
    // Linien nur von 08:00 bis 13:00 anzeigen
    IF Time >= 080000 AND Time <= 190000 THEN
     
    // ===== OBERHALB DES OPENS =====
    //DRAWSEGMENT(barindex, up65,  barindex + 1, up65) COLOURED(255,0,0)style(line,2)
    DrawText("#up65#", barindex + 3, up65, dialog, bold, 10) COLOURED(255,0,0)
    //DRAWSEGMENT(barindex, up75,  barindex + 1, up75)   COLOURED(255,0,0)style(dottedline,2)
    DrawText("#up75#", barindex + 3, up75, dialog, bold, 10) COLOURED(255,0,0)
    //DRAWSEGMENT(barindex, up115,  barindex + 1, up115)   COLOURED(255,0,0)style(line,2)
    DrawText("#up115#", barindex + 3, up115, dialog, bold, 10) COLOURED(255,0,0)
    //DRAWSEGMENT(barindex, up125, barindex + 1, up125)  COLOURED(255,0,0)style(dottedline, 2)
    DrawText("#up125#", barindex + 3, up125, dialog, bold, 10) COLOURED(255,0,0)
    //DRAWSEGMENT(barindex, up160, barindex + 1, up160)  COLOURED(0,0,0)style(line,2)
    DrawText("#up160#", barindex + 3, up160, dialog, bold, 10) COLOURED(255,0,0)
    
    //DRAWRECTANGLE(barindex, down65, barindex+1, down75) fillcolor(200,200,255,230) coloured(200,200,255,230)
    //DRAWRECTANGLE(barindex, down115, barindex+1, down125) fillcolor(200,200,255,230) coloured(200,200,255,230)
    //DRAWRECTANGLE(barindex, up65, barindex+1, up75) fillcolor(200,200,255,230) coloured(200,200,255,230)
    //DRAWRECTANGLE(barindex, up115, barindex+1, up125) fillcolor(200,200,255,230) coloured(200,200,255,230)
     
    // ===== UNTERHALB DES OPENS =====
     
    //DRAWSEGMENT(barindex, down65,  barindex + 1, down65)  COLOURED(0,0,255)style(line,2)
    DrawText("#down65#", barindex + 3, down65, dialog, bold, 10) COLOURED(255,0,0)
    //DRAWSEGMENT(barindex, down75,  barindex + 1, down75)  COLOURED(0,0,255)style(dottedline,2)
    DrawText("#down75#", barindex + 3, down75, dialog, bold, 10) COLOURED(255,0,0)
    //DRAWSEGMENT(barindex, down115, barindex + 1, down115) COLOURED(0,0,255)style(line,2)
    DrawText("#down115#", barindex + 3, down115, dialog, bold, 10) COLOURED(255,0,0)
    //DRAWSEGMENT(barindex, down125, barindex + 1, down125) COLOURED(0,0,255)style(dottedline,2)
    DrawText("#down125#", barindex + 3, down125, dialog, bold, 10) COLOURED(255,0,0)
    //DRAWSEGMENT(barindex, down160, barindex + 1, down160) COLOURED(0,0,0)style(line,2)
     DrawText("#down160#", barindex + 3, down160, dialog, bold, 10) COLOURED(255,0,0)
    ENDIF
    RETURN

    add both the indicators on your chart (using different names).

    theunpredictable thanked this post
    #254617 quote
    theunpredictable
    Participant
    New

    Thank you very much.
    I will take the way with two copies of the Indi.
    This will work for me.

    Best regards,
    Björn

    robertogozzi thanked this post
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Draw lines and areas. Label lines


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by theunpredictable
1 month, 3 weeks ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 12/17/2025
Status: Active
Attachments: 1 files
Logo Logo
Loading...