PureBytes Links
Trading Reference Links
|
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;
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/
|