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