Modified on 2008/04/10 23:23 by Administrator — Categorized as: TASCIndicators


public TrendLinePeaks(DataSeries ds, double reversepct, bool uselogscale, string description)
public static TrendLinePeaks Series(DataSeries ds, double reversepct, bool uselogscale)

Parameter Description

ds Source Series
reversepct The reversal percentage used to determine peaks and troughs
uselogscale Pass true to project trendlines on a semi-log scale, otherwise false


TrendLinePeaks and TrendLineTroughs were not published in TASC Magazine. These indicators facilitate creating a trendline strategy by calculating the projection of the trend line resulting from the two most recent peaks determined by reversepct (the reversal percentage). Pass true to the boolean parameter uselogscale to project trendlines on a semi-log scale.


/* Catch breakouts over a descending trendline */

using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using TASCIndicators;

namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { bool useLog = true; DataSeries tP = TrendLinePeaks.Series(High, 10, useLog); PlotSeries(PricePane, tP, Color.Red, LineStyle.Dashed, 1); PlotStops(); for (int bar = tP.FirstValidValue; bar < Bars.Count; bar++) { if( IsLastPositionActive ) { Position p = LastPosition; if( Close[bar] < p.EntryPrice * 0.95 ) SellAtMarket(bar + 1, p, "Stop Loss"); else // Keep 80% of the profit after achieving a 25% target SellAtAutoTrailingStop(bar + 1, p, 25.0, 20.0); } else { if( tP[bar] < tP[bar-1] ) // descending trendline if( CrossOver(bar, Close, tP) ) BuyAtMarket( bar + 1 ); } } } } }