Percentage Price Oscillator (PPO)

Modified on 2010/09/12 12:50 by Eugene — Categorized as: Community Indicators

Percentage Price Oscillator: Indicator Documentation

Syntax

DataSeries PPO( DataSeries ds, int Period1, int Period2 )

Parameter Description

dsData series
Period1The shorter-term moving average period
Period2The longer-term moving average period

Description

According to the Investopedia's definition, Percentage Price Oscillator (PPO) is a technical momentum indicator showing the relationship between two moving averages. To calculate the PPO, subtract the 26-day exponential moving average (EMA) from the nine-day EMA, and then divide this difference by the 26-day EMA.

It allows to rank and compare stocks more easily than does its counterpart, the MACD. Since PPO expresses the difference as a percentage, you will know that a "5" reading of PPO means the shorter moving average is 5% above the longer.

Note! Version 2010.10 of Community Indicators contains a breaking change: replaced Bars parameter with DataSeries.

Example

This example illustrates a trading system based on Percentage Price Oscillator (PPO):

Note: the code is based on the new syntax and requires Community Indicators 2010.10.


using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using Community.Indicators;

namespace WealthLab.Strategies { public class PPO_demo: WealthScript { private StrategyParameter Period1; private StrategyParameter Period2; public PPO_demo() { Period1 = CreateParameter("Period1", 9, 9, 30, 1); Period2 = CreateParameter("Period2", 26, 20, 50, 1); } protected override void Execute() { PPO ppo = PPO.Series( Close, Period1.ValueInt, Period2.ValueInt ); for (int bar = ppo.FirstValidValue; bar < Bars.Count; bar++) { if (IsLastPositionActive) { if ( ppo[bar] < 0 ) SellAtMarket( bar+1, LastPosition ); } else { if ( ppo[bar] > 0 ) BuyAtMarket( bar+1 ); } } ChartPane ppoPane = CreatePane( 20, true, true ); PlotSeries( ppoPane, ppo, Color.DarkRed, LineStyle.Histogram, 2 ); } } }