Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find Support/Resistance Levels using R

Tags:

r

quantmod

I have not found any good answers on how to go about finding Support/Resistance levels in R. Essentially I would like clusters/areas or pivots where the stock is consolidating, but have found it difficult to do so.

# loads quatmod & xts
library("quantmod")
# Retrive 'ESSI' TICKER OHLCV data
STOCK = getSymbols("ESSI",auto.assign = FALSE)
# last observation carried formward / facilitates NAs
STOCK <- reclass(apply(STOCK,2,na.locf),match.to=STOCK)

# To be used as a rolling window
K=20
# Find MAX for Each Open, High, Low, Close Column & merge them
MAX <- merge.xts(rollmax(Op(STOCK), k=K, na.pad=TRUE),rollmax(Hi(STOCK), k=K, na.pad=TRUE),rollmax(Lo(STOCK), k=K, na.pad=TRUE),rollmax(Cl(STOCK), k=K, na.pad=TRUE))
# Find the mean of each MAX row
MAX <- na.locf(reclass(apply(MAX,1,mean),match.to=MAX))

I would do the same for the Low's but I think I would be better off going about using DonchianChannel() but it is not what I want... The output should return something similar to FinViz's :

FINVIZ

like image 484
Rime Avatar asked Dec 27 '16 07:12

Rime


1 Answers

You could apply a swing filter such as TTR's ZigZag function. Identifying reversals this way seems like a better way to go than Donchian channels and you can define support / resistance as levels where the reversals tend to cluster.

like image 92
Jay Avatar answered Sep 23 '22 11:09

Jay