How To Plot OHLC Values?
FXC911 – Forex & Crypto News & Insights
Goals
The script plots four lines on the chart:
The open price in blue.
The high price in green.
The low price in red.
The close price in white.
Pine Script Code
//@version=5
indicator("Plot OHLC")
plot(open, color=color.blue)
plot(high, color=color.green)
plot(low, color=color.red)
plot(close, color=color.white)
Code Output

Explanation
1. Version Declaration:
//@version=5
This line specifies that the script is written in Pine Script version 5.
2. Indicator Declaration:
indicator("Plot OHLC")
This line defines a new indicator named "Plot OHLC". When this script is applied to a chart, this name will be shown in the list of applied indicators.
3. Plotting Open Value:
plot(open, color=color.blue)
plot(open, color=color.blue)
: Theplot
function is used to draw a plot on the chart.open
: This is a built-in variable in Pine Script that represents the opening price of the current bar.color=color.blue
: This specifies that the plot of the open price will be colored blue.
4. Plotting High Value:
plot(high, color=color.green)
plot(high, color=color.green)
: Theplot
function is used to draw a plot on the chart.high
: This is a built-in variable in Pine Script that represents the highest price of the current bar.color=color.green
: This specifies that the plot of the high price will be colored green.
5. Plotting Low Value:
plot(low, color=color.red)
plot(low, color=color.red)
: Theplot
function is used to draw a plot on the chart.low
: This is a built-in variable in Pine Script that represents the lowest price of the current bar.color=color.red
: This specifies that the plot of the low price will be colored red.
6. Plotting Close Value:
plot(close, color=color.white)
plot(close, color=color.white)
: Theplot
function is used to draw a plot on the chart.close
: This is a built-in variable in Pine Script that represents the closing price of the current bar.color=color.white
: This specifies that the plot of the close price will be colored white.
Keywords
pine script
, trading view
, script editor
, indicators
, strategies
, backtesting
, alerts
, custom scripts
, stock analysis
, charting tools
, technical analysis
, built-in functions
, pine script syntax
, trading bots
, automated trading
, scripting language
, market data
, trading signals
, financial markets
, programming trading strategies
Visit me on:
🚀 Finance & Trading Insights: fxc911.ir
🐦 Twitter: x.com/fxc911_official/
Last updated