PureBytes Links
Trading Reference Links
|
David,
Thanks again for your feedback. I tried various ways of converting
your AFL script to something that could be used to SCAN; gave up on
that approach, and came up with something quite simple but effective.
The script I am using is simply:
AddColumn( 100-RSI(), "Rank", 1.5 );
Buy=1;
Filter=Buy;
Given that I want to find the most highly ranked funds on a Friday,
the script is used after updating prices following Thursday's close
and before Friday's close. Using Explore rather than Scan,
with "Apply to all symbols", and Range: "n last days" (n=1), a list
is generated in which every stock / fund is listed along with its
Rank. The list can then be sorted automatically according to Rank.
If the EnableRotationalTrading backtest script which is being
simulated has a SetOption("WorstRankHeld", n), then you have to
manually determine whether the stock(s) or fund(s) held is/are above
or below the rank cutoff point, and use that information to decide
whether to hold or rotate.
This is not particularly elegant, but it works!
It does highlight, however, one of the fundamental issues I have with
the logic of Amibroker. Before using the program, I had imagined that
there would be a smooth transition from script development (using
Backtester and Optimize) to the deployment of that script in
recommending trades in real time. This is clearly not the case for
rotational trading, and has also been an issue with several other
scripts that I have tried.
Regards,
David
--- In amibroker@xxxxxxxxxxxxxxx, "dweilmuenster95125"
<dweilmuenster95125@xxxx> wrote:
> David, that's a puzzler. I hadn't gotten so far as to trade a
> rotational system in real time. Was only doing some research so
> only used Backtester.
>
> Is it possible that you would never get a signal with
> > > weekend = DayOfWeek()>Ref(DayOfWeek(),1);
> because for today (whatever today is), the database has no entry to
> examine as Ref(dayofweek(),1)? I.e., if today is Monday, the
script
> can't look for Tuesday to see the value of dayofweek()?
>
> Maybe
> > > weekend = DayOfWeek()=7 (or whatever the right value is for
> Friday);
>
> would give Scan results, with the obvious caveat to lookout for
> weeks that end on other than Friday.
>
> David
>
>
> --- In amibroker@xxxxxxxxxxxxxxx, "David Nowotnik" <dnowotnik@xxxx>
> wrote:
> > David,
> >
> > When I got fairly good results from the BackTest of your final
> > version of "Weekly Portfolio Re-Balancing" I was keen to employ
> the
> > script in real-life; i.e. for it to recommend which funds to
> switch
> > to each Friday before the close (as a reminder, I am using it
with
> a
> > fund family, in which I hold 2 funds at one time). As
> > EnableRotationalTrading works for Backtester only, I assumed that
> > running the script in Backtester on a Friday would give me the
> > recommended funds that day. But instead, it ignored the end of
> week
> > signal that it should have received on a Friday, and continued to
> > hold the funds from the previous Friday. The signal was also
> ignored
> > on Saturday and the following Monday!
> >
> > Presumably, therefore, Backtester cannot be used to 'scan', and
as
> > EnableRotationalTrading works for Backtester only, a completely
> > different script is required to 'select' the top (using
> > PositionScore) funds on a Friday. Do you have a working 'Scan'
> script
> > which performs the "Weekly Portfolio Re-Balancing" strategy?
> >
> > Thanks,
> > David
> >
> >
> > --- In amibroker@xxxxxxxxxxxxxxx, "dweilmuenster95125"
> > <dweilmuenster95125@xxxx> wrote:
> > > Hi, yes, someone tipped me to an approach which goes like this
> > > (omitting extraneous details):
> > >
> > > EnableRotationalTrading();
> > >
> > > weekend = DayOfWeek()>Ref(DayOfWeek(),1);
> > >
> > > PositionScore = IIf(weekend,100-rsi(2),scorenorotate);
> > >
> > >
> > > Hope that helps with what you're trying to do.
> > >
> > >
> > > Regards,
> > > David
> > >
> > >
> > >
> > >
> > > --- In amibroker@xxxxxxxxxxxxxxx, "David Nowotnik"
> <dnowotnik@xxxx>
> > wrote:
> > > > David,
> > > >
> > > > Did you get response to this question, as I would also like
to
> > > > develop a script which performs rotational trading but is not
> > limited
> > > > by what EnableRotationalTrading() does and does not appear to
> > allow?
> > > >
> > > > I assume that the problem is that there is no option to
> > > > AllowSameBarEntry, equivalent to AllowSameBarExit. So an exit
> > cannot
> > > > trigger the next entry even when Buy is true, but instead,
you
> > have
> > > > to wait for the next bar in which a Buy condition is met.
> > > >
> > > > I tried many variations to your script (I'm sure you did
too),
> to
> > no
> > > > avail. The closest was to delay the buy to the first day of
> the
> > week
> > > > following the sale:
> > > >
> > > > weekend = DayOfWeek()>Ref(DayOfWeek(),1);
> > > > FirstDay = DayOfWeek()==1;
> > > >
> > > > RSI2 = RSIa(C,2);
> > > > PositionScore = 100-RSI2;
> > > >
> > > > Buy = FirstDay;
> > > > Sell = weekend;
> > > >
> > > > Regards,
> > > > David
> > > >
> > > > --- In amibroker@xxxxxxxxxxxxxxx, "dweilmuenster95125"
> > > > <dweilmuenster95125@xxxx> wrote:
> > > > >
> > > > > I am trying to set up a portfolio backtest to:
> > > > >
> > > > > - Buy on the last trading day of each week the top 2
> equities
> > in a
> > > > > watchlist, ranked by 100-RSI(2).
> > > > >
> > > > > - Sell those 2 equities on the last trading day of the
next
> > week,
> > > > and
> > > > > replace them with 2 equities that satisfy the above rule.
> > > > >
> > > > > (Note: EnableRotationalTrading() doesn't do the trick,
> because
> > > > > I want to exit unconditionally at the end of the following
> > week, not
> > > > > because the current positions fall below a positionrank
> > threshhold.)
> > > > >
> > > > > I'm using the code below, and it almost works. Problem is
> that
> > it
> > > > > skips every other week. E.g., starting at the beginning of
> > 2002, it
> > > > > buys two stocks on 1/4/2002, and sells them on 1/11/2002.
> But
> > it
> > > > > doesn't buy anything on 1/11/2002. Instead, it buys 2
> stocks
> > again
> > > > on
> > > > > 1/18/2002, and sells them on 1/25/2002. Doesn't buy
> anything on
> > > > > 1/25/2002. But, it buys 2 stocks on 2/1/2002, and sells
> them on
> > > > > 2/8/2002. Etc.
> > > > >
> > > > > Suggestions?
> > > > >
> > > > > Thanks,
> > > > > David
> > > > >
> > > > > ------------------------------------------------------------
-
> > > > >
> > > > >
> > > > > SetOption("InitialEquity",100000);
> > > > > SetOption("CommissionMode",1);
> > > > > SetOption("CommissionAmount",0);
> > > > > SetOption("MaxOpenPositions",2);
> > > > > SetOption("MarginRequirement",100);
> > > > > SetOption("UsePrevBarEquityForPosSizing",False);
> > > > > SetOption("AllowPositionShrinking" , True);
> > > > > SetOption("AllowSameBarExit",False);
> > > > > SetTradeDelays(0,0,0,0);
> > > > > BuyPrice = C;
> > > > > SellPrice = C;
> > > > > SetPositionSize(50,spsPercentOfEquity);
> > > > > RoundLotSize = 10;
> > > > >
> > > > > weekend = DayOfWeek()>Ref(DayOfWeek(),1);
> > > > >
> > > > > RSI2 = RSIa(C,2);
> > > > > PositionScore = 100-RSI2;
> > > > >
> > > > >
> > > > > Buy = weekend;
> > > > > Sell = weekend;
------------------------ Yahoo! Groups Sponsor --------------------~-->
Try Online Currency Trading with GFT. Free 50K Demo. Trade
24 Hours. Commission-Free.
http://us.click.yahoo.com/DldnlA/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~->
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 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/
<*> 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/
|