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
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
- True Range is a way to express a daily range without ignoring gaps that can occur between the previous close and the open.
- The True Range is not intended to be used as an indicator.
- The True Range is useful if used as a Price Series Parameter for another indicator as in the EMA volatility example show below.
- Especially useful in volatility indicators, where the high and low prices may not include the full volatility of price action.
- Can be incorporated in entry or exit triggers.
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 = ( tr[bar] > atr[bar] ) || ( tr[bar-1] > atr[bar-1] );
if( WideRange == true )
SetSeriesBarColor( bar, tr, Color.Red );
}
}
}
}