Australian (ASX) Stock Market Forum

Backtest your way to financial security

Re: Backtest your way to financial security.

nizar said:
Michael,

Isnt discretionary backtesting the same thing as paper-trading in the sense of what you will get out of it in terms of results ?
Not quite. When backtesting you can see the right hand side of the chart. This potentially introduces biases into entries and exits despite the very best of intentions.

When paper trading these biases are eliminated since you're already working with the right hand side of the chart. Paper trading also allows you to see if you've excessively curve fitted during backtesting (i.e. you've developed a plan which trades the backtest period(s) perfectly but which doesn't trade the same going forwards).
 
swingstar said:
Hi PF, how do you do this (can give me some terms to search the help file)?
You get the code to do it off Ami's website. It's called discretionary equity, and I found it in the knowledge base section.
Here's the link
Once you have the code, you just double click on it like you would for any other indicator,the parameters box will have the buy,sell,short,cover options. When you have gone through and done your buying and selling, you can run it through the auto analysis and it will punch out a report for you.
 
Hello all. I've started to get an interest for mech systems after playing around with my stock scanner. Now this is a very simple scan, but so far when i back test it, it seems to do quite well in terms of % gains as measured by the scanner.

It goes like this: Identify a SP that opens below the 13ema, and closes above it on the last day of trading.

While also the open and close are both above the 200 sma.

Only if the volume is above the 21ma.

Surprisingly this seems to backtest really well. Now if i exited when the SP crossed back over the 13ema i might give back some profits, but i might save some too.

So my question is simply, am i on the right path to understanding mech systems and backtesting, and if i apply some risk management, what is stopping me from applying this to my trading?

Perhaps i'm better to test it for 6 months or so.

Cheers,
 
CanOz said:
Hello all. I've started to get an interest for mech systems after playing around with my stock scanner. Now this is a very simple scan, but so far when i back test it, it seems to do quite well in terms of % gains as measured by the scanner.

It goes like this: Identify a SP that opens below the 13ema, and closes above it on the last day of trading.

While also the open and close are both above the 200 sma.

Only if the volume is above the 21ma.

Surprisingly this seems to backtest really well. Now if i exited when the SP crossed back over the 13ema i might give back some profits, but i might save some too.

So my question is simply, am i on the right path to understanding mech systems and backtesting, and if i apply some risk management, what is stopping me from applying this to my trading?

Perhaps i'm better to test it for 6 months or so.

Cheers,

As we are all trading/investing for profit/growth, your answer lies in that realisation.
 
CanOz said:
Hello all. I've started to get an interest for mech systems after playing around with my stock scanner. Now this is a very simple scan, but so far when i back test it, it seems to do quite well in terms of % gains as measured by the scanner.

It goes like this: Identify a SP that opens below the 13ema, and closes above it on the last day of trading.

While also the open and close are both above the 200 sma.

Only if the volume is above the 21ma.

Surprisingly this seems to backtest really well. Now if i exited when the SP crossed back over the 13ema i might give back some profits, but i might save some too.

So my question is simply, am i on the right path to understanding mech systems and backtesting, and if i apply some risk management, what is stopping me from applying this to my trading?

Perhaps i'm better to test it for 6 months or so.

Cheers,

Can,

I like it how you've mentioned exits, as most mechanical systems focus on the perfect entry.

Have you worked out when you will give back profits when the 13ema is crossed? Or is this part of the system (exits) still very much discretionary?

My entry at the moment, is a close above all-time highs, or sometimes even those with the least resistance as possible. As iv said previously, iv never intended to "day-trade" and i would prefer to take a longer term view. But sometimes when a stock gives my entry, i take a postion before the volume confirms that the breakout will be a short-term one. With stocks like MLS, and JMS, i would love them to move ~10% a week and just hold it for a few months ie. ride a longer term trend. But when they move 50-100% in 1-2days, i just say thanks, obviously that sort of move isnt sustainable.

