To reference the highest and lowest prices of the preceding day in Pine Script v5, you can use the security()
function with the highest()
and lowest()
functions.
Here is an example code:
//@version=5
indicator("Yesterday's High/Low", overlay=true)
yesterday_high = security(syminfo.tickerid, "D", highest(high))
yesterday_low = security(syminfo.tickerid, "D", lowest(low))
plot(yesterday_high, color=color.green)
plot(yesterday_low, color=color.red)
In this code, we use the security()
function to fetch the highest and lowest prices of the preceding day. The syminfo.tickerid
argument specifies the symbol and the "D"
argument specifies the timeframe (daily). The highest(high)
and lowest(low)
functions are used to find the highest and lowest prices.
We then plot the highest and lowest prices using the plot()
function, with the color
argument set to green for the highest price and red for the lowest price.
Note that this code only works for daily charts. If you want to reference the highest and lowest prices of the preceding week or month, you need to change the timeframe argument accordingly (e.g. "W"
for weekly, "M"
for monthly).
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-07-18 15:21:14 +0000
Seen: 10 times
Last updated: Jul 18 '23
How can I deal with Expression.Error related to a column in Power Query?
How can you implement pagination in Oracle for the LISTAGG() function?
What is the process for implementing a FutureBuilder on an OnTap function in Flutter?
How can we require users to be logged in before they can access the root folders in WordPress?
In SCSS, what is the method for grouping and reusing a set of classes and styles?
How can popen() be used to direct streaming data to TAR?
How does iOS retrieve information from a BLE device?
How can Django Admin accommodate a variety of formats and locales for its input fields?