Friday, March 30, 2007

Limiting the number of trades per week



Using some code Shutty found on Yahoo I was able to see the impact of limiting the maximum number of trades per week. I added the code in did an optimise and exported the results to Excel to get the graph above.

For a longer term system, like the one used for this test, it is possible to limit the number of buys to one per week and still get reasonable results.

With a shorter term system limiting the number of trades per week would have a bigger impact since the system needs to trade more - see the results for a 4 week system below.

5 comments:

Anonymous said...

Stevo, Could you please post a link to the code or the code itself that you used for the Limiting the number of trades per week.

stevo said...

Hopefully this posts ok.

// Maximum buys in a period
//-----------------------------
SetCustomBacktestProc("");
Num = Optimize("MaxBuys",4,0,9,1);
MaxBuys = Num;

if( Status("action") == actionPortfolio ) {

bo = GetBacktesterObject();
bo.PreProcess();

for( i = 0; i < BarCount; i++ ) {
cntBuys = 0;
for( sig = bo.GetFirstSignal(i); sig; sig = bo.GetNextSignal(i) ) {
if( sig.IsEntry() ) {
if( cntBuys > MaxBuys - 1 ) {
sig.PosSize = 0;
} else {
cntBuys = cntBuys + 1;
}
}
}
bo.ProcessTradeSignals( i );
}
bo.PostProcess();
}
//-----------------------------

Anonymous said...

Hi Stevo,

Could you please post the part that limits the number of signals taken per week.The code you posted if I am not mistaken only limit the number of buys on a daily basis.
I understand if you are not willing to post the entire code,if this is the case could you just give me the logic you used?

For another example of limiting the number of buys per day see the link below to a code written by Tomasz Janeczko.

http://www.mail-archive.com/amibroker@yahoogroups.com/msg19841.html

Cheers,

stevo said...

Since I set time frame to weekly the code above limits the number of buys in a week. I pretty much only use weekly charts.

regards
stevo

Anonymous said...

Thank you Stevo

Regards,

Mike