AGM i took a position when it broke through 40c last week, 10years of resistance. This one didnt go crazy, but slow and steady is nice. Im still holding.
 
nizar said:
Can,

I like it how you've mentioned exits, as most mechanical systems focus on the perfect entry.

Have you worked out when you will give back profits when the 13ema is crossed? Or is this part of the system (exits) still very much discretionary?

My entry at the moment, is a close above all-time highs, or sometimes even those with the least resistance as possible. As iv said previously, iv never intended to "day-trade" and i would prefer to take a longer term view. But sometimes when a stock gives my entry, i take a postion before the volume confirms that the breakout will be a short-term one. With stocks like MLS, and JMS, i would love them to move ~10% a week and just hold it for a few months ie. ride a longer term trend. But when they move 50-100% in 1-2days, i just say thanks, obviously that sort of move isnt sustainable.

AGM i took a position when it broke through 40c last week, 10years of resistance. This one didnt go crazy, but slow and steady is nice. Im still holding.

The exits i think i will have to leave up to a certain amount of descretion for now. Until i research them a bit more, maybe two closes below the 13ema would be enough to pull the pin and not have it come back and haunt me....not sure yet. I can backtest exits as well, so i might try that.

Allot of this works well in bullish markets and i can't really back test far enough back to test it in bearish markets...but you could also reverse the signals and trade short positions that come up too i suppose.

I like your system too, buying on the all time highs, and there are some traders in Nick Radge's book "Every Day Traders" that do something very similar, buying on a high and a rising ma.

One thing is for sure, simple seems best and retains robustness. I would like to be in a position one day to be trading this way with the majority of my capital while saving a portion for intraday if the market's really bullish. Then also develop a longer term, bear market resistant system or just take signals from one of Nick's systems to preserve capital and try to beat the banks.

All very interesting stuff, but very basic as i haven't the software to get too deep yet. I will be developing this strategy for a while i think.

Cheers,
 
https://www.aussiestockforums.com/forums/showthread.php?t=5234

There is some discussion on this sister thread which maybe helpful to some.

Sorry to say but your M/A cross over system is doomed.
And thats without testing it through Tradesim.

Exits are where you'll make your money.
You have much more to do first before worrying about exits.

Read the stuff in the thread above from Stevo and myself should get the grey matter working.
 
tech/a said:
https://www.aussiestockforums.com/forums/showthread.php?t=5234

There is some discussion on this sister thread which maybe helpful to some.

Sorry to say but your M/A cross over system is doomed.
And thats without testing it through Tradesim.

Exits are where you'll make your money.
You have much more to do first before worrying about exits.

Read the stuff in the thread above from Stevo and myself should get the grey matter working.

Ok teck thanks, i suggested maybe we can get my recent postings on here moved over there.

Doomed......Ahhhhh! Back to the drawing board :eek:


Cheers,
 
Can..


I coded it up and ran it for you.
Afraid its as I expected.
Detailed Report

Trade Database Filename
C:\TradeSimData\Test 13 day simple.trb

Simulation Summary
Simulation Date: 9/12/2006
Simulation Time: 2:51:39 PM
Simulation Duration: 9.91 seconds

Trade Summary
Earliest Entry Date in the Trade Database: 2/09/1998
Latest Entry Date in the Trade Database: 8/12/2006
Earliest Exit Date in the Trade Database: 8/09/1998
Latest Exit Date in the Trade Database: 8/12/2006

Start Trade Entry Date: 2/09/1998
Stop Trade Entry Date: 8/12/2006
First Entry Date: 2/09/1998
Last Entry Date: 20/08/2004
First Exit Date: 8/09/1998
Last Exit Date: 24/08/2004

Total Trading duration: 2183 days

