# Derivative Oscillator

### Syntax

```
DataSeries DerivativeOscillator (DataSeries ds, int periodRSI, int periodEMA1, int periodEMA2, int periodSMA)
```

### Parameter Description

 ds A DataSeries to apply Derivative Oscillator to periodRSI Period of the RSI periodEMA1 Period for the EMA to that smooths the RSI periodEMA2 Shorter period EMA to smooth the EMA of RSI periodSMA Period for the SMA that smooths the double-smoothed RSI

### Description

The Derivative Oscillator created by Constance Brown is a triple smoothed RSI that incorporates two EMAs and one SMA. It was specifically developed to:
1. resolve problems associated with complex market corrections where data becomes choppy and congested.
2. reentering when there is a very strong trend.

### Calculation

The oscillator uses a 14-period RSI. The RSI is then double smoothed with exponential moving averages. The default settings for the smoothing periods are 5 and 3. In a second step a signal line is generated from the smoothed RSI by calculating a simple moving average with a period of 9. The Derivative Oscillator is calculated as the difference between the smoothed RSI and the signal line and displayed as histogram.

### Example

```
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 DerivativeOscDemo : WealthScript
{
private StrategyParameter paramPeriodRSI;
private StrategyParameter paramPeriod1;
private StrategyParameter paramPeriod2;
private StrategyParameter paramPeriod3;

public DerivativeOscDemo()
{
paramPeriodRSI = CreateParameter("RSI Period", 14, 2, 30, 1);
paramPeriod1 = CreateParameter("EMA Period 1", 5, 2, 20, 1);
paramPeriod2 = CreateParameter("EMA Period 2", 3, 2, 10, 1);
paramPeriod3 = CreateParameter("SMA Period", 9, 2, 20, 1);
}

protected override void Execute()
{
int perRSI = paramPeriodRSI.ValueInt;
int perEMA1 = paramPeriod1.ValueInt;
int perEMA2 = paramPeriod2.ValueInt;
int perSMA = paramPeriod3.ValueInt;

DerivativeOscillator derivOsc = DerivativeOscillator.Series( Close,perRSI,perEMA1,perEMA2,perSMA );			for(int bar = GetTradingLoopStartBar(derivOsc.FirstValidValue * 3); bar < Bars.Count; bar++)
{
if (IsLastPositionActive)
{
if( CrossUnder( bar, derivOsc, 0 ) )
SellAtMarket( bar+1, LastPosition );
}
else
{
if( CrossOver( bar, derivOsc, 0 ) )