colorbetween only for a certain time

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #254664 quote
    theunpredictable
    Participant
    New

    Hi, does anyone have any idea how I can use the “colorbetween” command to highlight a specific time period?

    I’ve already tried using time >080000 and time <130000, but prorealcode continues to draw up to the current candle.

    I was able to fill the area with drawrectangle and it worked, but I can’t see any wicks or fuses in the colored area.

    Thanks in advance.

    Best regards,
    Björn

     

    // 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)
    //
    
    colorbetween(down65, down75,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
    
    #254672 quote
    robertogozzi
    Moderator
    Master

    I can’t see any reason why it should plot segments outside your time range. I tested it from 110000 to 140000 and it only plots in that narrower range.

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

    I moved your post from the German forum.

    #254676 quote
    theunpredictable
    Participant
    New

    The drawing ends after the specified time with the rectangles. When I use the colorbetween command, it draws up to the current candle, even beyond the defined time.

    #254696 quote
    robertogozzi
    Moderator
    Master

    You are right, there’s no way to work it out.

    You can only ask the assistance or make a suggestion to PRT.

    #254700 quote
    JC_Bywan
    Moderator
    Master

    Hi,

    take your colorbetween instruction out of the if-endif bloc, and use a variable transparency instead inside the if-endif, called alpha for example, equal to your 230 when in your time range, and equal to zero outside of it:

    IF Time >= 080000 AND Time <= 130000 THEN
      alpha=230
    ELSE
      alpha=0
    ENDIF
    
    colorbetween(down65, down75, 200,200,255, alpha)
    #254701 quote
    theunpredictable
    Participant
    New

    That works well 🙂

    Thanks a lot.

    #254717 quote
    theunpredictable
    Participant
    New

    Hi, do you have any idea how to align the colored zone between the lines with the lines?

    The lines are drawn with this command. Can I also align the fill with bar index +1?

    DRAWSEGMENT(barindex, up65, barindex + 1, up65) COLOURED(255,0,0)style(line,2)

    That is the term for filling in color.

    IF Time >= 083000 AND Time <= 131500 THEN
    alpha=230
    ELSE
    alpha=0
    ENDIF

    colorbetween(down65, down75, 200,200,255, alpha)

     

    Thanks in advance,

    Björn

    #254733 quote
    JC_Bywan
    Moderator
    Master

    Hi,

    although you can’t use colorbetween on barindex+1, assuming you can use drawonlastbaronly without messing up other graphic objects in your code needing to remain drawn permanently, you could try to add a rectangle of same color between barindex and barindex+1 being refreshed thanks to drawonlastbaronly. to reduce visual effects of borders, you coud force it to draw a transparent border.

    Line to add at beginning of code:

    defparam drawonlastbaronly = true

    And line to add after colorbetween line:

    drawrectangle(barindex, down65, barindex+1, down75) fillcolor(200,200,255,alpha) coloured(200,200,255,0)

    To be tested to see if it’s an acceptable workaround.

    Iván González thanked this post
Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.

colorbetween only for a certain time


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

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

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