Profit Summary
Profit Status: BANKRUPT
Starting Capital: $100,000.00
Finishing Capital: -$6.11
Maximum Equity/(Date): $2,682.38 (13/12/1999)
Minimum Equity/(Date): -$100,006.11 (24/08/2004)
Gross Trade Profit: $158,218.24 (158.22%)
Gross Trade Loss: -$258,224.34 (-258.22%)
Total Net Profit: -$100,006.11 (-100.01%)
Average Profit per Trade: -$54.50
Profit Factor: 0.6127
Profit Index: -63.21%
Total Transaction Cost: $110,100.00
Total Slippage: $0.00
Daily Compound Interest Rate: 100%
Annualized Compound Interest Rate: 100%

Trade Statistics
Trades Processed: 8696
Trades Taken: 1835
Partial Trades Taken: 0
Trades Rejected: 5970
Winning Trades: 341 (18.58%)
Losing Trades: 1494 (81.42%)
Breakeven Trades: 0 (0.00%)

Largest Winning Trade/(Date): $18,376.32 (8/12/1999)
Largest Losing Trade/(Date): -$2,075.00 (5/04/2000)
Average Winning Trade: $463.98
Average Losing Trade: -$172.84
Average Win/Average Loss: 2.6845

Trade Breakdown Long and Short Trades Long Trades Short Trades
Normal Exit: 1796 (97.87%) 1796 (97.87%) 0 (0.00%)
Protective Stop: 39 (2.13%) 39 (2.13%) 0 (0.00%)

Total Trades: 1835 (100.00%) 1835 (100.00%) 0 (0.00%)

Trade Duration Statistics Winning and Losing Trades Winning Trades Losing Trades
Maximum Trade Duration: 79 (days) 79 (days) 71 (days)
Minimum Trade Duration: 1 (days) 1 (days) 1 (days)
Average Trade Duration: 9.00 (days) 22.48 (days) 5.92 (days)

Consecutive Trade Statistics
Maximum consecutive winning trades: 6
Maximum consecutive losing trades: 106
Average consecutive winning trades: 1.44
Average consecutive losing trades: 6.33

Trade Expectation Statistics
Normalized Expectation per dollar risked: -$0.19
Maximum Reward/Risk ratio: 21.03
Minimum Reward/Risk ratio: -2.00
Average Positive Reward/Risk ratio: $0.61
Average Negative Reward/Risk ratio: -$0.37

Relative Drawdown
Maximum Dollar Drawdown/(Date): $6,522.06 (13/04/2000)
Maximum Percentage Drawdown/(Date): 100.2000% (24/08/2004)

Absolute (Peak-to-Valley) Dollar Drawdown
Maximum Dollar Drawdown: $102,418.49 (100.0000%)
Capital Peak/(Date): $102,412.38 (13/12/1999)
Capital Valley/(Date): -$6.11 (24/08/2004)

Absolute (Peak-to-Valley) Percent Drawdown
Maximum Percentage Drawdown: 100.0000% ($102,418.49)
Capital Peak/(Date): $102,412.38 (13/12/1999)
Capital Valley/(Date): -$6.11 (24/08/2004)
 
So then I altered the periodicy to weekly and while not startling it was profitable.
The first table is the Singular test.
Detailed Report

Trade Database Filename
C:\TradeSimData\Test 13 day simple weekly.trb

Simulation Summary
Simulation Date: 9/12/2006
Simulation Time: 2:57:31 PM
Simulation Duration: 1.73 seconds

Trade Summary
Earliest Entry Date in the Trade Database: 4/09/1998
Latest Entry Date in the Trade Database: 8/12/2006
Earliest Exit Date in the Trade Database: 11/09/1998
Latest Exit Date in the Trade Database: 8/12/2006

Start Trade Entry Date: 4/09/1998
Stop Trade Entry Date: 8/12/2006
First Entry Date: 4/09/1998
Last Entry Date: 8/12/2006
First Exit Date: 11/09/1998
Last Exit Date: 8/12/2006

Total Trading duration: 3017 days

