How To Plot A Bar?
Yaser Rahmati | یاسر رحمتی
Last updated
Yaser Rahmati | یاسر رحمتی
Last updated
The script plots a single bar on the chart based on the open, high, low, and close prices of the current bar.
The color of the bar depends on whether the closing price is greater than the opening price:
If close > open
, the bar color will be green.
If close <= open
, the bar color will be red.
This line specifies that the script is written in Pine Script version 5.
This line defines a new indicator named "Plot Bar". When this script is applied to a chart, this name will be shown in the list of applied indicators.
barColor
: This variable determines the color of the bar to be plotted based on the condition (close > open)
.
if (close > open)
: This is a conditional statement that checks if the closing price (close
) is greater than the opening price (open
).
color.green
and color.red
: These are predefined colors in Pine Script. If the condition (close > open)
is true, barColor
is set to green; otherwise, it's set to red.
plotbar(open, high, low, close, title="BAR", color=barColor)
: The plotbar
function is used to plot a bar on the chart.
open
, high
, low
, close
: These are built-in variables in Pine Script that represent the opening, highest, lowest, and closing prices of the current bar respectively.
title="BAR"
: This specifies the title of the plot on the chart.
color=barColor
: This specifies the color of the bar, which is determined by the barColor
variable.
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
, یاسر رحمتی