TrendDetectionChannel: Current Trend Detection using Donchian Channel

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/TrendDetectionChannel.R

Description

Uses the Donchian Channel of n periods to determine whether a price series is in uptrend, sideward trend or downtrend

Usage

1
TrendDetectionChannel(TS, n=20, DCSector=1/3)

Arguments

TS

xts Time Series containing OHLC prices

n

number of periods to calculate the high and low band of the Donchian Channel

DCSector

sector of Donchian Channel to determine uptrend / downtrend

Details

This function assumes that a price series is in uptrend when a period's price closes above the upper third of the Donchian Channel of n periods. If the price close below the lower third of the channel, a downtrend is detected. If the price closes within the middle third of the channel, a sideward trend is detected. The parameter DCSector can be used to widen/narrow the threshold of up/downtrend detection. E.g. a value of .25 anticipates the price for a uptrend to be above the highest quarter of the donchian channel

Value

A xts object containing the columns:

UpTrend

TRUE if uptrend detected

NoTrend

TRUE if sideward trend detected

DownTrend

TRUE if downtrend detected

Trend

+1 for uptrend, 0 for sideward trend, -1 for downtrend

Author(s)

Andreas Voellenklee

See Also

TrendDetectionSMA

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
  getSymbols("YHOO", adjust=TRUE)
  
  # create chart of YAHOO
  chartSeries(YHOO, subset="last 1 year", TA=NULL)
  
  # visualize the result of trend detection in a indicator box
  addTA(TrendDetectionChannel(YHOO)[,4])
  
  # filter YHOO for Hammer Candlestick Patterns that occur in downtrends
  Hammer <- CSPHammer(TS) & TrendDetectionChannel(TS)[,"DownTrend"]
  
  # how frequent are these hammers?
  colSums(Hammer, na.rm=TRUE)

## End(Not run)

candlesticks documentation built on Feb. 2, 2020, 3:01 a.m.