Profit Summary
Profit Status: PROFITABLE
Starting Capital: $100,000.00
Finishing Capital: $165,407.02
Maximum Equity/(Date): $65,407.02 (8/12/2006)
Minimum Equity/(Date): -$22,701.66 (31/03/2000)
Gross Trade Profit: $271,037.22 (271.04%)
Gross Trade Loss: -$205,630.20 (-205.63%)
Total Net Profit: $65,407.02 (65.41%)
Average Profit per Trade: $122.03
Profit Factor: 1.3181
Profit Index: 24.13%
Total Transaction Cost: $32,160.00
Total Slippage: $0.00
Daily Compound Interest Rate: 0.0167%
Annualized Compound Interest Rate: 6.2774%

Trade Statistics
Trades Processed: 6090
Trades Taken: 536
Partial Trades Taken: 0
Trades Rejected: 3950
Winning Trades: 152 (28.36%)
Losing Trades: 384 (71.64%)
Breakeven Trades: 0 (0.00%)

Largest Winning Trade/(Date): $22,974.58 (14/04/2000)
Largest Losing Trade/(Date): -$5,427.05 (16/09/2005)
Average Winning Trade: $1,783.14
Average Losing Trade: -$535.50
Average Win/Average Loss: 3.3299

Trade Breakdown Long and Short Trades Long Trades Short Trades
Normal Exit: 482 (89.93%) 482 (89.93%) 0 (0.00%)
Protective Stop: 42 (7.84%) 42 (7.84%) 0 (0.00%)
Open Trade: 12 (2.24%) 12 (2.24%) 0 (0.00%)

Total Trades: 536 (100.00%) 536 (100.00%) 0 (0.00%)

Trade Duration Statistics Winning and Losing Trades Winning Trades Losing Trades
Maximum Trade Duration: 301 (days) 301 (days) 168 (days)
Minimum Trade Duration: 0 (days) 6 (days) 0 (days)
Average Trade Duration: 45.94 (days) 107.74 (days) 21.48 (days)

Consecutive Trade Statistics
Maximum consecutive winning trades: 4
Maximum consecutive losing trades: 13
Average consecutive winning trades: 1.48
Average consecutive losing trades: 3.76

Trade Expectation Statistics
Normalized Expectation per dollar risked: $0.12
Maximum Reward/Risk ratio: 23.41
Minimum Reward/Risk ratio: -3.90
Average Positive Reward/Risk ratio: $1.57
Average Negative Reward/Risk ratio: -$0.46

Relative Drawdown
Maximum Dollar Drawdown/(Date): $10,849.20 (6/10/2006)
Maximum Percentage Drawdown/(Date): 8.9920% (6/10/2006)

Absolute (Peak-to-Valley) Dollar Drawdown
Maximum Dollar Drawdown: $32,987.01 (23.1000%)
Capital Peak/(Date): $142,785.69 (1/04/2005)
Capital Valley/(Date): $109,798.68 (6/10/2006)

Absolute (Peak-to-Valley) Percent Drawdown
Maximum Percentage Drawdown: 23.1000% ($32,987.01)
Capital Peak/(Date): $142,785.69 (1/04/2005)
Capital Valley/(Date): $109,798.68

(6/10/2006)
 
The second table is a Montecarlo report of 10000 portfolios

Monte Carlo Report

Trade Database Filename
C:\TradeSimData\Test 13 day simple weekly.trb

Simulation Summary
Simulation Date: 9/12/2006
Simulation Time: 2:58:27 PM
Simulation Duration: 113.57 seconds

Trade Parameters
Initial Capital: $100,000.00
Portfolio Limit: 100.00%
Maximum number of open positions: 100
Position Size Model: Fixed Percent Risk
Percentage of capital risked per trade: 2.00%
Position size limit: 10.00%
Portfolio Heat: 100.00%
Pyramid profits: Yes
Transaction cost (Trade Entry): $30.00
Transaction cost (Trade Exit): $30.00
Margin Requirement: 100.00%
Magnify Position Size(& Risk) according to Margin Req: No

