Cochran’s Formula : the number of samples
In statistics it is believed that a certain degree of significance is valid if the test is applied to a sufficiently large data set, otherwise the positive results obtained could lead to positive evaluations but which in reality are not reliable. I think it is important before creating strategies with software like SQ, it is important to define the number of samples (trade) necessary for a correct reliability of the performances and related metrics.
Some believe that to help us research the minimum number of trades, we can rely on the Cochran’s Formula:
n = (Z) ^ 2 (p) (q) / (e) ^ 2
n = minimum number of trades,
Z = Z score (variable based on Confidence level% example 95%)
p = currently known result (for example 50% win rate for the strategy)
e = margin of error (for example 5%).
On this information I have created 2 snippets on the basis that, the sample number should consider both the number of data of the IS period, and the winning percentage that the system develops.
Alternatively, even just one of these. I am attaching the codes created to be imported with CodeEditor:
1) CochranTotalDataDays.java provides a fixed number of trades based on the length of the IS period, taking into consideration a probability that the market is 50% Long and 50% Short and with a confidence level of 95% and a margin of error of 5%;
2) CochranFormula.java like the previous one but considering the probability of winning of the trading system.