PureBytes Links
Trading Reference Links
|
Ed,
Thanks so much for your help to the programming illiterate. I would
have never thought it's so complicated, just thought I miss
something really simple. Well, thanks even more.
Sam
--- In amibroker@xxxxxxxxxxxxxxx, "Edward Pottasch" <empottasch@xxx>
wrote:
>
> hi
>
> I fabricated something that doesn't make use of the barssince
function since I didn't get it to work in a hurry. Code below does
the following:
>
> I calculates the positionScore on the close at a thursday then it
enters a trade at the open on a friday and closes this trade on the
open on a thrursday at least 22 bars after entry,
>
> (you will need the latest version of Amibroker for this because of
the break function).
>
> rgds, ed
>
>
>
> SetBarsRequired(10000,10000);
> SetOption("MaxOpenPositions", 1 );
> PositionSize = -100;
> SetTradeDelays(0,0,0,0);
> PositionScore = IIf( Ref(ROC(C,15),-1) > 0, Ref(ROC(C,15),-1), 0);
>
> procedure sell_proc(Buy,Sellday) {
>
> global Sell;
> global SellPrice;
> SellPrice = 0;
> Sell = 0;
>
> // sell delay in bars
> selldelay = 22;
>
> for (i = 1; i < BarCount; i++)
> {
>
> if (Buy[ i ])
> {
>
> for (j = i + selldelay; j < BarCount; j++)
> {
>
> if (Sellday[ j ])
> {
>
> Sell[ j ] = 1;
>
> i = j;
> break;
>
> }
>
> }
>
> }
>
> }
>
> }
>
>
> Buy = DayOfWeek() == 5;
> BuyPrice = O;
>
> sell_proc(Buy,DayOfWeek() == 4);
> SellPrice = O;
>
> SetChartOptions(0, chartShowDates);
> GraphXSpace = 5;
> Plot(C,"C",1,64);
>
> PlotShapes(IIf(Buy,shapeUpArrow,0),colorWhite, layer = 0,
yposition = BuyPrice, offset = 0 );
>
>
>
>
>
> ----- Original Message -----
> From: samu_trading
> To: amibroker@xxxxxxxxxxxxxxx
> Sent: Sunday, October 14, 2007 7:44 AM
> Subject: [amibroker] Code Question: buy best performing ticker
of last 15 days
>
>
> How could I code this for backtesting in AB?
>
> Buy on Friday the ticker symbol with the best performance of the
last
> 15 trading days.
>
> Sell 5 weeks later
>
> Thanks, Samantha
>
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|