Standard Deviation and Z-score

Today I did a bit of work on the Panic Recovery strategies mentioned earlier. I wanted the strategy to support analysis of changes in the price by using standard deviations … so I had to do a bit of a refresher on standard deviations.

So the standard deviation is easily explained here:

http://www.mathsisfun.com/data/standard-deviation.html

But how do I know how many standard deviations a price change is away? Well, for that I need to calculate the Z-score which appears to be:

Z = (price – mean) / stdDev

Now the maths functions built into LUA allow me to calculate the standard deviation of a range pretty easily… so first I plotted the stdDev but I ended up getting unexpected results …

So I manually recalculated in Excel and this is what I found. The rows in red are the bars pointed out above.

Date MEDIAN STDDEV MEAN ZSCORE   DIFF STDDEV MEAN ZSCORE
15/02 7:00 95.81 0.20 95.98 -0.88 -0.09 0.16 -0.02 -0.40
15/02 8:00 96.18 0.19 95.98 1.06 0.60 0.22 0.01 2.75
15/02 9:00 96.44 0.21 95.99 2.07 0.01 0.21 0.02 -0.06
15/02 10:00 96.51 0.24 96.02 2.02 0.24 0.22 0.02 0.99
15/02 11:00 96.56 0.27 96.03 1.96 -0.17 0.22 0.01 -0.83
15/02 12:00 96.36 0.27 96.04 1.16 -0.17 0.22 0.01 -0.78
15/02 13:00 96.34 0.28 96.05 1.04 0.08 0.22 0.02 0.29
15/02 14:00 96.24 0.28 96.06 0.64 -0.25 0.23 0.01 -1.12
15/02 15:00 96.23 0.29 96.06 0.58 0.20 0.23 0.01 0.80
15/02 16:00 96.34 0.29 96.08 0.88 0.00 0.22 0.03 -0.11
17/02 14:00 96.38 0.29 96.12 0.93 0.06 0.21 0.04 0.08
17/02 15:00 96.39 0.28 96.15 0.86 -0.01 0.20 0.02 -0.17
17/02 16:00 96.41 0.28 96.18 0.83 0.03 0.20 0.02 0.07
17/02 17:00 96.52 0.29 96.21 1.08 0.08 0.20 0.03 0.24
17/02 18:00 96.55 0.28 96.25 1.08 0.04 0.19 0.05 -0.05
17/02 19:00 96.54 0.24 96.30 0.97 -0.05 0.19 0.05 -0.52

The standard deviation is being calculated on the price (or rather the median of the price).
So of course this value ranges (95.00 – 97.00) for example, so it calculates the standard deviation of the overall price. Yes, we could possibly use this to see how the current price compares to historical prices, so we can see when the price raised high, the standard deviation was high too (1.08).

However, I want to know if the change in the price is significant or not, therefore, I should be calculating the standard deviations on the range of bar sizes (close – open). I recalculated this in excel in the right 4 columns, and the Z-score for the new differences is much higher where expected (2.75)

Posted in Research and tagged , , , .

Leave a Reply

Your email address will not be published. Required fields are marked *