Portfolio Design

Advanced concepts in stock investment portfolio design.  Fundamentals, technical analysis and many other related topics are discussed.

Working With Time Periods and Offsets

Portfolio123 price and technical analysis functions generally require one or two input parameters that are dependent on the series unit-time-period (daily, weekly, monthly. etc.)

This tutorial provides an overview of these inputs, determination and verification of the series time-base, and number of bars to approximate standard time frames for use in technical indicator and price functions. 

Stock market analysis fueled by Portfolio123.


Function Input Parameters

  • Offset (BarsAgo) - The Offset or BarsAgo parameter refers to the bar number (series offset) in the past that the function operates on. For example, Close(5[,series]) refers to the closing price of [series] five bars ago.
  • Period (Bars, NoBars) - The Period, also referred to as Bars or NoBars depending on the application, defines the number of bars in the past that the function operates on. 

Each bar is a single unit time period, and will be one of the following: one trading day, one week, one month, three months, or one year. The question is, "Which one?" The answer to that question depends on what series has been chosen for the function.

Technical Indicators

Before going any further, have a look at a couple of example technical functions. Start with the reference guide from the Portfolio123 help menu.

Accessing the reference documentationfrom the Portfolio123 Help pull-down

Navigate to the TECHNICAL - INDICATORS & PRICE displayed on the left side of the screen. Expand the folder labelled MOVING AVERAGE and click on Simple Moving Average.

Simple Moving Average (SMA) Input parameters

As shown above, the Simple Moving Average (SMA) has three input parameters: bars, offset, and series.  The first parameter "bars", specifies how many time periods the averaging function will perform the calculation on.  The second parameter "offset" specifies how many bars back in time. The third parameter "series" specifies the time series that the SMA will perform the average on.  The series could be a stock price/volume series, an index, an economic or banking indicator, or a custom series designed by the user. The series parameter determines whether the bars or unit-time periods are in days, weeks, months, quarters, or years. Likewise, the offset into the series is in days, weeks, months, quarters, or years, the same time scale as for bars.

Illustration of SMA(50,1) operating on a time series 

Another example is the Bollinger Band Lower (BBLower) function. It has four input parameters, three of which are of interest for this tutorial. Deviations can be ignored for the purpose of this tutorial. "Period" has the same meaning as "bars" in the previous example. Same for "offset" and "series". 

Bollinger Band Lower function and input parameters

It is typical for technical analysis functions to have these three or at least two of the three parameters.  If there is no series input allowed for the function, then the function only operates on a stock or ETF time series and the time period will always be daily.

Determining the Series Unit-Time Period (Bar)

General Guidelines

  • Stock/ETF price series: one bar = one trading day
  • Index starting with $: one bar = one trading day
  • Series starting with # or ##: 1 bar = 1 trading day, 1 week, 1 month, one quarter, one year
  • Custom Series: Depends on rebalance frequency

Time Series Examples

The unit time period can be determined by going to the Portfolio123 reference and selecting the specific time series of interest. Two examples are provided below, the Bank Prime Loan Rate (monthly) and Home Vacancy Rate (yearly).

Bank Prime Loan Rate (##PRIME) time series

Home Vacancy Rate (##HVACANCY) time series

Custom Series Example

From the Portfolio123 TOOLS pull-down menu, select custom series.

Selecting Custom Series from TOOLS pull-down menu

On the left-hand side of the screen, expand the P123 Series: Samples and select MySPEPSCNY as shown below.

Observing the Rebalance Frequency for the custom series MySPEPSCNY

The Rebalance Frequency is Weekly, thus the unit-time period is one week.

Verifying the Unit Time Period

When it is unclear what the time-base is for the series, or you have reason to distrust your interpretation, you can verify the unit time period using Multi-Charts. Select Charts / Multi from the Portfolio123 Data pull-down menu.

Selecting CHARTS / Multi from the DATA pull-down menu

Select the desired series, confirm that the ID code (series label) is the one you are planning on using in a function, and then examine the resolution of the plot.  Two examples are provided below: the Bank Prime Loan Rate, and Home Vacancy Rate.


Economic Indicator Bank Prime Loan Rate Selection in Multi-Charts

Verify the Time Series ID (##PRIME)

Examine the resolution of the ##PRIME Series


Economic Indicator Home Vacancy Rate Selection in Multi-Charts

Verify the Time Series ID (##HVACANCY)

Examine the resolution of the ##HVACANCY Series


Approximate Period Lengths

  • one month = 21 bars (trading days)
  • one quarter = 63 trading days or 13 weeks
  • six months = 126 trading days or 26 weeks
  • one year = 252 trading days, 52 weeks, or 13 quasi-months (4 weeks)