Log in to see Cloud of Tags

Wealth-Lab Wiki

TrendStrengthB

RSS

TrendStrengthA Indicator Documentation

Syntax

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

Parameter Description

dsData series
periodStartBeginning SMA period
periodEndEnding SMA period
stepStep of SMAs

Description

TrendStrengthB Indicator 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. It works similar to the TrendStrengthA Indicator but takes the difference of the current price to the SMAs into account. The idea behind: The farer away prices are from their SMAs the strengther is the trend of the price series. So, the indicator calculates the average %-difference from the price to the SMAs and can have these values:

> 0 Price (on average) is above analyzed SMAs
== 0Price (on average) matches the SMA values
< 0Price (on average) is below analyzed SMAs

A value of 1 indicates that (on average) the price is 1% above all analyzed SMAs. Usually, values above 2 (below -2) indicate an 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.

Example

This simple stop-and-reverse system example illustrates the idea of going long when values above 0.6, indicating a strong uptrend, and reversing when values are below -0.6 (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("TrendStrengthB Period Start",30,2,300,20); slider2 = CreateParameter("TrendStrengthB Period End",110,2,300,20); slider3 = CreateParameter("TrendStrengthB Step 3",20,2,300,20); } protected override void Execute() { TrendStrengthB tsb = TrendStrengthB.Series(Close,slider1.ValueInt,slider2.ValueInt,slider3.ValueInt); ChartPane paneTrendStrengthB = CreatePane(40,true,true); PlotSeriesOscillator(paneTrendStrengthB,tsb, 60, -60, Color.Green, Color.Red, Color.CadetBlue,LineStyle.Solid,1); //Let's consider values above 0.6 (below -0.6) indicating 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, tsb, 0.6); bool xu = CrossUnder(bar, tsb, -0.6); // 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 ); } } } } } }

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.