CloseD (Series Function)
The CloseD function allows you to reference the daily Close of previous days in an intraday chart (minute
CloseD is a function in a family of functions that allows historical daily, weekly, monthly, and yearly references in intraday charts.
Syntax
CloseD(PeriodsAgo)
Returns (Double)
A numeric value for the current bar. If there is not enough data, the function will return –1.
Parameters
Name |
Type |
Description |
PeriodsAgo |
Numeric |
The number of days/periods back to reference a previous day’s closing price. (0 = Today’s current Close) |
Remarks
You must have enough intraday data in the chart in order to look back and reference any previous close. For example, if you want to look back at the close of 25 days ago on a 5-minute chart, you must have 25 days of 5-minute bars in the chart.
The value for the PeriodsAgo input parameter should always be a whole number greater than or equal to 0. Setting PeriodsAgo to 0 equals today’s current Close.
This function considers the transition between one day and the next to occur at midnight, when the date changes. If you're using a symbol that trades overnight and would prefer to use the end of a session to transition to a new "day," consider using the CloseSession function.
If you're calling this function in a study that will be applied to RadarScreen, be sure to set the "Load additional bars" setting. This setting should be set so as to ensure that it exceeds the number of intra-day bars in the PeriodsAgo. For example, if your code looks back 5 days (that is, PeriodsAgo is set to 5), then at least 6 days of intra-day bars should be loaded using the "Load additional bars" setting. On hourly bars for a symbol that trades 24 hours a day, this would be approximately 144 bars (6 x 24). For more detail on the "Load additional bars" setting, see Customize Study Properties.
Example
Assigns the Close of the previous day on an intraday chart to Value1, then plots Value1:
Value1 = CloseD(1);
Plot1(Value1, "PrevClose");