Trough

Modified on 2008/05/03 16:07 by Administrator — Categorized as: Standard Indicators

Syntax

public static Trough Series(DataSeries source, double reversalAmount, WealthLab.Indicators.PeakTroughMode mode)
public static double Value(int bar, DataSeries source, double reversalAmount, WealthLab.Indicators.PeakTroughMode mode)

Parameter Description

source The source DataSeries
reversalAmount How much of a percentage/point (see mode) decline is required to trigger a new Trough
mode PeakTroughMode enum: (PeakTroughMode.Value, PeakTroughMode.Percent)

Description

Returns the value of the last Trough that was identified for the specified Price Series as of the specified Bar. The Reversal parameter determines how much of a percentage (default) or point advance is required to trigger a new Trough. It typically requires a few bars of upward price movement to reach the Reversal level and qualify a new Trough. The Trough function never "looks ahead" in time, but always returns the Trough value as it would have been determined as of the specified Bar. For this reason, the return value of the Trough function will lag, and report troughs a few bars later than they actually occurred in hindsight. This is intentional, and allows peak/trough detection to be used when back-testing trading systems.

Interpretation

See Peak

Remarks


Calculation

Troughs are detected by looking for a percentage (default) or point reversal in the Price Series greater than or equal to the reversal amount specified in the Reversal parameter. For example, if you specify a reversal value of 10, and prices make a new low of $20, a trough will be triggered at that bar as soon as prices move up to $22 (provided they do not continue below $20). The move up to $22 may take several bars. During these bars the Trough function will not return $20, but will instead return the value of the previous trough. This is because you would not have known that that $20 was an actual trough yet because the Reversal level has not been met. The new Trough value of $20 will be returned only after prices have reached the $22 level, and the reversal level is reached.

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() { // Draw the level of 7% Troughs on the chart PlotSeries( PricePane, Trough.Series( Low, 7, PeakTroughMode.Percent ), Color.Green, LineStyle.Dots, 3 ); } } }