How to find support / resistance levels using R

I did not find good answers to the question of how to find support / resistance levels in R. In fact, I need clusters / areas or reference points where stocks are consolidating, but it was difficult to do.

# 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 Low, but I think I'm better off using DonchianChannel() , but that is not what I want ... The result should return something similar to FinViz:

FINVIZ

+8
r quantmod
source share
1 answer

You can apply a swing filter, such as the TTR ZigZag function. Identifying U-turns in this way seems like a better way than Donchian channels, and you can define support / resistance as levels where changes tend to cluster.

+1
source share

All Articles