Prior day Close price?
Author: jheffez
Creation Date: 8/2/2018 10:15 AM
profile picture

jheffez

#1
Is there an easy way to get the (previous) end of day close price (without having to loop)?
profile picture

Eugene

#2
I'm sure you're not talking about something as simple as Close[bar - 1] and the WealthScript Programming Guide > DataSeries > Accessing a Single Value from a DataSeries > How to: Access a value at a specific bar. There must be some catch that you don't tell about like intraday bar scale, right? So to get the previous end of day close price in a one-liner, check this out:

Intraday | Building blocks of Intraday trading strategies > Identify the Open price of the day when working with intraday data
profile picture

Cone

#3
A one liner to get yesterday's closing value from an intraday chart... assuming within the bar loop:

CODE:
Please log in to see this code.


Note!
The intraday chart's close (last trade before 1600) can differ from the official settled close in a Daily chart, a trade which often occurs after 1600. So in the case that you need to use the official daily closing price, you need to access the data from the daily symbol.

Example:
Assume you have an intraday 5-minute DataSet called "N100_5" and a daily DataSet called "N100" with the same symbols. Here's how you'd get the official close in the intraday chart:

CODE:
Please log in to see this code.
profile picture

hmg2020

#4
Similar to this question,...How can I get the value for the price close from 1 year ago?
profile picture

Eugene

#5
You can subtract one year from the current bar's date with .AddYears(-1) and then convert it to existing bar using DateTimeToBar.

Load enough bars to highlight 11/29/2018 (as of today):
CODE:
Please log in to see this code.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).