Indicator Reference

Percentage Price Oscillator

Introduction

This indicator computes the Percentage Price Oscillator (PPO) The Percentage Price Oscillator is calculated using the following formula: PPO[i] = 100 * (FastMA[i] - SlowMA[i]) / SlowMA[i]

Create Manual Indicators

You can manually create a PercentagePriceOscillator indicator, so it doesn’t automatically update. Manual indicators let you update their values with any data you choose. The following reference table describes the PercentagePriceOscillator constructor.

PercentagePriceOscillator()1/2

            PercentagePriceOscillator QuantConnect.Indicators.PercentagePriceOscillator (
     string              name,
     int                 slowPeriod,
     *MovingAverageType  movingAverageType
   )
        

Initializes a new instance of the PercentagePriceOscillator class using the specified name and parameters.

PercentagePriceOscillator()2/2

            PercentagePriceOscillator QuantConnect.Indicators.PercentagePriceOscillator (
     int                 slowPeriod,
     *MovingAverageType  movingAverageType
   )
        

Initializes a new instance of the PercentagePriceOscillator class using the specified parameters.

The following table shows the MovingAverageType enumeration members and the indicator that implements each one:

MovingAverageTypeUnderlying Indicator
SimpleSimple Moving Average
ExponentialExponential Moving Average
WildersWilder Moving Average
LinearWeightedMovingAverageLinear Weighted Moving Average
DoubleExponentialDouble Exponential Moving Average
TripleExponentialTriple Exponential Moving Average
TriangularTriangular Moving Average
T3T3 Moving Average
KamaKaufman Adaptive Moving Average
HullHull Moving Average
AlmaArnaud Legoux Moving Average

Update Manual Indicators

You can update the indicator automatically or manually.

Automatic Update

To register a manual indicator for automatic updates with the security data, call the RegisterIndicator method.


private PercentagePriceOscillator _ppo;

// In Initialize()
_ppo = new PercentagePriceOscillator(name, fastPeriod, slowPeriod);
_ppo.Updated += IndicatorUpdateMethod;

RegisterIndicator(symbol, _ppo, Resolution.Daily);

// In IndicatorUpdateMethod()
if (_ppo.IsReady)
{
    var indicatorValue = _ppo.Current.Value;
}
    
# In Initialize()
self.ppo = PercentagePriceOscillator(name, fastPeriod, slowPeriod)
self.ppo.Updated += self.IndicatorUpdateMethod

self.RegisterIndicator(symbol, self.ppo, Resolution.Daily)

# In IndicatorUpdateMethod()
if self.ppo.IsReady:
    indicator_value = self.ppo.Current.Value

To customize the data that automatically updates the indicator, see Custom Indicator Periods and Custom Indicator Values.

Manual Update

Updating your indicator manually enables you to control when the indicator is updated and what data you use to update it. To manually update the indicator, call the Update method with time/decimal pair. The indicator will only be ready after you prime it with enough data.

    
private PercentagePriceOscillator _ppo;
private Symbol symbol;

// In Initialize()
_ppo = new PercentagePriceOscillator(fastPeriod, slowPeriod);
symbol = AddEquity("SPY").Symbol;

// In OnData()
if (data.ContainsKey(_symbol))
{
    _ppo.Update(data[symbol].EndTime, data[symbol].High);
}
if (_ppo.IsReady)
{
    var indicatorValue = _ppo.Current.Value;
}
    
# In Initialize()
self.ppo = PercentagePriceOscillator(fastPeriod, slowPeriod)
self.symbol = self.AddEquity("SPY").Symbol

# In OnData()
if data.ContainsKey(self.symbol):
    self.ppo.Update(data[self.symbol].EndTime, data[self.symbol].High)
if self.ppo.IsReady:
    indicator_value = self.ppo.Current.Value

Create Automatic Indicators

The PPO method creates an PercentagePriceOscillator indicator, sets up a consolidator to update the indicator, and then returns the indicator so you can use it in your algorithm.

The following reference table describes the PPO method:

PPO()1/1

            PercentagePriceOscillator QuantConnect.Algorithm.QCAlgorithm.PPO (
    Symbol                           symbol,
    Int32                            fastPeriod,
    Int32                            slowPeriod,
    MovingAverageType                movingAverageType,
    *Nullable<Resolution>      resolution,
    *Func<IBaseData, Decimal>  selector
   )
        

Creates a new PercentagePriceOscillator indicator.


The following table shows the MovingAverageType enumeration members and the indicator that implements each one:

MovingAverageTypeUnderlying Indicator
SimpleSimple Moving Average
ExponentialExponential Moving Average
WildersWilder Moving Average
LinearWeightedMovingAverageLinear Weighted Moving Average
DoubleExponentialDouble Exponential Moving Average
TripleExponentialTriple Exponential Moving Average
TriangularTriangular Moving Average
T3T3 Moving Average
KamaKaufman Adaptive Moving Average
HullHull Moving Average
AlmaArnaud Legoux Moving Average

If you don't provide a resolution, it defauls to the security resolution. If you provide a resolution, it must be greater than or equal to the resolution of the security. For instance, if you subscribe to hourly data for a security, you should update its indicator with data that spans 1 hour or longer.

For more information about the selector argument, see Alternative Price Fields.

Get Indicator Values

To get the value of the indicator, use its Current.Value attribute.

private PercentagePriceOscillator _ppo;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_ppo = PPO(symbol, fastPeriod, slowPeriod, movingAverageType);

// In OnData()
if (_ppo.IsReady)
{
    var fast = _ppo.Fast.Current.Value;
    var slow = _ppo.Slow.Current.Value;
    var signal = _ppo.Signal.Current.Value;
    var histogram = _ppo.Histogram.Current.Value;
    var current = _ppo.Current.Value;
}
# In Initialize()
symbol = self.AddEquity("SPY").Symbol
self.ppo = self.PPO(symbol, fastPeriod, slowPeriod, movingAverageType)

# In OnData()
if self.ppo.IsReady:
    fast = self.ppo.Fast.Current.Value
    slow = self.ppo.Slow.Current.Value
    signal = self.ppo.Signal.Current.Value
    histogram = self.ppo.Histogram.Current.Value
    current = self.ppo.Current.Value

Visualization

To plot indicator values, in the OnData event handler, call the Plot method.

private PercentagePriceOscillator _ppo;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_ppo = PPO(symbol, fastPeriod, slowPeriod, movingAverageType);

// In OnData()
if (_ppo.IsReady)
{
    Plot("My Indicators", "fast", _ppo.Fast);
    Plot("My Indicators", "slow", _ppo.Slow);
    Plot("My Indicators", "signal", _ppo.Signal);
    Plot("My Indicators", "histogram", _ppo.Histogram);
    Plot("My Indicators", "percentagepriceoscillator", _ppo.Current);
}
# In Initialize()
symbol = self.AddEquity("SPY").Symbol
self.ppo = self.PPO(symbol, fastPeriod, slowPeriod, movingAverageType)

# In OnData()
if self.ppo.IsReady:
    self.Plot("My Indicators", "fast", self.ppo.Fast)
    self.Plot("My Indicators", "slow", self.ppo.Slow)
    self.Plot("My Indicators", "signal", self.ppo.Signal)
    self.Plot("My Indicators", "histogram", self.ppo.Histogram)
    self.Plot("My Indicators", "percentagepriceoscillator", self.ppo.Current)

For more information about plotting indicators, see Plotting Indicators.

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: