Mr Subliminal is correct about the Gaussian distribution. I put that in to try to reflect my observation that trading often results in winning or losing streaks. I don't know if the idea of a Gaussian distribution doing this is mathematically correct though. And even though math was one of my best subjects in school, it's been a long time since I've been in school.
The first line of the output had parameters used for the test (win rate, reward for a win, risk for a loss, number of trades in a run, and number of runs). result is the gain or loss from running 100 simulated trades. Each simulated trade adds 1 for a win or subtracts 1 for a loss. maxresult is the highest result in the simulation. maxdrawdown is the maximum number of consecutive losses. So with maxdrawdown == 5, there was at least one case of 10 simulated trades with 5 or more consecutive losses. That doesn't show how often any group of 10 consecutive trades had 5 or more losses though. So, I added that to my script. A sample run of that is: winrate 0.6 reward 1 risk 1 numTrades 100 numruns 20 groupSize 10 run 0 numTrades 100 result 8 maxresult 10 maxdrawdown 9 run 0 had 91 groups of 10 consecutive trades with (56 winningGroups) (21 losingGroups) (14 evenGroups) run 1 numTrades 100 result 28 maxresult 29 maxdrawdown 5 run 1 had 91 groups of 10 consecutive trades with (56 winningGroups) (9 losingGroups) (26 evenGroups) run 2 numTrades 100 result 26 maxresult 28 maxdrawdown 4 run 2 had 91 groups of 10 consecutive trades with (65 winningGroups) (4 losingGroups) (22 evenGroups) run 3 numTrades 100 result 26 maxresult 27 maxdrawdown 5 run 3 had 91 groups of 10 consecutive trades with (52 winningGroups) (11 losingGroups) (28 evenGroups) run 4 numTrades 100 result 26 maxresult 27 maxdrawdown 6 run 4 had 91 groups of 10 consecutive trades with (61 winningGroups) (17 losingGroups) (13 evenGroups) run 5 numTrades 100 result 36 maxresult 36 maxdrawdown 3 run 5 had 91 groups of 10 consecutive trades with (83 winningGroups) (2 losingGroups) (6 evenGroups) run 6 numTrades 100 result 32 maxresult 32 maxdrawdown 4 run 6 had 91 groups of 10 consecutive trades with (71 winningGroups) (5 losingGroups) (15 evenGroups) run 7 numTrades 100 result 30 maxresult 30 maxdrawdown 5 run 7 had 91 groups of 10 consecutive trades with (62 winningGroups) (12 losingGroups) (17 evenGroups) run 8 numTrades 100 result 22 maxresult 24 maxdrawdown 5 run 8 had 91 groups of 10 consecutive trades with (60 winningGroups) (16 losingGroups) (15 evenGroups) run 9 numTrades 100 result 12 maxresult 13 maxdrawdown 7 run 9 had 91 groups of 10 consecutive trades with (47 winningGroups) (26 losingGroups) (18 evenGroups) run 10 numTrades 100 result 6 maxresult 8 maxdrawdown 7 run 10 had 91 groups of 10 consecutive trades with (47 winningGroups) (29 losingGroups) (15 evenGroups) run 11 numTrades 100 result 10 maxresult 10 maxdrawdown 7 run 11 had 91 groups of 10 consecutive trades with (48 winningGroups) (22 losingGroups) (21 evenGroups) run 12 numTrades 100 result 18 maxresult 20 maxdrawdown 6 run 12 had 91 groups of 10 consecutive trades with (57 winningGroups) (18 losingGroups) (16 evenGroups) run 13 numTrades 100 result 16 maxresult 19 maxdrawdown 6 run 13 had 91 groups of 10 consecutive trades with (49 winningGroups) (26 losingGroups) (16 evenGroups) run 14 numTrades 100 result 44 maxresult 44 maxdrawdown 3 run 14 had 91 groups of 10 consecutive trades with (78 winningGroups) (4 losingGroups) (9 evenGroups) run 15 numTrades 100 result 22 maxresult 23 maxdrawdown 11 run 15 had 91 groups of 10 consecutive trades with (59 winningGroups) (22 losingGroups) (10 evenGroups) run 16 numTrades 100 result 14 maxresult 16 maxdrawdown 4 run 16 had 91 groups of 10 consecutive trades with (52 winningGroups) (12 losingGroups) (27 evenGroups) run 17 numTrades 100 result 6 maxresult 11 maxdrawdown 8 run 17 had 91 groups of 10 consecutive trades with (53 winningGroups) (17 losingGroups) (21 evenGroups) run 18 numTrades 100 result 12 maxresult 13 maxdrawdown 4 run 18 had 91 groups of 10 consecutive trades with (45 winningGroups) (16 losingGroups) (30 evenGroups) run 19 numTrades 100 result 20 maxresult 20 maxdrawdown 7 run 19 had 91 groups of 10 consecutive trades with (67 winningGroups) (11 losingGroups) (13 evenGroups) Each run simulated 100 trades which means they each had 91 groups of 10 consecutive trades (100 - 10 + 1). For example, run 0 had 56 that would have had 6 or more wins, and 21 + 14 = 45 that would have had 5 or fewer wins. So it would be fairly common to have 10 consecutive trades with 5 or fewer wins. Code: # simulate trades with a particular win rate, risk, and reward per trade. # assumes wins and losses are normally distributed. perl -e 'use warnings; use strict; use EasyLanguageObject; my $winrate = 0.6; my $reward = 1; my $risk = 1; my $numTrades = 100; my $numruns = 20; my $groupSize = 10; print "winrate $winrate reward $reward risk $risk numTrades $numTrades numruns $numruns groupSize $groupSize\n"; my $normval = `INVCDF=1 cdf $winrate`; # inverse cumulative normal distribution $normval =~ s/\s+$//; $normval =~ s/.* //; # second token has value corresponding to winrate my $rand = RandomGenerator->new(); for ( my $run = 0; $run < $numruns; ++$run ) { my $maxresult = 0; my $curresult = 0; my $maxdd = 0; my @groupedTrades; my $winningGroups = 0; my $losingGroups = 0; my $evenGroups = 0; for (my $i = 0; $i < $numTrades; ++$i) { # if ( $rand->randUnitUniform() <= $winrate ) if ( $rand->randFloatGaussian() <= $normval ) { $curresult += $reward; push (@groupedTrades, $reward); if ( $curresult > $maxresult ) { $maxresult = $curresult; } } else { $curresult -= $risk; push (@groupedTrades, -$risk); my $curdd = $maxresult - $curresult; if ($curdd > $maxdd) { $maxdd = $curdd; } } if ( scalar(@groupedTrades) == $groupSize ) { my $groupResult = 0; for my $result (@groupedTrades) { $groupResult += $result; } if ($groupResult > 0) { ++$winningGroups; } elsif ($groupResult < 0) { ++$losingGroups; } else { ++$evenGroups; } shift (@groupedTrades); } } my $numGroups = $winningGroups + $losingGroups + $evenGroups; print "\nrun $run numTrades $numTrades result $curresult maxresult $maxresult maxdrawdown $maxdd\n"; print "run $run had $numGroups groups of $groupSize consecutive trades with ($winningGroups winningGroups) ($losingGroups losingGroups) ($evenGroups evenGroups)\n"; } '
Ah i see now... thanks for your work... it has helped me straighting my thought process. So the "plan" in this case was always to fund for "highest group of loosing trades".... our case 29. Or to make it secure... make it 60. Which means 600 trades. And compound every 10% addition to the account balance.
Thank you for the new word. +1. https://english.stackexchange.com/questions/38945/what-is-wrong-with-the-word-performant What is wrong with the word “performant”? I keep getting the red underlining in Word whenever I write the word "performant". Here I intend to refer to something that performs well or better than something else (i.e., it's more performant). Is there something wrong with that word?
I agree with a comment at your link that indicates that there is a difference between the words performant and efficient/fast. A lot of real words, began as terms of art; only to later be added to the dictionaries. Another term not used much, therefore:
Effective What the hell, while we're at at and the question we all want to know is whether it is effective. Then we can see if it is performant. If it outcompetes the alternatives. effective Synonyms & Antonyms of 1 producing or capable of producing a desired result an effective treatment of the once-dreaded disease gave an effective speech that won over many undecided voters Synonyms for effective effectual, efficacious, efficient, fruitful, operative, potent, productive Words Related to effective hyperefficient, ultraefficient adequate, capable, competent accomplished, adept, consummate, experienced, expert, masterly, practiced (also practised), proficient, skilled, skillful, versed, veteran, virtuoso cogent, convincing, killer, sound, striking, telling, valid active, dynamic useful, working applicable, feasible, functional, practicable, practical, realizable, usable (also useable), workable Near Antonyms for effective counterproductive incapable, incompetent, inexperienced, inexpert, unqualified, unseasoned, unskilled, unskillful abortive, bootless, futile, vain empty, hollow, idle, pointless, unavailing, unprofitable, unsuccessful inoperative, worthless, fucked up
Assuming we have efficient pseudo-random number generators, both methods are acceptable given the problem at hand. We could also place 6 white balls and 4 black balls into an urn, and do everything manually. Of course there is no need to simulate here when the exact answer to questions about consecutive runs of losses and other events can be answered analytically with combinatorial probability.
The normal distribution was used to simulate a binomial random variable with a probability of success on a single trial of 0.6. This is one of many correct ways of doing this and has nothing to do with the distribution of stock prices.
subliminal combinatorial probability - Search - https://duckduckgo.com/?q=subliminal+combinatorial+probability&t=h_&ia=web combinatorial probability - search - https://duckduckgo.com/?q=combinatorial+probability&t=h_&ia=web