Has the S&P 500 Cleared the Earlier Sell?

October 25, 2015
By

[This article was first published on Quintuitive » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Life has been busy and has kept me away from blogging, and from trading, mostly. Still, I can’t stay away from monitoring the markets, and, with the recent rally, I started asking myself – has the situation changed since the 200 day SMA signaled an exit. What do you think – make up your mind before reading further.

Making up once mind before looking at the technical is a valuable approach to analyze one’s emotions in a rational way. To tune the gut feeling in other words.

Now back to the S&P 500. The answer to the question is – it depends. Let’s rerun the R script:

require(quantmod)

# Download data
spy = getSymbols("SPY",from="1900-01-01",auto.assign=F)

# Confirm the SMA situation first
spy.sma = runMean(Cl(spy), 200)
mm = merge(Cl(spy), spy.sma, all=F)
ind = mm[,1] >= mm[,2]
print(tail(ind,4))

# 2015-10-20     FALSE
# 2015-10-21     FALSE
# 2015-10-22     FALSE
# 2015-10-23      TRUE
# Yep, buy on the Friday's close

# Compute the returns
rets = ROC(Cl(spy),type="discrete")

# Compute the adjusted returns
adj.rets = rets/sqrt(runSum(rets*rets,10)/9)

# The moving average
sma = runMean(adj.rets,n=200)

ind = sma >= 0
print(tail(ind,4))

# 2015-10-20 FALSE
# 2015-10-21 FALSE
# 2015-10-22 FALSE
# 2015-10-23 FALSE
# Nope, no action based on the returns SMA

We closed above the 200 day SMA. On the other hand, the more robust, and better historically, approach, which uses normalized returns, continues maintaining a cautious position.

Make your mind and act accordingly – who said trading is easy.

Best of luck!

The post Has the S&P 500 Cleared the Earlier Sell? appeared first on Quintuitive.

To leave a comment for the author, please follow the link and comment on their blog: Quintuitive » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers

Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)