Australian (ASX) Stock Market Forum

My Trading Plan/System (Beginner)

Saiter,

You might want to check your logic. I coded it for MS and backtested it in Tradesim on the ASX50. Well over half the trades, and all of them on the Long side, enter and exit on the same day.eg Long NAB 12/5/08, Close NAB 12/5/08.
 
Good one. Bet you learnt something more valuable than reading your next book?

If a system fails badly consider flipping it - long when short. It may be a winner. Like a couple suggested ;)

Okay well this time, I went short instead of long
Code:
(short=buy and cover=sell)
. A 1% stop loss and 5% trailing stop was used.

Results of Backtest from 01/01/09 to 20/02/09
=================

Starting capital: $7500
Ending capital: $7630.86
Net Profit: 1.74%
Total Trades: 18
Winners: 2 (11.11%) with average win of $522.18
Losers: 16 (88.89%) with average loss of $57.09
Max system %DD: -10.75%
Risk/Reward Ratio: 7.83

Results of Backtest from 01/09/08 to 20/02/09
================

Starting capital: $7500
Ending capital: $5240.44
Net Profit: -30.13%
Total Trades: 58
Winners: 12 (20.69%) with average win of $297.43
Losers: 46 (79.31%) with average loss of $126.71
Max system %DD: -39.9%
Risk/Reward Ratio: -11.16

Results of Backtest from 01/01/09 to 20/02/09
================

Starting capital: $7500
Ending capital: $15328.97
Net Profit: 104.39%
Total Trades: 107
Winners: 25 (23.36%) with average win of $1039.02
Losers: 82 (76.64%) with average loss of $221.30
Max system %DD: -30.23%
Risk/Reward Ratio: 3.61

And for the fun of it, I backtested it from 01/01/01 till today and I ended up with a whopping $2.50 left in my account :p

So I can turn a pretty good profit with a small win % and if the market is declining. I guess the results from the former 2 backtests were because the XAO was going sideways from 21/11/08 and still is?

I'll try working on the other two systems and see what I can pull out.
 
You might want to check your logic. I coded it for MS (had to make a few tweaks in translation ) and backtested it in Tradesim on the ASX50. Well over half the trades, and all of them on the Long side, enter and exit on the same day.eg Long NAB 12/5/08 - Close NAB 12/5/08.

Yup, this is happening on my scans as well. Look at the image below:

example.png
 
very interesting thread leaves a lot to think about

should any trading system be adjusted to take the current trend into account
as mentioned above a flip around would have resulted in quite a profit
 
very interesting thread leaves a lot to think about

should any trading system be adjusted to take the current trend into account
as mentioned above a flip around would have resulted in quite a profit

Yup yup. I guess then that it'd be a good idea to have a range of systems, each suited to a particular stage of the market cycle so that you can implement them when needed.
 
should any trading system be adjusted to take the current trend into account

Absolutely.

All your trying to do is work out how to get onto the trend and exit, or to pick a turnaround in the trend.

If your not taking the trend into account (however you choose to define trend, some use MAs, others such as myself simply use a HH and HL or LH and LL in the main timeframe I trade), then your basically missing the entire base of which you form your strategy.
 
"What have I done wrong?"

Some more reading needed.
I think you'll also find that your entries and exits are also on the same day as they are triggered. unless you have a way of exiting intraday(And how do you know the final bar type untill close?) you should have both set at buy or sell delay of 1 bar as most EOD systems signal at the close of the day. This can dramatically alter the result of a system.

Another observation is that none of your sell signals conform to the condition
'Highest close in the last 90 days".

Flipping entry to exit and V versa is poor logic.
 
Your 10%-20% Win ratio might strain you.

you could be looking at drawdowns of up to 50% - depending on your risk ofcourse, but you could suffer up to 20 losses in a row- probably more - i havent done the sums.

would you continue trading with 20 losses in a row? something to consider
 
What have I done wrong

Sell = LLV(spread,15) AND V>1.5*Y AND C>mid AND HHV(C,90);

Convert to something like

Sell = spread <= LLV(spread, 15) AND ... AND C >= HHV(C,90);

