# Z-Score calculation for a win-loss streak

I am trying to find the correlation between wins and losses by applying Z-Score according to formula attached below. I put them in an array by assigning 1 to wins and -1s to losers. I am trying to determine if winners follow winners or losers follow losers. What I wanna ask is before applying Z-Score into this should I remove non-streaks from this array? (When I include non-streaks I find Z-Score -125 which is not a logical number)

my array=[1,1,-1,1,-1,1,1,1,1,1,-1,1,-1,1...]

The formula of the z-score is

Z=(N*(R-0.5)-P)/((P*(P-N))/(N-1))^(1/2)

N - total number of trades in a series
R - total number of series of profitable and losing trades
P = 2*W*L;
W - total number of profitable trades in the series;
L - total number of losing trades in the series.


## 1 Answer

Your source is not particularly clear about why what they're doing is a Z-score. To give some background, what they're doing is calculating $$\frac{R-\mu_{R}}{\sigma_{R}}$$ where R is the number of runs and the mean and standard deviation are of the number of runs. It's really more of a test statistic than a Z-score per se. The denominator in their formula is actually the same standard deviation as is used in the Wald-Wolfowitz runs test but divided by $N$ (which cancels out from the mean). While I get a slightly different result if I calculate the Z-score solely using the Wald-Wolfowitz values for the mean of runs, it is conceptually the same thing.

So back to your question, you're asking if you should remove the streaks from your array before calculating the value. I would emphasize that you should not. The point of the runs test is to test the number of runs. If you remove everything that is not a run, then your test statistic is no longer valid. If you are not getting sensible numbers, there could be an issue with the calculation somewhere. I was getting perfectly sensible numbers when I was testing this.

The benefit of the original approach is that it is very easy to calculate. There are some other options that might be a little more sophisticated and could provide some interesting information. For instance, you could fit a Hidden Markov Model (HMM) that tries to estimate the probability of a win given whether the previous period was a win or not.

• I think I have some misunderstanding about counting runs. A run is a change from 1 to -1 or -1 to 1. I counted the whole array according to this logic and Z-Score is normal now. Thanks for the answer. Also I found the Z-Score as 1.49 . Do not think this is a good number to change an existing strategy. If it was above 1.96 I could think of changing it.
– Lyrk
May 21 '15 at 8:50
• @Lyrk Glad you figured it out.
– John
May 21 '15 at 13:49