Trade Preferences
Trading Instrument: Stocks
Break Even Trades: Process separately
Trade Position Type: Process long trades only
Entry Order Type: Default Order
Exit Order Type: Default Order
Minimum Trade Size: $0.00
Accept Partial Trades: No
Volume Filter: Ignore Volume Information
Pyramid Trades: No
Use Level Zero trades only: Yes

Simulation Stats
Number of trade simulations: 10000
Trades processed per simulation: 6090
Maximum Number of Trades Executed: 582
Average Number of Trades Executed: 515
Minimum Number of Trades Executed: 454
Standard Deviation: 16.76

Profit Stats
Maximum Profit: $613,218.49 (613.22%)
Average Profit: $156,845.06 (156.85%)
Minimum Profit: -$22,724.71 (-22.72%)
Standard Deviation: $78,483.58 (78.48%)
Probability of Profit: 99.65%
Probability of Loss: 0.35%


Percent Winning Trade Stats
Maximum percentage of winning trades: 37.76%
Average percentage of winning trades: 30.81%
Minimum percentage of winning trades: 22.68%
Standard Deviation: 1.79%

Percent Losing Trade Stats
Maximum percentage of losing trades: 77.32%
Average percentage of losing Trades: 69.19%
Minimum percentage of losing trades: 62.24%
Standard Deviation: 1.79%

Average Relative Dollar Drawdown Stats
Maximum of the Average Relative Dollar Drawdown: $3,411.85
Average of the Average Relative Dollar Drawdown: $1,681.34
Minimum of the Average Relative Dollar Drawdown: $866.74
Standard Deviation: $297.49

Average Relative Percent Drawdown Stats
Maximum of the Average Relative Percent Drawdown: 1.8221%
Average of the Average Relative Percent Drawdown: 1.0840%
Minimum of the Average Relative Percent Drawdown: 0.6655%
Standard Deviation: 0.1374%

Maximum Peak-to-Valley Dollar Drawdown Stats
Maximum Absolute Dollar Drawdown: $89,037.38
Average Absolute Dollar Drawdown: $33,620.12
Minimum Absolute Dollar Drawdown: $13,910.99
Standard Deviation: $9,376.44

Maximum Peak-to-Valley Percent Drawdown Stats
Maximum Absolute Percent Drawdown: 51.0453%
Average Absolute Percent Drawdown: 19.5400%
Minimum Absolute Percent Drawdown: 7.7471%
Standard Deviation: 5.2278%
 
From the first backtest of MA crossover:
Maximum consecutive losing trades: 106
:eek: :eek:

I note the 2nd backtest results (weekly) was profitable but only getting 28% winners, probably hard to handle psychologically. ie. you would only win 3 out of every 11 trades.

With this backtesting, where is the initial stop placed? and when is this adjusted? ie. to a breakeven stop or to a trailing stop?

Can you even backtest with those sorts of parameters?

Obviously in thinking that can make a huge difference to profitability.
 
What was the criteria that you asked it to run? Were the losses due to mostly the exit? Sorry if i've missed something...on my way out the door to get a haircut! Can't see for the hair in my eyes.

Thank Tech, looking forward to going over this better later.

Cheers,
 
Nizar.

Its not even worth fiddling with.
From the results its clear that it is whipsawed out all the time.

Just as a comparison here is T/Trader based upon 35% margin.
IE 65% leverage.

Detailed Report

Trade Database Filename
C:\TradeSimData\TT Latch Master stop..trb

Simulation Summary
Simulation Date: 9/12/2006
Simulation Time: 5:00:27 PM
Simulation Duration: 1.02 seconds

Trade Summary
Earliest Entry Date in the Trade Database: 7/09/1998
Latest Entry Date in the Trade Database: 2/11/2006
Earliest Exit Date in the Trade Database: 28/09/1998
Latest Exit Date in the Trade Database: 3/11/2006

Start Trade Entry Date: 7/09/1998
Stop Trade Entry Date: 2/11/2006
First Entry Date: 7/09/1998
Last Entry Date: 18/09/2006
First Exit Date: 28/09/1998
Last Exit Date: 3/11/2006

