This ProBuilder script is designed to draw a series of horizontal lines on a price chart, spaced at regular intervals. This can be useful for visualizing significant price levels, often referred to as ’round numbers’ or psychological levels in trading.
defparam drawonlastbaronly=true
start = 10000 //start price
step = 100 //price step
quantity = 20 //lines quantity
i = start
while i < start + (step * quantity) do
drawhline(i)
i = i + step
wend
return
Explanation of the Code:
- defparam drawonlastbaronly=true: This line ensures that the drawing of horizontal lines is limited to the last bar on the chart, which helps in reducing clutter and improving performance.
- start = 10000: Sets the starting price level at which the first horizontal line will be drawn.
- step = 100: Defines the price interval between consecutive horizontal lines. In this case, each line will be 100 units apart.
- quantity = 20: Specifies the total number of horizontal lines to draw.
- while loop: This loop starts at the 'start' price and continues to add horizontal lines at each 'step' interval until it has added 'quantity' number of lines. The loop uses the variable i to keep track of the current price level at which a line is drawn.
- drawhline(i): This function draws a horizontal line at the price level specified by i.
- i = i + step: Increments the value of i by the 'step' amount to prepare for the next line drawing in the subsequent iteration.
- The wend keyword marks the end of the while loop.
This script is particularly useful for traders and analysts who want to highlight key price levels that might act as support or resistance in the market.