17 votes

Calculating Bollinger Band Correctly

In Pandas 0.19.2++: ...
12 votes

Theoretical justification for technical analysis

The answer to your question about the theoretical justification for technical analysis depends on the price series being analyzed. There is some evidence for a few technical indicators to have ...
  • 2,810
11 votes

Calculating Bollinger Band Correctly

...
  • 191
10 votes
Accepted

Half life of Exponetial Weighted Moving Average

The Exponentially Weighted Moving Average (EWMA for short) is characterized my the size of the lookback window $N$ and the decay parameter $\lambda$. The corresponding volatility forecast is then ...
  • 1,386
9 votes

Calculating Bollinger Band Correctly

I believe that the answers given here are incorrect as they return the sample standard deviation while the the population measure is the correct calculation for Bollinger Bands. The bands usign the ...
  • 91
9 votes

What is the difference between squared returns and variance?

Usually the formula for the sample variance of a stock is given by: \begin{equation} Var(R_{i}) = E (R_t - E(R_t))^2 \end{equation} If you are using daily data to compute the variance then the ...
  • 7,293
7 votes

Theoretical justification for technical analysis

Really great question. Having studied finance academically, in an academic setting, you will always be told that technical analysis is non-sense. In the world of pure academics, the efficient market ...
  • 5,513
6 votes

Is there a non-recursive way of calculating the exponential moving average?

The point of the recursive formula is that you can easily calculate the current EWMA if you have last period's EWMA. Equivalently, you can calculate all the weights directly and sum them that way. $$ ...
  • 741
5 votes
Accepted

Is there a non-recursive way of calculating the exponential moving average?

I've been waiting for someone to ask this question since every published method with which I am familiar propose weights which converge to $1$ only when the numbers of terms goes to infininity. This ...
5 votes

Unsmoothing of returns

Did you try solving for $w_k$? $$\bar{r}_t = \sum_{k=0}^p w_k r_{t-k}$$ $$\bar R = W R$$ Since you probably have $t>>k$, you can solve for $W$ using OLS $$\bar R = W R +\varepsilon$$ -- ...
5 votes
Accepted

Why the diff of signal is called positions and what does it mean in backtesting?

My understanding, in that context, is that signal indicates that you want to hold a share (signal is 1) or hold no shares (signal is zero). Therefore taking the diff will tell you if you want to buy (...
  • 4,267
5 votes

Theoretical justification for technical analysis

The theoretical justification for technical analysis (TA) is less about market (in)efficiency; and more about prices as a signal of sentiment and positioning biases, that are neither always neutral ...
  • 4,971
4 votes
Accepted

Unsmoothing of returns

Thanks @Aksakal for suggesting Kalman Filter. Here I provide more details. We will view it as a state-space model: $$ \begin{split} z_t &= A_t z_{t-1} + B_t u_t + \epsilon_t, \\ y_t &= C_t ...
  • 273
4 votes
Accepted

How to get the the final % return in backtesting?

Note: Assuming you're a bit of a beginner trying to learn the ropes of how this whole process works at a high level, I can definitely make a couple recommendations (if I'm interpreting that wrong then ...
4 votes

Workflow in algorithmic strategies

"What are more appropriate way to test it with real-world data? Also, can you suggest the next steps to make it more realistic?" Pick a tradable instrument (e.g. SPY rather than S&P500), ...
  • 2,161
3 votes
Accepted

Derivation (or proof) of commonly used formula showing relationship between time and smoothing factor in exponential smoothing

The current data point is said to have age 0, the previous has age 1, and so on going backwards. For a straight N period moving average of the form $\frac{1}{N}(x_t+x_{t-1}+\cdots+x_{t-N+1})$ it is ...
  • 9,212
3 votes
Accepted

Where to get historical equity data?

Recently I came across interesting platform. https://www.quantopian.com/ they offer exactly what you need and for free. Basically, you code your algo in python, they provide data using api and ...
3 votes
Accepted

Technical Indicators reference

The TA_lib Technical Analysis library here has open source code for numerous indicators.
3 votes
Accepted

What is the difference between a moving average crossover and a moving average of returns?

Moving averages of prices are closely related to moving averages of price differences. In particular, if the price is a cumulative sum of historical price differences, $$ p_t = \sum_{j=0} \delta p_{t-...
  • 5,718
3 votes
Accepted

Pricing an Asian style forward contract with early exercise feature

Welcome to Quant SE. Unfortunately there is no closed form formula for computing the american contract value $\max_{\tau}E^P\left[e^{-r\tau}(A_{\tau} - K)\right]$, so you have to resort to an american ...
3 votes

Detect trend of an index

Questions: 1=> Does anyone have a suggestion to determine a trend correctly. My answer is in general and an opinion. Hong Kong Stock Exchange is third largest market behind Tokyo and Shanghai and ...
  • 460
3 votes
Accepted

Exponential Moving Average Data Set Average Age

Bridging the gap between equation 2 and 3: Let us use the fact that the infinite series $\sum_{k=0}^\infty k \cdot \beta^k$ has a closed-form solution given by (see this post for proof): $$\sum_{k=0}^\...
  • 4,108
2 votes
Accepted

Online algorithm for selecting smoothing parameter?

First of all, I do not believe the "optimal smoothing" of an estimator (like the mean or the variance) and the "regression case" are the same. The smoothing of an existing estimator (like mean or ...
  • 11k
2 votes

Technical Indicators reference

The Technical Analysis of Financial markets is considered as a milestone of the matter. I suggest to read that before starting to test your strategy. It explains well the use of each indicator, ...
  • 2,456
2 votes

Technical Indicators reference

A very good reference can be found here: http://www.asiapacfinance.com/trading-strategies/technicalindicators
  • 27.2k
2 votes

How to optimize return in a moving average crossover algorithm

It is unlikely that you could beat the market in the long-term with such a simple strategy. But, since you ask about optimization (not real trading), all you have to do to is run the optimization ...
  • 271
2 votes

Where to get historical equity data?

I have used https://www.tickdata.com/ and https://www.quantgo.com/ I enjoy the simplistic nature of obtaining data that they use, so for someone new to quantitative finance like you, I recommend that ...
2 votes

Where to get historical equity data?

If you are by any chance familiar with R take a look at the following post LINK It offers an easy way to obtain data from Yahoo finance, Google etc. Cheers. PS: Jameson, I am in a similar situation ...
  • 21
2 votes
Accepted

Simple Moving Average Backtest: Cumulative Return too high

The moving average is determined as of the close of a particular day. Then to calculate the P&L you have to multiply today's state (1 or -1) by TOMORROWs return, instead you are using todays! So ...
  • 9,212
2 votes

What is an Efficient way to calculate Simple moving average without saving previous N period values?

This is impossible. You need to remember the tail. I'd suggest using exponential smoothing in this case. Otherwise, for a simple moving average you'd have to apply some kind of an approximation. ...

Only top scored, non community-wiki answers of a minimum length are eligible