Total Trading duration: 2979 days

Profit Summary
Profit Status: PROFITABLE
Starting Capital: $100,000.00
Finishing Capital: $2,175,204.97
Maximum Equity/(Date): $2,075,204.97 (3/11/2006)
Minimum Equity/(Date): -$27,821.50 (18/04/2000)
Gross Trade Profit: $2,582,455.20 (2582.46%)
Gross Trade Loss: -$507,250.23 (-507.25%)
Total Net Profit: $2,075,204.97 (2075.20%)
Average Profit per Trade: $6,050.16
Profit Factor: 5.0911
Profit Index: 80.36%
Total Transaction Cost: $20,580.00
Total Slippage: $0.00
Daily Compound Interest Rate: 0.1034%
Annualized Compound Interest Rate: 45.8399%

Trade Statistics
Trades Processed: 1902
Trades Taken: 343
Partial Trades Taken: 0
Trades Rejected: 740
Winning Trades: 118 (34.40%)
Losing Trades: 225 (65.60%)
Breakeven Trades: 0 (0.00%)

Largest Winning Trade/(Date): $334,597.39 (3/11/2006)
Largest Losing Trade/(Date): -$20,548.00 (15/05/2006)
Average Winning Trade: $21,885.21
Average Losing Trade: -$2,254.45
Average Win/Average Loss: 9.7076

Trade Breakdown Long and Short Trades Long Trades Short Trades
Normal Exit: 238 (69.39%) 238 (69.39%) 0 (0.00%)
Protective Stop: 82 (23.91%) 82 (23.91%) 0 (0.00%)
Open Trade: 23 (6.71%) 23 (6.71%) 0 (0.00%)

Total Trades: 343 (100.00%) 343 (100.00%) 0 (0.00%)

Trade Duration Statistics Winning and Losing Trades Winning Trades Losing Trades
Maximum Trade Duration: 1632 (days) 1632 (days) 222 (days)
Minimum Trade Duration: 1 (days) 12 (days) 1 (days)
Average Trade Duration: 151.73 (days) 344.54 (days) 50.60 (days)

Consecutive Trade Statistics
Maximum consecutive winning trades: 20
Maximum consecutive losing trades: 13
Average consecutive winning trades: 1.79
Average consecutive losing trades: 3.41

Trade Expectation Statistics
Normalized Expectation per dollar risked: $1.53
Maximum Reward/Risk ratio: 54.81
Minimum Reward/Risk ratio: -2.08
Average Positive Reward/Risk ratio: $5.63
Average Negative Reward/Risk ratio: -$0.62

Relative Drawdown
Maximum Dollar Drawdown/(Date): $45,566.29 (15/08/2006)
Maximum Percentage Drawdown/(Date): 14.3700% (18/04/2000)

Absolute (Peak-to-Valley) Dollar Drawdown
Maximum Dollar Drawdown: $45,566.29 (4.1610%)
Capital Peak/(Date): $1,095,150.64 (28/07/2006)
Capital Valley/(Date): $1,049,584.35 (15/08/2006)

Absolute (Peak-to-Valley) Percent Drawdown
Maximum Percentage Drawdown: 28.2400% ($28,241.50)
Capital Peak/(Date): $100,000.00 (18000101)
Capital Valley/(Date): $71,758.50 (18/04/2000)
 
In my veiw the BIBLE for Systems developers.

Trading Systems and Methods---Author Perry J Kaufman.
ISBN0-471-14879-2
 
Re: Backtest your way to financial security.

Paper trading also allows you to see if you've excessively curve fitted during backtesting (i.e. you've developed a plan which trades the backtest period(s) perfectly but which doesn't trade the same going forwards).

Great thread, just had another read.
Michael defines curve-fitting superbly.
 
Also some great points about how to make a system fail by stevo, tech, and rub92me, ill certainly be reading this thread again when im testing my system.

Thanks guys.
 
Top