Modified on 2015/06/08 07:37 by Eugene — Categorized as: Community Indicators

TrendStrengthA Indicator Documentation


public TrendStrengthA(DataSeries ds, int periodStart, int periodEnd, int step, string description)
public static TrendStrengthA Series(DataSeries ds, int periodStart, int periodEnd, int step)

Parameter Description

dsData series
periodStartBeginning SMA period
periodEndEnding SMA period
stepStep of SMAs


TrendStrengthA Indicator from the August 2005 issue of Active Trader Magazine. Created by Jose Cruset.

Looks how trendy a series is by comparing its price with various SMAs. All SMAs from PeriodStart to PeriodEnd (in steps of the Step parameter) are used for this indicator. The idea behind: The more SMAs are below (or above) the price the strengther is the trend of the price series. If some SMAs are above and some are below the price no exact trend direction can be defined. The indicator is normalized from -100 to +100, which serves as a value of how many SMAs are above or below the price:

+ 100 Price is above all SMAs, i.e. all SMAs are below the price
> 0Price is above most SMAs
0Price is above 50% and below the other 50% SMAs
< 0Price is below most SMAs
- 100Price is below all SMAs, i.e. all SMAs are above the price

Usually, values above 60 (below -60) indicate a strong up- (down-) trend whereas values in-between indicate a sideways market. The results depend on the period-range used for the SMAs. The broader the range (e.g. 20-200) the more significance does the indicator have. The longer the indicator remains at +/-100 the stronger the trend.


This simple stop-and-reverse system example illustrates the idea of going long when values above 60, indicating a strong uptrend, and reversing when values are below -60 (which indicates a strong downtrend):

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

namespace WealthLab.Strategies { public class MyStrategy : WealthScript { private StrategyParameter slider1; private StrategyParameter slider2; private StrategyParameter slider3; public MyStrategy() { slider1 = CreateParameter("TrendStrengthA Period Start",30,2,300,20); slider2 = CreateParameter("TrendStrengthA Period End",110,2,300,20); slider3 = CreateParameter("TrendStrengthA Step 3",20,2,300,20); } protected override void Execute() { TrendStrengthA tsa = TrendStrengthA.Series(Close,slider1.ValueInt,slider2.ValueInt,slider3.ValueInt); ChartPane paneTrendStrengthA1 = CreatePane(40,true,true); PlotSeriesOscillator(paneTrendStrengthA1,tsa, 60, -60, Color.Green, Color.Red, Color.CadetBlue,LineStyle.Solid,1); //Usually, values above 60 (below -60) indicate a strong up- (down-) trend whereas values in-between indicate a sideways market. for(int bar = GetTradingLoopStartBar(1); bar < Bars.Count; bar++) { // Detect crossover/crossunder and store state in a variable bool xo = CrossOver(bar, tsa, 60); bool xu = CrossUnder(bar, tsa, -60); // The first trade if (Positions.Count == 0){ if ( xo ) BuyAtMarket( bar + 1 ); else if( xu ) ShortAtMarket( bar + 1 ); } // Subsequent trades else { Position p = LastPosition; if ( p.PositionType == PositionType.Long ) { if ( xu ) { SellAtMarket( bar + 1, p ); ShortAtMarket( bar + 1 ); } } else if ( xo ) { CoverAtMarket( bar + 1, p ); BuyAtMarket( bar + 1 ); } } } } } }