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:
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.
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)