How to Make Consistent Money

Support functions for the experiment

A single trade will either make the average win, or lose the average loss.

In[82]:=

singleTrade[winRate_, avgWin_, avgLoss_] := If[Random[] < winRate, avgWin, -avgLoss]

For each period we're considering (whether it's a day, a week, a month, a year, etc)... tradingPeriod makes a list of trading outcomes, based on the number of trades we will take, per trading period.

In[83]:=

tradingPeriod[numTrades_, winRate_, avgWin_, avgLoss_] := Table[singleTrade[winRate, avgWin, avgLoss], {numTrades}]

... and tradingTrials is just a set of tradingPeriods... as in, "what if I traded 20 trades a day, for 2000 days?"  That would be 2000 trials of a 20-trade trading period.

In[84]:=

tradingTrials[numTrials_, numTrades_, winRate_, avgWin_, avgLoss_]    :=  Table[tradingPeriod[numTrades, winRate, avgWin, avgLoss], {numTrials}]

Given our tradingTrials, then pctProfitable calculates what percentage of the trade sets were profitable...

In[85]:=

pctProfitable[tpers_] := With[{results = Map[Total, tpers]}, Count[results, _ ? Positive]/Length[results] ]

Profit Factor and Expectancy are two measures of trading performance...

In[86]:=

profitFactor[winRate_, avgWin_, avgLoss_] := (winRate avgWin)/((1 - winRate) avgLoss)

In[87]:=

expectancy[winRate_, avgWin_, avgLoss_] := winRate avgWin   - (1 - winRate) avgLoss

This is just a helper function to print stuff out...

In[88]:=

Another helper function, to label our plots well:

In[92]:=

This is the main report that draws the pretty table...

In[90]:=

Effect of Positive Expectancy on Consistency

Your expectancy is your tendency to make money over a large number of trades (to be precise, over an _infinite_ number of trades).  Therefore, it's imperative that your expectancy be above 0. Otherwise, as these charts show, the more trades you make in a given time period, the less chance you have of being profitable!  In other words, if your expectancy is negative, and you just HAVE to trade, the best thing you can do is trade once and hope you happen to win.  (By the way, this is also how you can figure out the best advice for playing roulette... your best chances are just to bet it all on either red or black, and hope you happen to win... the longer you play, the bigger chance you have of losing).

In[124]:=

mkRpt[2000, 0.7, 500, 500]

[Graphics:HTMLFiles/System_Consistency_11.gif]

In[127]:=

mkRpt[2000, 0.15, 1000, 411.76]

[Graphics:HTMLFiles/System_Consistency_13.gif]

So, from now on, for obvious reasons, all of our examples will have a positive expectancy.

By the way, if your expectancy is exactly 0, then you eventually converge on a 50/50 shot at profitabliity over time:

In[156]:=

mkRpt[2000, 0.2, 1000, 250]

[Graphics:HTMLFiles/System_Consistency_15.gif]

Effect of Expectancy Size on Consistency

So, we know that we need a positive expectancy to be consistently profitable.  Do we need a large expectancy?  What happens if we vary the expectancy from the first example, both down from 200, and up from 200?  Will it change our consistency?

In[129]:=

Do[mkRpt[2000, 0.7, s, s], {s, 100, 1100, 200}] ;

[Graphics:HTMLFiles/System_Consistency_17.gif]

[Graphics:HTMLFiles/System_Consistency_18.gif]

[Graphics:HTMLFiles/System_Consistency_19.gif]

[Graphics:HTMLFiles/System_Consistency_20.gif]

[Graphics:HTMLFiles/System_Consistency_21.gif]

[Graphics:HTMLFiles/System_Consistency_22.gif]

Wow, these all look pretty much the same.  If you think about it, you will realize that a higher expectancy means you will make _more_ money when you are profitable.  But, it's really irrelevant to your consistent profitability.

Effect of Win Rate on Consistent Profitability

Well, what about if we vary the win rate?  What effect will that have on consistency?

In[135]:=

Do[mkRpt[2000, wr, 1000, 500], {wr, 0.35, 0.95, 0.15}] ;

[Graphics:HTMLFiles/System_Consistency_24.gif]

[Graphics:HTMLFiles/System_Consistency_25.gif]

[Graphics:HTMLFiles/System_Consistency_26.gif]

[Graphics:HTMLFiles/System_Consistency_27.gif]

[Graphics:HTMLFiles/System_Consistency_28.gif]

Initially, it looks like increasing the win rate has a positive effect on consistency.  But, notice that the way we've set up this test, both expectancy and the profit factor drift up along with the win rate.  We already know from earlier that different expectancies don't make a difference, but what about the profit factor?  Let's do the test again, only we'll hold the profit factor at a constant as we raise the win rate:

In[142]:=

Do[With[{al = Solve[(1000 wr)/((1 - wr) loss) == 2, loss][[1, 1, 2]]}, mkRpt[2000, wr, 1000, al]], {wr, 0.35, 0.95, 0.15}] ;

[Graphics:HTMLFiles/System_Consistency_30.gif]

[Graphics:HTMLFiles/System_Consistency_31.gif]

[Graphics:HTMLFiles/System_Consistency_32.gif]

[Graphics:HTMLFiles/System_Consistency_33.gif]

[Graphics:HTMLFiles/System_Consistency_34.gif]

If you are wondering why the last one looks so weird, it's because it's hard to have a profit factor of 2, and a win rate of 95%... if your average win is $1000, then your average loss has to be $9500:

In[143]:=

 Solve[(1000 0.95)/((1 - 0.95) loss) == 2, loss]

Out[143]=

{{loss→9500.}}

But, regardless, you can see that with a constant profit factor, win rate and expectancy have very little to do with consistency in a given time period.  That leaves the profit factor.

Effect of Profit Factor on Consistent Profitability

Ok, now just to visually confirm what I've just said, let's draw a series of charts with increasing profit factors, and show how the consistency improves:

In[154]:=

[Graphics:HTMLFiles/System_Consistency_38.gif]

[Graphics:HTMLFiles/System_Consistency_39.gif]

[Graphics:HTMLFiles/System_Consistency_40.gif]

[Graphics:HTMLFiles/System_Consistency_41.gif]

[Graphics:HTMLFiles/System_Consistency_42.gif]

[Graphics:HTMLFiles/System_Consistency_43.gif]

[Graphics:HTMLFiles/System_Consistency_44.gif]

[Graphics:HTMLFiles/System_Consistency_45.gif]

[Graphics:HTMLFiles/System_Consistency_46.gif]

[Graphics:HTMLFiles/System_Consistency_47.gif]

[Graphics:HTMLFiles/System_Consistency_48.gif]

Properties of the Profit Factor

Note that whenever the profit factor is 1, the expectancy has to be 0.  This can be seen by simple transformation of the equation for the Profit Factor.

In[158]:=

onepf = (aw winr)/((1 - winr) al) == 1

Out[158]=

(aw winr)/(al (1 - winr)) == 1

In[163]:=

MapAt[(#1 * (1 - winr) al) &, onepf, {{1}, {2}}]

Out[163]=

aw winr == al (1 - winr)

In[164]:=

MapAt[(#1 - al (1 - winr)) &, %, {{1}, {2}}]

Out[164]=

-al (1 - winr) + aw winr == 0

Note that this is the expectancy equation.  And, with similar logic, you can show that whenever the PF is > 1, the expectancy is greater than 0.  Whenever the PF is < 1, the expectancy is less than 0.  So, from a consistency standpoint, striving for a positive expectancy is equivilent to striving for a profit factor > 1.


Created by Mathematica  (January 28, 2007) Valid XHTML 1.1!