You are on page 1of 2

Walras wannabe’s diary #01: Stochastic oscillator

Victor Dieguez Correa

Motivation and the beautiful living in it is given by

This is the first of many PDFs this diary will be composed of(I 1
hope so). Our main purpose is to track our economical studies SMAk,next = SMAk,prev + (pn+1 − pn−k+1 )
k
in a simplistic, although effective way, and to show what we
are, in fact, studying, discussing and reading. By any means, since we are now considering a sampling widht k from n−k +2
it is supposed to represent some kind of formal study. Our to n + 1. The algebra behind it is straightfoward. And, because
modus operandi is to prepare ourselves for tapa na cara, soco of it all, we may say
no estômago e chute no saco when we trade. The best way of
understading what we want mean with this humble study might 
be perfectly summarized by the own words of its[Stochastics] momentum = (N + 1) SMAtoday − SMAyesterday
creator, Professor George Lane:
That is, we can see momentum as the change in a N-day SMA.
”Stochastics measures the momentum of price. If you Well, it behaves like a derivative! That is where the magic hap-
visualize a rocket going up in the air – before it can turn pens. When momentum crosses up through zero, it is a trough
down, it must slow down. Momentum always changes in the SMA, oterwhise, when it crosses down through zero, it
direction before price.” is a peak! A good future reading is the paper Market Timing
with Moving Averages: Anatomy and Performance of Trad-
ing Rules, where the author shows us that every trading rule
All that changes are based on the differences among each clos- can be seen as a weighted average of our momenta computed
ing price pairwisely, according to the day we are looking for: using differents averaging periods.
Well, then we may see the behaviour of momentum as troughs
momentum = closetoday − close past and peaks(obviously) regarding the SMA. It would be use-
ful if we can take a different kind of mean among our num-
where close past may be any day on the past, it will be, gener- bers. Well, I am not interested in so many numbers as needed
ally, referred as N days ago and N is a natural number related for the SMA. It has a high computing cost(if we are trading
to our period of analysis, from where we will look for infor- largely) and it may carry some informations I am not wanting
mation to, with some sucess, describe the future based on the for now(for now! Every economical information is sacred in
past. A good example for us is the behaviour of Bitcoin — I its own right). Mathematically, we are looking for some kind
feel sorry for talking a lot about crypto! But this is the only re- of Mean-value theorem in some time interval [ti ,ti+n ].
source of economical information I have experience with (un-
til now, but this is about to change!) —, it is what we call an That is exactly what the stochastic oscillator is about. It
is based on support and resistance levels. A support level
against-inflation protector1 (I have forgotten the real name of is where the price[of an asset] tends to find support as it
it, but is something like: An asset whose value only increases falls(what happens due to an increase in demand for the as-
along time, although it may briefly vary, but regarding a long set). What we mean with all of that is the price is more likely
period of time, it is highly probable to bring profit) for N su- to ”bounce” of this level rather than go through it; A resistance
ficciently large. That is, you will find momentum > 0. If you level is the opposite of a support level, then we mean by the
do not like crypto, you are probably saying right now: Alright resistance it may find due to an increase in selling interest, that
buddy, we are not in Ancapistan. Beware Victor! When N is is, the price is more likely, again, to bounce off this level than
small, the Bitcoin price is a total mess with a high volatility, go through it. Well, that is, no more and no less, the supply
you will lose money, moron! You are absolutely right and it is and demand in their own habitat. After all, we will take ad-
exactly the point I want to talk about. vantage of this well-known market behaviour and try to take
Although our study is focused on the changing of momentum, another ”type of SMA” to help in our analyzis, and from it the
we do not have to look at any N and, luckily, take a good time- stochastic oscillator is born.
lapse to profit. To understand it, firstly we have to take a good
pathway. Another way to view what momentum is relating it
with the Simple Moving Average(SMA). It is a way to analyze Developing the Stochastic oscillator
data points by taking the averages of some data subsets from With all discussed, we proceed straightfoward to our two
the full data set. Briefly, it is a type of finite impulse response.
It is caclulated bu taking the unweighted mean of k previous principal formulas,
data points from a total set of n data points, then
Price − Lowest Low
1 n %K = × 100
SMAk = pi Highest Hight − Lowest Low

k i=n−k+1
and
1 Just like Gold %D = SMA3 (%K)
That is, for %K, we take a n-period stochastic oscillator, not know for how long we will remain in the overbought or
such that we will take the Lowest Low and the Highest Hight oversold area. So, if you want to buy or sell, wait for it to
among the prices covered by this period. Usually, it is fixed decrease or increase, respectvely. In such way, you will know
for the last 14 periods, meanwhile %D is always taken as a you have not lost any better position, so you have a good po-
3-day SMA. %D is also seen as a derivative of %K. tential for trading in virtually all time frame. However, SI
There is a useful question we all have to ask: Okay, we alone won’t tell you where to stop or take profit as you have
know the formula, but how we know it is reaching the top already noticed, you must be a little bit rogue to know it(or
or the bottom? Well, as many things, this is a observational using another method or relying in your own judgment). As
study, we can summarize it: everything in life, be prepared to take your loses if it is neces-
sary. The use of SI is not infallible, but using SI with another
• When we have %K higher than 75%, generally it is an in-
timing signal will achive a greater degree of accuracy while
dication that a top is imminent. We call it a overbought
limiting false signals and risk.
condition;
The strategy regarding 75/25 may seen more fruitful than
• When we have %K lower than 25%, we have the opposite, the crossover method. It can be used in any time frame as it
a bottom is imminent. It is a oversold condition. is expressed in Figure 2 and Figure 3
We must tell you all that not necessarily when one of the con-
ditions is reached, we have to take an action immediately, it is
just a single drawback of our stochastic implementation, we
mean: Just a sign to see and say ”alright, let’s see cautiously
what is happening”. We also notice that it can be used as a
stand-alone system, however, the addition of timing indica-
tors can improve overall results.
There are two types of Stochastic indicators to use in our
oscillator: The fast and slow mode. As the name tells us, the
slow one is a moving average version of the so-called fast.
It is highly recommended to use the slow Stochastic indica-
tor(SI), since it does not oscillates too widly, unlike the fast
SI.
A way to use the slow SI to trade happens when the lines
of %D and %K cross as it is seen in Figure1. If you are suf-
Figure 2: 75/25 strategy in 5-minute frame

Figure 1: Buy(B) and Sell(S) signals regarding %K and %D.

ficiently cautious — skepticism is always a good behaviour, Figure 3: 75/25 strategy in 10-minute frame
specially on yourself — on your graphical analysis hability,
you might notice that we have done neither bought, nor sold,
The code
when we have reached the top or the bottom regions of our
graphic. You can say ”But you told me only to buy or sell Ride the Tiger: High-volatility Stochastic
when the lines have crossed, and this haven’t happened when Indicator
we reached the top”, you are right, but there is another rea-
son more sofisticated and more economical behind it: we do What will come next

You might also like