(Dont know if you want comparisons relative to prev. day. For example:

C > Ref(HHV(C,90), -1)

But, they might get to out at the beginning of the trend, rather that riding the trend. Depends on what you are trying to do.)
Tim
 
What have I done wrong

Sell = LLV(spread,15) AND V>1.5*Y AND C>mid AND HHV(C,90);

Convert to something like

Sell = spread <= LLV(spread, 15) AND ... AND C >= HHV(C,90);

(Dont know if you want comparisons relative to prev. day. For example:

C > Ref(HHV(C,90), -1)

But, they might get to out at the beginning of the trend, rather that riding the trend. Depends on what you are trying to do.)
Tim

Holy **** that is sooooooooooo much better! Thanks for your help, testing it right now!
 
Backtest results
  1. System in use

    A stop loss of 1% with a trailing stop of 5% was used.
    Code:
    /*Variables*/
    /***********/
    y=MA(Volume,10); /*Formula for Average Volume*/
    spread= H-L; /*Size of the spread*/
    mid = L + spread/2; /*The midpoint of a bar*/
    
    
    /*Going Long*/
    /************/
    [B]/*Buy Condition: Three consecutive up-thrust days with successively increasing volume*/[/B]
    Buy = Ref(C,-2)<Ref(C,-1) AND Ref(C,-1)<C AND Ref(C,-2)<C AND Ref(V,-2)<Ref(V,-1) AND Ref(V,-1)<V AND Ref(V,-2)<V;
    
    /*Sell Condition #1: Three days where the close is sideways (+/- 5% of each other) and volume is successively decling but larger than average for the first two days*/
    /*Sell =  (Ref(C,-2)<1.025*Ref(C,-1) AND Ref(C,-2)>0.975*Ref(C,-1)) AND (Ref(C,-2)<1.025*C AND Ref(C,-2)>0.975*C) AND (Ref(C,-1)<1.025*C AND Ref(C,-1)>0.975*C);*/
    
    [B]/*Sell Condition #2: Sell on the bar with the smallest spread for the past 15 days, above average volume and a close towards the high with the bar in an uptrend.*/[/B]
    Sell = spread<=LLV(spread,15) AND V>Y AND C>mid AND C>=HHV(C,5);
    
    /*Going Short*/
    /*Short = Ref(C,-2)>Ref(C,-1) AND Ref(C,-1)>C AND Ref(C,-2)>C AND Ref(V,-2)<Ref(V,-1) AND Ref(V,-1)<V AND Ref(V,-2)<V;
    Cover = ApplyStop(stopTypeTrailing, stopModePercent, 2,0) ;*/
  2. Going long
    Backtest results from 01/01/09 to 20/02/09
    =====================

    Starting capital: $7500
    Ending capital: $6591.80
    Net Profit: -12.11%
    Trades Taken: 13
    Winners: 2 (15.38%) with an average win of $415.97
    Losers: 11 (84.62%) with an average loss of $158.19
    Max sys. % DD: -32.47%
    Risk/Reward: -21.46

    Backtest results from 01/09/08 to 20/02/09
    =====================

    Starting capital: $7500
    Ending capital: $7753.40
    Net Profit: 3.38%
    Trades Taken: 41
    Winners: 9 (21.95%) with an average win of $865.62
    Losers: 32 (78.05%) with an average loss of $235.54
    Max sys. % DD: -40.08%
    Risk/Reward: 6.13

    Backtest results from 01/01/08 to 20/02/09
    =====================

    Starting capital: $7500
    Ending capital: $4885.39
    Net Profit: -34.86%
    Trades Taken: 74
    Winners: 17 (22.97%) with an average win of $482.74
    Losers: 57 (77.03%) with an average loss of $189.85
    Max sys. % DD: -65.94%
    Risk/Reward: -2.43

    Experienced 100% DD after 24/01/2008 for the period of 01/01/2001 to 20/02/2009.​
  3. Going short
    I just changed sell signals to short and buy to cover.

    Backtest results from 01/01/09 to 20/02/09
    =====================

    Starting capital: $7500
    Ending capital: $8083.10
    Net Profit: 7.77%
    Trades Taken: 4
    Winners: 2 (50%) with an average win of $358.55
    Losers: 2 (50%) with an average loss of $67
    Max sys. % DD: -3.63%
    Risk/Reward: 33.89

    Backtest results from 01/09/08 to 20/02/09
    =====================

    Starting capital: $7500
    Ending capital: $9512.13
    Net Profit: 26.83%
    Trades Taken: 7
    Winners: 4 (57.14%) with an average win of $604.28
    Losers: 3 (42.86%) with an average loss of $135
    Max sys. % DD: -9.22%
    Risk/Reward: 10.7

    Backtest results from 01/01/08 to 20/02/09
    =====================

    Starting capital: $7500
    Ending capital: $11327.34
    Net Profit: 51.03%
    Trades Taken: 26
    Winners: 11 (42.31%) with an average win of $653.06
    Losers: 15 (57.69%) with an average loss of $223.76
    Max sys. % DD: -20.48%
    Risk/Reward: 6.51

    Experienced 73.71% loss from 01/01/2001 till 20/02/09​
 
