[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Backtesting exits with discretionary entry



PureBytes Links

Trading Reference Links





Here is another application for the StrExtract and 
StrToNum functions.  There was a recent question about Backtesting 
Exits with discretionary Buys to which I believe Herman provided a 
solution.  This is just an alternative method.  If you read my 
previous post  - Stock Specific Indicator 
Settings - you have an idea of where this post is headed.  Again we need to 
construct a comma separated list, this time the format is <FONT 
color=#008000>"Ticker1,BuyDate1,BuyPrice1,Ticker2,BuyDate2,BuyPrice2, 
...etc".  In this example,  I'm testing a 
simple sell strategy on EOD data so I've incorporated a one day delay on the 
sell only.  Backtest or Explore and check the 
results.
<FONT 
color=#000000>Andrew
 
 
// Backtesting exits with discretionary entry - by Andrew 
Perrin
// Build your discretionary entry list - 
"Ticker1,BuyDate1,BuyPrice1,Ticker2,BuyDate2,BuyPrice2, etc"
// Where BuyDate is in DateNum format.
DiscretionEntryList = <FONT 
color=#ff00ff>"NAB,1030729,32.41,ANZ,1030522,18.21,CBA,1030523,27.51,NAB,1030626,33.61";
Buydate = 0;
price = 0;
Buy = 0;
for( i = 0; ( sym = <FONT 
color=#0000ff>StrExtract( DiscretionEntryList, i ) ) != <FONT 
color=#ff00ff>""; i=i+3)
{
if(Name()==sym)
{
BuyDate = StrToNum(<FONT 
color=#0000ff>StrExtract(DiscretionEntryList, i+<FONT 
color=#ff00ff>1));
IndexofBar = LastValue(<FONT 
color=#0000ff>ValueWhen(BuyDate==<FONT 
color=#0000ff>DateNum(),BarIndex()));
Price = StrToNum(<FONT 
color=#0000ff>StrExtract(DiscretionEntryList, i+<FONT 
color=#ff00ff>2));
Buy[IndexOfBar] = 1;
BuyPrice[IndexOfBar] = price;
}
}
Sell = C < Ref(<FONT 
color=#0000ff>LLV(L,3),-<FONT 
color=#ff00ff>1);
SetTradeDelays(0,<FONT 
color=#ff00ff>1,0,<FONT 
color=#ff00ff>0);
PositionSize = -50;
Filter = Buy;
AddColumn(BuyPrice,<FONT 
color=#ff00ff>"");






Yahoo! Groups Sponsor


  ADVERTISEMENT 









Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.