OHLCPeriodsAgo (Function)
The OHLCPeriodsAgo series function returns the Open, High, Low, and Close of a specified time segment, a specified number of periods ago.
Syntax
OHLCPeriodsAgo(PeriodType, PeriodsAgo, oPeriodOpen, oPeriodHigh, oPeriodLow, oPeriodClose)
Returns (Integer)
The oPeriodOpen, oPeriodHigh, oPeriodLow, and oPeriodCLose output parameters returns the Open, High, Low, and Close from a time segment. The OHLCPeriodsAgo function itself returns 1 if the specified time segment was available, and -1 if not.
Parameters
Name |
Type |
Description |
PeriodType |
Numeric |
Sets the time period on which to base values (1=Day, 2=Week, 3=Month, 4=Year) |
PeriodsAgo |
Numeric |
Sets the number of PeriodType periods ago |
oPeriodOpen |
Numeric |
Outputs the open of the specified time segment |
oPeriodHigh |
Numeric |
Outputs the high of the specified time segment |
oPeriodLow |
Numeric |
Outputs the low of the specified time segment |
oPeriodClose |
Numeric |
Outputs the close of the specified time segment |
Remarks
See Multiple Output Function for more information on using output parameters to return values.
Example
Assigns to Value2 through Value5 the Open, High, Low, and Close of the last 20 weeks. Value1 is assigned a value of 1.
vars: oPeriodOpen(0), oPeriodHigh(0), oPeriodLow(0), oPeriodClose(0);
Value1 = OHLCPeriodsAgo(2, 20, oPeriodOpen, oPeriodHigh, oPeriodLow, oPeriodClose);
Value2 = oPeriodOpen;
Value3 = oPeriodHigh;
Value4 = oPeriodLow;
Value5 = oPeriodClose;