This ProBuilder code snippet is designed to draw a rectangle on a chart, marking the range between the highest and lowest prices of the day at a specific time. The rectangle is drawn at the end of the trading period defined by the user.
StartEndHour = 163000
maxvalue = max(maxvalue , high)
minvalue = min(minvalue , low)
if time = StartEndHour then
DRAWRECTANGLE(x1,maxvalue,barindex,minvalue) coloured(0,0,0,0)
x1=barindex
maxvalue=0
minvalue=Dclose(0)*5
endif
RETURN
Explanation of the Code:
- Variable Initialization: The variable StartEndHour is set to 163000, representing the time (16:30:00) in HHMMSS format. This is the specific time at which the rectangle will be drawn.
- Tracking High and Low Values: The maxvalue and minvalue variables are updated continuously with the highest and lowest price values respectively using the max and min functions.
- Condition Check: The if statement checks if the current time matches StartEndHour. If true, several actions are performed:
- Drawing the Rectangle: The DRAWRECTANGLE function is called with parameters to specify the corners of the rectangle based on the bar index and the max/min values. The rectangle is colored transparently with RGBA values (0,0,0,0).
- Resetting Variables: The x1 variable is set to the current bar index, and maxvalue and minvalue are reset. minvalue is set to five times the closing price of the current bar, preparing the variables for the next trading day.
- End of Code: The RETURN statement marks the end of the code execution for this script.
This snippet is useful for visualizing the price range at a specific closing time, which can be adjusted by changing the StartEndHour variable to match any desired time point.