TrueRange

Modified on 2008/05/03 16:14 by Administrator — Categorized as: Standard Indicators

Syntax

public static WealthLab.Indicators.TrueRange Series(WealthLab.Bars bars) public TrueRange(WealthLab.Bars bars, string description) public static double Value(int bar, WealthLab.Bars bars)

Parameter Description

bars The Bars object

Description

True Range is apart of the Welles Wilder indicator collection. It is the actual range, high to low, of a bar. It includes any gap, between today's High or Low and yesterday's Close. As it can use the previous day in its calculation, the first periods true range may be undefined. The True Range is the maximum price movement over a period. True Range is the basis of the Average True Range indicator, ATR.

Interpretation


Calculation

True Range is always a positive number and is defined by Welles Wilder to be the greatest of the following for each period:

The distance from today's high to today's low.
The distance from yesterday's close to today's high.
The distance from yesterday's close to today's low.


Example

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() { // Compare ATR with TrueRange and highlight volatile bars DataSeries atr = ATR.Series( Bars, 14 ); DataSeries tr = TrueRange.Series( Bars ); bool WideRange = false; ChartPane ATRPane = CreatePane( 40, true, true ); PlotSeries( ATRPane, atr, Color.Red, WealthLab.LineStyle.Solid, 1 ); PlotSeries( ATRPane, tr, Color.Black, WealthLab.LineStyle.Histogram, 2 ); DrawLabel( ATRPane, "14 bar ATR and current bar True Range" ); DrawLabel( ATRPane, "Red bars indicator True Range greater than ATR" ); // Note the instability feature of ATR, hence the loop should start at least 3 time the period for(int bar = 45; bar < Bars.Count; bar++) { WideRange = ( trbar > atrbar ) || ( trbar-1 > atrbar-1 ); if( WideRange == true ) SetSeriesBarColor( bar, tr, Color.Red ); } } } }