Some more reading needed.
I think you'll also find that your entries and exits are also on the same day as they are triggered. unless you have a way of exiting intraday(And how do you know the final bar type untill close?) you should have both set at buy or sell delay of 1 bar as most EOD systems signal at the close of the day. This can dramatically alter the result of a system.

Another observation is that none of your sell signals conform to the condition
'Highest close in the last 90 days".

Flipping entry to exit and V versa is poor logic.

Yes, I just noticed it now when I went over my code. I'll fix it and test it!
 
Okay, I revised the way I shorted stocks. This updated code also allows you to change the number of days used to compare the current bar to previous bars, through the "Parameters" button in "Automatic Analysis" for amibroker. This way you won't have to play around with the code if you don't want to.

Code:
/*Variables*/
/***********/
W= Param("Number of bars to compare low (for Covering)", 5, 0, 100); /*The number of previous bars today's close will be compared to*/
X= Param("Number of bars to compare high (for Selling)", 5, 0, 100); /*The number of previous bars today's close will be compared to*/
Y=MA(Volume,10); /*Formula for Average Volume*/
Z= Param("Number of bars to compare size of spread", 15, 0, 100); /*The number of previous bars today's spread will be compared to*/
spread= H-L; /*Size of the spread*/
mid = L + spread/2; /*The midpoint of a bar*/


/*Going Long*/
/************/
/*Buy Condition: Three consecutive up-thrust days with successively increasing volume*/
Buy = Ref(C,-2)<Ref(C,-1) AND Ref(C,-1)<C AND Ref(C,-2)<C AND Ref(V,-2)<Ref(V,-1) AND Ref(V,-1)<V AND Ref(V,-2)<V;

/*Sell Condition #1: Three days where the close is sideways (+/- 5% of each other) and volume is successively decling but larger than average for the first two days*/
/*Sell =  (Ref(C,-2)<1.025*Ref(C,-1) AND Ref(C,-2)>0.975*Ref(C,-1)) AND (Ref(C,-2)<1.025*C AND Ref(C,-2)>0.975*C) AND (Ref(C,-1)<1.025*C AND Ref(C,-1)>0.975*C);*/

/*Sell Condition #2: Sell on the bar with the smallest spread for the past 15 days, above average volume and a close towards the high with the bar in an uptrend.*/
Sell = spread<=LLV(spread,Z) AND V>Y AND C>mid AND C>=HHV(C,X);

/*Going Short*/
/*************/
/*Short Condition: Three consecutive down-thrust days with successively increasing volume*/
Short = Ref(C,-2)>Ref(C,-1) AND Ref(C,-1)>C AND Ref(C,-2)>C AND Ref(V,-2)<Ref(V,-1) AND Ref(V,-1)<V AND Ref(V,-2)<V;

/*Cover Condition: Cover on bar with lowest close for X period, above average volume, small spread and with a close towards the low*/
Cover = spread<=LLV(spread, Z) AND V>Y AND C<mid AND C<=HHV(C,X);

Updated Backtesting Results for the SHORT ONLY version
Stop losses at 1% with trailing stops at 5%

Backtest results from 01/01/09 to 20/02/09
==================

Starting capital: $7500
Ending capital: $6231.80
Net Profit: -16.91%
Total Trades: 13
Winners: 3 (23.08%) with an average win of $334.13
Losers: 10 (76.92%) with an average loss of $227.06
Max sys. % DD: -24.54%
Risk/Reward: -46.15

