DRAWCANDLE

Category: Graphical

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.

Syntax:

DRAWCANDLE(open, high, low, close) COLOURED(R, G, B) BORDERCOLOR(R, G, B)
  • open, high, low, close: These parameters represent the values for the opening, highest, lowest, and closing prices of the candlestick, respectively. These can be constants, variables, or expressions.
  • COLOURED(R, G, B): Optional. Defines the fill color of the candlestick using RGB values.
  • BORDERCOLOR(R, G, B): Optional. Sets the border color of the candlestick using RGB values.

Example Usage:

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.

Additional Information:

  • The DRAWCANDLE function is particularly useful for creating custom visual representations of data in trading systems, allowing for better analysis and decision-making.
  • When the COLOURED and BORDERCOLOR parameters are not specified, the default colors of the platform are used.

Related Instructions:

  • DRAWBARCHART graphical
  • Logo Logo
    Loading...