Log in to see Cloud of Tags

Wealth-Lab Wiki

TrendLinePeaks

RSS

Syntax

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

Description

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.

Example

/* 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 ); } } } } }

Important Disclaimer: The information provided by Wealth-Lab is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.  The owner of Wealth-Lab.com assumes no liability resulting from the use of the material contained herein for investment purposes. By using this web site, you agree to the terms of this disclaimer and our Terms of Use.


ScrewTurn Wiki. Some of the icons created by FamFamFam.