Modified on 2008/04/13 15:25 by Administrator — Categorized as: Standard Indicators


public static PeakBar Series(DataSeries source, double reversalAmount, PeakTroughMode mode)
public static double Value(int bar, DataSeries source, double reversalAmount, PeakTroughMode mode)

Parameter Description

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


Returns the bar number at which the last Peak that was identified for the specified Price Series as of the specified Bar. The Reversal parameter determines how much of a percentage (default) decline is required to trigger a new Peak. It typically requires a few bars of downward price movement to reach the Reversal level and qualify a new Peak. The Peak function never "looks ahead" in time, but always returns the Peak value as it would have been determined as of the specified bar. For this reason, the return value of the Peak function will lag, and report peaks 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.




See Peak


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 a trendline from the 2 most recent 10% Peaks bool Detected2Peaks = false; int bar = Bars.Count-1; int p2 = -1; int p1 = (int)PeakBar.Value( bar, Close, 10, PeakTroughMode.Percent ); if( p1 > -1 ) { p2 = (int)PeakBar.Value( p1, Close, 10, PeakTroughMode.Percent ); if( p2 > -1 ) { DrawLine( PricePane, p1, Close[p1], p2, Close[p2], Color.Red, WealthLab.LineStyle.Solid, 1 ); Detected2Peaks = true; } } if( !Detected2Peaks ) DrawText( PricePane, "2 peaks not detected. Try another symbol or load more data.", 0, 5, Color.Red ); } } }