DrawRectangle OPen till Close

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #216313 quote
    eckertheckerth
    Participant
    New

    HI

    am looking for help on regards the DRAWRECTANGLE function

    Would like to paint a rectangle between two prices. e.g. 1 and 2.

    and the width of the rectangle should be from OPEN to CLose (or 5 bars into the future)

    Somehow I cant get this managed with Barindex and co,

    Can someone help me ?

    #216315 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    A rectangle is plotted according to two coordinates:

    • price (from price 1 to price 2)
    • bars (from bar 1 to bar 2), which can also be in the future, if you like.

    The line width is specified by a numeric constant, not a price:

    DEFPARAM DrawOnLastBarOnly = True
    ONCE Price1 = 0
    ONCE Price2 = 0
    ONCE Bar1   = 0
    ONCE Bar2   = 0
    IF (Time >= 090000) AND (Time <= 210000) THEN
       IF Time = 090000 THEN
          Price1 = open
          Bar1   = BarIndex
       ENDIF
       Price2 = close
       Bar2   = BarIndex
    ENDIF
    IF Price1 <> 0 THEN
       DrawRectangle(Bar1,Price1,Bar2,Price2) coloured("Grey",25) BorderColor("Fuchsia",255) style(Line,3)
    ENDIF
    RETURN
    eckerth thanked this post
    #220897 quote
    eckertheckerth
    Participant
    New

    Thanks.. i solved it like this

    defparam DRAWONLASTBARONLY = true

    mintimeFrame = 9

    if GetTimeFrame/60 >= minTimeFrame then

    maxCheck = 50
    i = 0
    lastOuterBar = -1

    lastLow = low[maxcheck]
    lastHigh = high[maxcheck]

    for i = maxCheck-1 downto 0
    if open[i] >= lastHigh or open[i] =< lastLow or close[i] >= lastHigh or close[i] =< lastLow then
    lastLow = low[i]
    lastHigh = high[i]
    lastOuterBar = i
    endif
    next

    if lastOuterBar > 0 then

    x1 = barindex
    y1 = high[lastOuterBar] //high[barindex+1]
    x2 = barindex-lastOuterBar
    y2 = low[lastOuterBar]//low[barindex+1]
    DRAWRECTANGLE(x1, y1, x2,y2) coloured(255,155,0)FILLCOLOR(255,255,230)
    endif
    endif

    RETURN

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

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

DrawRectangle OPen till Close


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
eckerth @eckerth Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by eckertheckerth
3 years ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 06/15/2023
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...