PriceOscillator (Function)

image\trumpet2.gif Disclaimer

The PriceOscillator series function calculates the difference between the Slow Moving Average and the Fast Moving Average.

Syntax

PriceOscillator(Price, FastLength, SlowLength)

Returns (Double)

The difference between the Fast Moving Average and the Slow Moving Average.

Parameters

Name

Type

Description

Price

Numeric

Specifies which bar value (price, function, or formula) to consider.

FastLength

Numeric

Sets the number of bars over which the fast average will be calculated.

SlowLength

Numeric

Sets the number of bars over which the slow average will be calculated.

Example

Assigns to Value1 the difference between the 9 bar moving average and the 18 bar moving average, both based on the Close:

Value1 = PriceOscillator(Close, 9, 18);

Assigns to Value2 the difference between the 3 bar moving average and the 5 bar moving average, both based on the Close:

Value2 = PriceOscillator(Close, 3, 5);

Additional Example

If you wanted an Alert when the PriceOscillator, based on 10 and 20 bar moving averages, crosses above zero, indicating that the fast average has crossed above the slow average, you could use the following syntax:

If PriceOscillator(Close, 10, 20) Crosses Above 0 Then
 Alert("The Price Oscillator has crosses above zero");