Syntax
public ROC(DataSeries source, int period, string description)
public static ROC Series(WealthLab.DataSeries source, int period)
public static double Value(int bar, DataSeries source, int period)
Parameter Description
source |
The source DataSeries |
period |
Indicator calculation period |
Description
The Rate of Change (ROC) indicator provides the percentage that the security's price has changed over the specified
period. The Rate of Change shows the speed at which price changes from one period to another. Compare to
Momentum. It gives a excellent indication of the market participants' commitment to the current trend. When the ROC begins to reverse or turn, it indicates diminishing commitment and a loss of momentum. ROC is a leading or coincidental indicator.
Like other momentum indicators, ROC has overbought and oversold zones. These zones are defined by lines that are placed so that ROC spends about 5% of its time within the zones. The lines should be adjusted according to market conditions.
Interpretation
- In ranging markets, go long after ROC falls below the oversold line then rises back above it.
- In ranging markets, go short after ROC rises above the overbought line the falls back below it.
- In ranging markets, go long on bullish divergences if ROC's first trough is in the oversold zone.
- In ranging markets, go short on bearish divergences if ROC's first peak is in the overbought zone.
- In an up trend confirmed by a trend-following indicator, go long when ROC turns up from below the center line. Exit using the trend following indicator. Divergences of ROC and price during a trend can be misleading.
- In a down trend, confirmed by a trend-following indicator, go short when the ROC turns down from above the center line. Exit using the trend following indicator. Divergences of ROC and price during trend can be misleading.
Calculation
ROC is the percentage change between the current price with respect to an earlier price. Typically, the closing Price Series (
Bars.Close) is used.
ROC
bar = 100 * ( ( Price
bar / Price
bar - period ) - 1 ),
where bar is the current Bar. For example, if the current price is 77 and the previous price were 70, ROC = 100 * (( 77 / 70 ) - 1 ) = 10.0, which is the percentage change from 70.
Example
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
namespace WealthLab.Strategies
{
public class MyStrategy : WealthScript
{
protected override void Execute()
{
/*
This system is based on a smoothed Rate of Change.
Entry occurs when smoothed ROC rises above zero.
The long Position is closed when the smoothed ROC turns down.
*/
DataSeries roc = ROC.Series( Close, 40 );
DataSeries SMARoc = SMA.Series( roc, 14 );
ChartPane ROCPane = CreatePane( 35, true, true );
PlotSeries( ROCPane, roc, Color.DarkBlue, WealthLab.LineStyle.Histogram, 3 );
PlotSeries( ROCPane, SMARoc, Color.Black, WealthLab.LineStyle.Dotted, 2 );
for(int bar = 54; bar < Bars.Count; bar++)
{
if (IsLastPositionActive)
{
if( TurnDown( bar, SMARoc ) )
SellAtMarket( bar+1, LastPosition );
}
else
{
if( CrossOver( bar, SMARoc, 0 ) )
BuyAtMarket( bar+1 );
}
}
}
}
}