Backtest results from 01/09/08 to 20/02/09
==================

Starting capital: $7500
Ending capital: $10141.88
Net Profit: 35.23%
Total Trades: 48
Winners: 16 (33.33%) with an average win of $1077.98
Losers: 32 (66.66%) with an average loss of $456.43
Max sys. % DD: -37.66%
Risk/Reward: 0.16

Backtest results from 01/01/08 to 20/02/09
==================

Starting capital: $7500
Ending capital: $11108.31
Net Profit: 48.11%
Total Trades: 86
Winners: 29 (33.72%) with an average win of $810.16
Losers: 57 (66.28%) with an average loss of $348.88
Max sys. % DD: -36.08%
Risk/Reward: 3.35​

The DD is still huge but at least its now turning a profit :)

EDIT: Tech I still haven't implemented the delays to buying/selling/covering/shorting. How do I do this in amibroker?
 
Suggest that you check out the settings that you apply. Consider the following...

1. buy on open (next day) and sell on close (next day)
2. buy on open (next day) and sell on open (next day)
3. adding a percentage trailing stop (see "Stops" under "Backtester settings"
4. adding an A-bar stop
5. setting maximum stop loss as a percentage

For example, try with 5% max loss stop and 5% trailing stop and 5 bars N-day stop.

What do you get. I ran again ASX200 from Jan 1 to today with your defaults and settings above and you

Example - Backtest ReportStatistics | Charts | Trades | Formula | Settings |
Symbols

Statistics
All tradesLong tradesShort trades
Initial capital7500.007500.007500.00
Ending capital8633.528633.527500.00
Net Profit1133.521133.520.00
Net Profit %15.11 %15.11 %0.00 %
Exposure %96.97 %96.97 %0.00 %
Net Risk Adjusted Return %15.59 %15.59 %N/A
Annual Return %185.32 %185.32 %0.00 %
Risk Adjusted Return %191.11 %191.11 %N/A



All trades1515 (100.00 %)0 (0.00 %)
Avg. Profit/Loss75.5775.57N/A
Avg. Profit/Loss %1.17 %1.17 %N/A
Avg. Bars Held3.003.00N/A



Winners6 (40.00 %)6 (40.00 %)0 (0.00 %)
Total Profit4049.974049.970.00
Avg. Profit675.00675.00N/A
Avg. Profit %8.56 %8.56 %N/A
Avg. Bars Held3.333.33N/A
Max. Consecutive330
Largest win1131.341131.340.00
# bars in largest win330



Losers9 (60.00 %)9 (60.00 %)0 (0.00 %)
Total Loss-2916.45-2916.450.00
Avg. Loss-324.05-324.05N/A
Avg. Loss %-3.75 %-3.75 %N/A
Avg. Bars Held2.782.78N/A
Max. Consecutive440
Largest loss-735.16-735.160.00
# bars in largest loss440



Max. trade drawdown-870.47-870.470.00
Max. trade % drawdown-8.50 %-8.50 %0.00 %
Max. system drawdown-1771.39-1771.390.00
Max. system % drawdown-17.02 %-17.02 %0.00 %
Recovery Factor0.640.64N/A
CAR/MaxDD10.8910.89N/A
RAR/MaxDD11.2311.23N/A
Profit Factor1.391.39N/A
Payoff Ratio2.082.08N/A
Standard Error588.75588.750.00
Risk-Reward Ratio31.0731.07N/A
Ulcer Index6.916.910.00
Ulcer Performance Index26.0526.05N/A
Sharpe Ratio of trades1.491.490.00
K-Ratio0.20950.2095-1.#IND

Tim

PS. buy and sell on open next day.
 
Tip #1

PS. Another tip.

What happens if you reduce number of days in spread from 15 to 10?

Hint: use the same settings as mentioned in prev post.

Tip #2

Learn to use optimizations in Amibroker to find best combination of variables.

Tim
 
Okay fellahs, I'm back again, this time with a slightly beefier system.

Code:
/*Variables*/
/***********/
T= SetOption("InitialEquity", 7500); /*Your starting capital*/
U= Param("What % of your capital are you willing to risk?", 1, 0, 100); /*The % of capital that is going to be risked per trade*/
W= Param("Number of bars to compare lowest close (for Covering)", 5, 0, 100); /*The number of previous bars today's close will be compared to*/
X= Param("Number of bars to compare highest close (for Selling)", 5, 0, 100); /*The number of previous bars today's close will be compared to*/
Y= MA(Volume,10); /*Formula for Average Volume*/
Z= Param("Number of bars to compare size of spread", 15, 0, 100); /*The number of previous bars today's spread will be compared to*/
risk= (U/100)*T; /*The $ value that is going to be risked per trade*/
spread= H-L; /*Size of the spread*/
mid= L + spread/2; /*The midpoint of a bar*/


/*Going Long*/
/************/
/*Buy Condition: Three consecutive up-thrust days with successively increasing volume*/
Buy = Ref(C,-2)<Ref(C,-1) AND Ref(C,-1)<C AND Ref(C,-2)<C AND Ref(V,-2)<Ref(V,-1) AND Ref(V,-1)<V AND Ref(V,-2)<V;

/*Sell Condition #1: Three days where the close is sideways (+/- 5% of each other) and volume is successively decling but larger than average for the first two days*/
/*Sell =  (Ref(C,-2)<1.025*Ref(C,-1) AND Ref(C,-2)>0.975*Ref(C,-1)) AND (Ref(C,-2)<1.025*C AND Ref(C,-2)>0.975*C) AND (Ref(C,-1)<1.025*C AND Ref(C,-1)>0.975*C);*/

/*Sell Condition #2: Sell on the bar with the smallest spread for the past 15 days, above average volume and a close towards the high with the bar in an uptrend.*/
Sell = spread<=LLV(spread,Z) AND V>Y AND C>mid AND C>=HHV(C,X);

/*Going Short*/
/*************/
/*Short Condition: Three consecutive down-thrust days with successively increasing volume*/
Short = Ref(C,-2)>Ref(C,-1) AND Ref(C,-1)>C AND Ref(C,-2)>C AND Ref(V,-2)<Ref(V,-1) AND Ref(V,-1)<V AND Ref(V,-2)<V;

/*Cover Condition: Cover on bar with lowest close for X period, above average volume, small spread and with a close towards the low*/
Cover = spread<=LLV(spread, Z) AND V>Y AND C<mid AND C<=LLV(C,X);

/*Timing the Trades*/
/*******************/
SetTradeDelays(1,1,1,1);
BuyPrice = Open;
SellPrice = Open;
ShortPrice = Open;
CoverPrice = Open;

/*Stop Losses & Position Size*/
/*****************************/
ApplyStop(0,2,Ref(C,-1),1); /*Apply a static stop loss at yesterday's close. If triggered, exit intraday*/
ApplyStop(2,2,Ref(mid,-1),1); /*Apply a trailing stop at the middle of the previous bar. If triggered, exit intraday*/
PositionSize = risk/(C-Ref(C,-1))*BuyPrice; /*The position size*/
SetOption("MaxOpenPositions", Optimize("MaxOpenPositions", 3, 1, 10, 1)); /*The maximum number of trades open at any one time. Optimizing.*/

What's New?
============

  • I've added the buy/sell/short/cover delays. All trades occur on the next day's open.
  • I've customised the stop losses and trailing stops. Read the comments in the code.
  • Added position sizing

Tcoates: The only bit that I've used optimize in is in determining the maximum number of open positions. I thought that optimizing systems was a no no as this would just fit the system to historical data?

EDIT: Well, as soon as I added it I found a problem! :( It looks like the stop losses keep moving (like a trailing stop). I need a way to keep them static! Will post a fix later.
 
Good Luck :)

Offtopic: Is it true that if i am ages under 21 years i can start an IB account with just 3,000 USD? This is good news!

Do they enforce the 100 trade rule?

Where did you find this information?
Thanks!
 
Good Luck :)

Offtopic: Is it true that if i am ages under 21 years i can start an IB account with just 3,000 USD? This is good news!

Do they enforce the 100 trade rule?

Where did you find this information?
Thanks!

The 100 trade rule is not enforced.
Neither is anything else.
I told them that my net worth was in the millions :D
 
Top