Hi Everyone:

I am trying to find the z-score for the difference between 2 MAs. Can you help?

Hi Everyone:

I am trying to find the z-score for the difference between 2 MAs. Can you help?

Hi Dan,

Easiest way is to use the Z-Score function in scripting on an Oscillator. The simple oscillator tool is the difference between two MAs.

One thing to note, the ZScore works by calculating the average and standard deviation over a look back period and then for each point measuring the number of standard deviations away from the average.

Script would be:

o1=OSC(BARS1=50, BARS2=200); ZSCORE(o1)

If that is not doing what you need, let us know.

All the best

Mathew

Hi Mathew,

I allow me to link into this discussion about the z-score test.

I have seen and read something about the z-score test to verify the significance of a test. SentimenTrader (https://www.sentimentrader.com) works a lot with z-score testing.

Can you give me some more information about z-score testing e.g. internet links etc.?

The z-score tells us how many standard deviations a value is from its mean. A z-score of -1.95 and 1.95 means that there is a statistical significance since it corresponds with a standard deviation of -2 to 2. A standard deviation between -2 and 2 means that 95% of the values are in this area.

In your script above what does the value of the z-score mean in relation to the two moving averages? Lets say e.g. the z-score is 1.37 in the above script using the S&P 500 data. What does that mean in plain English explained?

Thanks a lot.

Thomas

Hi Thomas,

ZScores are simply multiples of standard deviations.

- We calculate an average over a lookback period (say 20 bars)
- We look at all the points that led to that average and from them we calculate the variance σ² (squared average distance from the average value) and then the standard deviation is σ.
- The ZScore value is distance from the final bar's close to the average value divided by σ. It is the distance measured in units of standard deviations.
- Then we move to the next bar and repeat the process.

Where this get confusing is that in Hypothesis Testing (which we use in the MonteCarlo section of the Back Tester in Optuma) we use “significance” to compare our test result against thousands of random variations of our test. This all comes down to the primary premise of TA - that our analysis is giving us results which are better than random. If my test is more than 1.95σ away from the average, then I can argue that it is statistically significant and not the result of luck.

Look at Lecture 1 on this page (you do not need to buy the course to see the preview) I explain this more in that video.

https://learn.optuma.com/course/quant/ Note that I am waiting to finish that course for when I have our new generation of testers in place.

It is the mixing up of these ideas which led to the problems with VaR (value at risk). Analysts were calculating the average moves in a security and from that, the standard deviation. The issue came that they believed that a price move of more than 2σ was so rare that they built in risk models which did not allow for bigger moves (ie. their capital reserves did not need to be bigger). In their models they completely understated the probability and magnitude of “black swan” events and some argue that it is what made 2008 so bad. Essentially they took the theory of hypothesis testing significance and applied it to daily moves in the market.

There are other complications such as 2 tailed v’s single tailed tests.

Hope that helps

Mathew

Hello Mathew - I’ve been working with the back tester and looking at how best to interpret the monte carlo analysis results. You mention a video link in this thread (https://learn.optuma.com/course/quant/) that is not longer available - is there an alternate video I can review?

Many thanks

Andrew

Hi Andrew,

That was not updated for the new education site. Try this URL - you still need to login with your Optuma username and password but after that you should be able to access the first lesson as a preview.

https://learn.optuma.com/courses/advanced-quantitative-testing/

All the best

Mathew