ATRP

Modified on 2008/04/13 15:06 by Administrator — Categorized as: Standard Indicators

Syntax

public ATRP(WealthLab.Bars bars, int period, string description)
public static ATRP Series(WealthLab.Bars bars, int period)

Parameter Description

bars The Bars object
period Indicator calculation period

Description

ATRP expresses the Average True Range, or ATR, as a percentage of the closing price of the specified Bar. ATRP provides a good picture of current volatility.

Calculation

ATRP( bar, period ) = 100 * ATR( bar period ) / PriceClose( bar )

where,
ATR = Average True Range (see indicator)

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 { /* Short when price hits the High of the previous bar * (1 + ATRP/100 ) Cover on trailing stop of the same series */ protected override void Execute() { // Convert to fractional percentage, e.g., 3.5% -> 0.035 DataSeries hATRP = ATRP.Series( Bars, 5 ) / 100 + 1; DataSeries hATRP_H = Bars.High * hATRP;

// Delay indicator plot by 1 bar to observe crossovers PlotSeries( PricePane, hATRP_H>>1, Color.Blue, LineStyle.Dotted, 2 ); DrawLabel( PricePane, "ATRP_H + 2%" ); PlotStops(); for(int bar = 15; bar < Bars.Count; bar++) { if (IsLastPositionActive) CoverAtTrailingStop( bar+1, LastPosition, hATRP_H[bar] ); else ShortAtLimit( bar+1, hATRP_H[bar] ); } } } }