DRAWCANDLE is a function in the ProBuilder language used to draw custom OHLC (Open, High, Low, Close) candlestick charts. This function allows users to visually represent trading data, which can be customized using specific values for open, high, low, and close. Optional color settings for the candlestick body and border can also be specified.
DRAWCANDLE(open, high, low, close) COLOURED(R, G, B) BORDERCOLOR(R, G, B)
Below is an example of how to use the DRAWCANDLE function to create a simple Heiken Ashi candlestick, which is a type of candlestick chart used to average price movements for better trend identification:
period = 20
if barindex > period then
avgO = average[period](open)
avgH = average[period](high)
avgL = average[period](low)
avgC = average[period](close)
HAClose = (avgO + avgH + avgL + avgC) / 4
HAOpen = (HAOpen[1] + HAClose[1]) / 2
HAHigh = MAX(avgH, MAX(HAOpen, HAClose))
HALow = MIN(avgL, MIN(HAOpen, HAClose))
if avgO <= avgC then
DRAWCANDLE(HAOpen, HAHigh, HALow, HAClose) COLOURED(0, 255, 0)
else
DRAWCANDLE(HAOpen, HAHigh, HALow, HAClose) COLOURED(255, 0, 0)
endif
endif
This script calculates the average open, high, low, and close over a specified period and uses these averages to plot Heiken Ashi candlesticks. Green candles are used when the average opening price is less than or equal to the average closing price, and red candles are used otherwise.