Back testing basics.

Discussion in 'Strategy Building' started by profitfromprice, Jun 6, 2005.

  1. I just found this Elite Trader website and I am very impressed by the trading resources it provides. Thanks to everyone who is posting useful information here.

    I need some feedback about back testing methods. I use a strategy for trading stocks for short-term- 1 to 30 days. I don't use any derivatives of prices like MACD, ROC, RSI...but just the plain four prices- Open, High, Low and Close.

    Only recently I saw back-testing being offered on the website I use daily to run my stock scans- http://www.stockfetcher.com.
    Their beta version of back-testing offers testing for the six month period or early 2003. When I ran my screens, I was impressed with the results I received. Most of my signals gave me a return of more than 20% per annum versus 4% for S&P 500 during the period. This was true not only for LONG positions but also for SHORT positions. As such this was my first back testing experience so just wanted to get some realistic feedback to make it more accurate.

    I am posting details of one of my signals -- U TURN (BUY).
    This is the exact syntax I use:

    "Show stocks where Close gained more than .15% percent over the last 1 day and open is more than .25% below the low 1 day ago and close is above the open 1 day ago and LOW reached a new 4 week low and volume gained more than 20% over volume 1 day ago and volume is above 500000 and close above 2"

    I am uploading details of the BUY version as well as the SELL version of this signal. These EXCEL files have 3 sheets- first one shows the test set-up, second one summary of results and the third one lists trades itself.

    Would love to hear your comments about how I can make this testing more realistic. Also, would be great if you can suggest some other websites which offer infrastructure to run screens and also to back test them.

    Thanks.
     
  2. Here is the XLS file for the SELL version of the signal.
     
  3. interesting. anything that shows good success on the short side is worth noting. maybe someone will code and show more detailed performance report stats as well as suggestions for improvement. i'll give it a shot, but can't within the next couple days. (yes, this simple system would take me several hours, if not days to code. :( ) my programming skills are very neophyte at the moment.
     
  4. I just visited the profit from price site and downloaded the free ebook. Are you the author by any chance, or did you come across the site yourself?

    My question for you is how often does this trading event occur, buying a stock during a retracement ( 4 week low ); it doesnt seem like their would be many opportunities in the market. Did your backtest only search the NDX100?

    You could try coding the strategy in wealthlab, using the wealthlab.com site. You could also consider downloading Amibroker for a free trail version, though it cost $99 or so to get the portfolio level backtesting feature. Im still new at the AFL ( Amibroker Formula Language ) but it can handle the task and you could have different versions of this strategy.
     
  5. Yes. I have authored this book- PROFIT FROM PRICES.
    http://www.profitfromprices.com

    You are correct- my screens are tight. I have around 10 different signals that I run everyday on stockfetcher to pick 1 to 4 stocks which offer the best reversal potential for taking long or short positions.

    The signal I have mentioned (U TURN) on this post gives me from 0 to 5 trading opportunities on a typical day. As you might find from the Excel files attached, I had around 100 BUY signals over the 6 month period and around 250 SELL signals.

    Thanks for suggesting wealthlab and the other system. I will take a look at them.

    Thanks again,

    Jayesh
     
  6. flat5

    flat5

    Your are running an information website about TA, and are asking on ET how to do basic backtesting? Does this not strike you as an absurdity?

    Hey, I'm running a how-to surgery information website. Do any of you guys know what a scalpel is?
     
  7. 20% p.a.? That is not very good - you can do just as good in a good mut fund with some occasional switches. Raising one's standards is good.
     
  8. Choad

    Choad

    Here's your long system in Wealth-Lab. It has a 10% profit target and 5% stoploss like the spreadsheet on your site.

    With starting capital $100,000, $5K trade size, 0.01/share commission, it barely breaks even over the last 5 years on the stocks in the SP500.

    System:


    {$NO_AUTO_EXECUTE}

    var Bar: integer;

    InstallProfitTarget(10); //10% profit target
    InstallStopLoss(5); //5% stoploss

    for Bar := 20 to BarCount - 1 do
    begin

    ApplyAutoStops(Bar);

    if not LastPositionActive then
    begin
    if PriceClose(Bar) > PriceClose(Bar - 1) * 1.0015 then //Close gained more than 0.15% percent over the last 1 day
    if PriceOpen(Bar) < PriceLow(Bar - 1) * 0.9975 then //Open is more than 0.25% below the low 1 day ago
    if PriceClose(Bar) > PriceOpen(Bar - 1) then //Close is above the open 1 day ago
    if PriceLow(Bar) <= Lowest(Bar - 1, #Low, 20) then //Today's LOW reached a new 4 week low
    if Volume(Bar) > Volume(Bar - 1) * 1.20 then //Volume gained more than 20% over volume 1 day ago
    if Volume(Bar) > 500000 then //Volume is above 500000
    if PriceClose(Bar) > 2.0 then //Close above 2
    BuyAtMarket(Bar + 1, 'Long Signal'); //Buy the next open
    end;

    end;



    SP500 results:


    Long + Short Long Only Short Only Buy & Hold
    Starting Capital $100,000.00 $100,000.00 $100,000.00 $100,000.00
    Ending Capital $103,371.30 $103,371.30 $100,000.00 $155,483.00
    Net Profit $3,371.30 $3,371.30 $0.00 $55,483.00
    Net Profit % 3.37% 3.37% 0.00% 55.48%
    Annualized Gain % 0.67% 0.67% 0.00% 9.23%
    Exposure 20.60% 20.60% 0.00% 92.81%

    Number of Trades 388 388 0 500
    Avg Profit/Loss $8.69 $8.69 $0.00 $110.97
    Avg Profit/Loss % 0.18% 0.18% 0.00% 56.87%
    Avg Bars Held 13.05 13.05 0.00 1,253.00

    Winning Trades 144 144 0 319
    Winning % 37.11% 37.11% N/A 63.80%
    Gross Profit $72,132.31 $72,132.31 $0.00 $69,046.10
    Avg Profit $500.92 $500.92 $0.00 $216.45
    Avg Profit % 10.03% 10.03% 0.00% 113.43%
    Avg Bars Held 18.34 18.34 0.00 1,253.00
    Max Consecutive 7 7 0 N/A

    Losing Trades 244 244 0 181
    Losing % 62.89% 62.89% N/A 36.20%
    Gross Loss $-68,761.01 $-68,761.01 $0.00 $-13,563.10
    Avg Loss $-281.81 $-281.81 $0.00 $-74.93
    Avg Loss % -5.63% -5.63% 0.00% -42.83%
    Avg Bars Held 9.93 9.93 0.00 1,253.00
    Max Consecutive 17 17 0 N/A

    Max Drawdown $-11,971.77 $-11,971.77 $0.00 $-30,386.86
    Max Drawdown % -11.61% -11.61% 0.00% -25.58%
    Max Drawdown Date 7/25/2002 7/25/2002 N/A 10/9/2002

    Wealth-Lab Score 2.86 2.86 0.00 7.40
    Profit Factor 1.05 1.05 0.00 5.09
    Recovery Factor 0.28 0.28 N/A 1.83
    Payoff Ratio 1.78 1.78 0.00 2.65
    Sharpe Ratio 0.13 0.13 0.00 0.63
    Ulcer Index 3.82 3.82 0.00 8.27
    Wealth-Lab Error Term 1.77 1.77 0.00 6.24
    Wealth-Lab Reward Ratio 0.38 0.38 N/A 1.48
    Luck Coefficient 1.68 1.68 0.00 10.59
    Pessimistic Rate of Return 0.91 0.91 0.00 4.10
    Equity Drop Ratio 3.90 3.90 0.00 0.33
     
  9. flat5

    You posted:
    "Your are running an information website about TA, and are asking on ET how to do basic backtesting? Does this not strike you as an absurdity?



    Hi Flat5,

    Did not mean to offend you or anyone. Sorry man. I have been trading as per my theory for last few years and had never thought of back testing it.

    However I am a regular visitor of stockfetcher.com and they invited their subs to explore the beta version of their new back testing service. It sounded interesting but I never had done any formal back testing. The EXCEL file I uploaded on my first post was my first experience with back testing.

    Then I came across this elitetrader.com website this week and I thought why spend time reinventing the wheel when I have found a community of expert traders! If there are people willing to share their knowledge and experience, why not learn from them?

    Thanks.
     
    #10     Jun 8, 2005