ATR_stop: Average True Range Trailing Stop

Description Usage Arguments Details Value See Also Examples

View source: R/protective_stops.R

Description

This average true range trailing stop was developed by Sylvain Vervoort.

Usage

1
ATR_stop(x, n = 5, coef = 3.5)

Arguments

x

an xts object that contains OHLC data

n

Number of lookback periods for the ATR Stop. Default is 5

coef

ATR coefficient. Default is 3.5

Details

Based on this question on stackoverflow and this article by Sylvain Vervoort.

Value

Returns an average true range trailing stop which can be used as a stop loss in a trend following system.

See Also

Other protective stops: chandelier(), safezone()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Not run: 
# show ATR stop on chart
library(quantmod)
ADM <- getSymbols("ADM", 
                  from = "2018-01-01", 
                  to = "2018-07-01",
                  auto.assign = FALSE)
chartSeries(ADM)
addTA(ATR_stop(ADM), on = 1)

## End(Not run)

pverspeelt/Quantfunctions documentation built on Oct. 10, 2021, 1:01 p.m.