Australian (ASX) Stock Market Forum

Amibroker code - Rotational Trading - Frank Hassler

Joined
6 October 2011
Posts
107
Reactions
126
I have seen the following article http://systemtradersuccess.com/rotational-trading-a-simple-but-powerful-concept/

I am using a trial of the Amibroker charting software to see whether I can support my trading and have been investigating some trading systems to see how they work - objective to do some paper trading as well as backtesting.

The Rotaional Trading system in the above is developed by Frank Hassler. He has posted the following code

Code:
SetCustomBacktestProc(“formulas\\include\\cbt_midlevel.afl”,True);
SetOption(“CommissionAmount”,0.0);
SetOption(“MaxOpenshort”,0);
SetOption(“MaxOpenLong”,5);
SetOption(“MaxOpenPositions”,5);
SetPositionSize( 20, spsPercentOfEquity);
SetTradeDelays(0,0,0,0);
SetBacktestMode(backtestRotational);
EnableRotationalTrading() ;
idx           = Foreign(“QQQQ”,”Close”);
score         = TSI();
Score         = IIf(idx>MA(idx,200) OR idx>MA(idx,30),score,0);
PositionScore = IIf(Year()>=2001 AND DayOfWeek()==2,score,scoreNoRotate);

However when I run this afl I get stuck at

Code:
SetCustomBacktestProc(“formulas\\include\\cbt_midlevel.afl”,True);

I have tried to google to find code for "cbt_midlevel.afl".

Any help will be appreciated.
 
I have seen the following article http://systemtradersuccess.com/rotational-trading-a-simple-but-powerful-concept/

I am using a trial of the Amibroker charting software to see whether I can support my trading and have been investigating some trading systems to see how they work - objective to do some paper trading as well as backtesting.

Any help will be appreciated.

Hi

I'm not a lot further down the road than you, but as well as your missing file you will need to change the code from EnableRotationalTrading to SetBacktestMode( backtestRotational ).
-------------------------------------------------------------------------------------------------
I've downloaded and adjusted the sample code for scaling Rotational trades. I'd like to force the AFL to run once at the start of the month (or 3 months). Tried using TimeFrameSet(InMonthly) which has an effect but not the intended outcome.

SetBacktestMode(BacktestRotational);
//TimeFrameSet(inMonthly);
//EnableRotationalTrading();
EachPosPercent = 5;

PositionScore = 1000 + ROC( C, 6);

PositionSize = -EachPosPercent;

SetOption("WorstRankHeld", 8 );
SetOption("MaxOpenPositions", 4 );

SetOption("UseCustomBacktestProc", True );

if( Status("action") == actionPortfolio )
{
bo = GetBacktesterObject();

bo.PreProcess(); // Initialize backtester

for(bar=0; bar < BarCount; bar++)
{
bo.ProcessTradeSignals( bar );

CurEquity = bo.Equity;

for( pos = bo.GetFirstOpenPos(); pos; pos = bo.GetNextOpenPos() )
{
posval = pos.GetPositionValue();

diff = posval - 0.01 * EachPosPercent * CurEquity;
price = pos.GetPrice( bar, "O" );

if( diff != 0 AND
abs( diff ) > 0.005 * CurEquity AND
abs( diff ) > price )
{
bo.ScaleTrade( bar, pos.Symbol, diff < 0, price, abs( diff ) );
}
}
}
bo.PostProcess(); // Finalize backtester
}
//TimeFrameRestore();

Help would be appreciated.
 
Greetings --

In my research and experience, it is essentially impossible to develop, test, and validate any system that uses monthly data. Financial data is notoriously non-stationary. Characteristics of the data change over the development period. There are just too few data points.

If a system is developed, carefully assess the risk of drawdown. Even for positions that are eventually profitable at the end of months-long holding periods (using any data periodicity), the intra-trade drawdown may exceed your personal risk tolerance.

Best regards,
Howard
 
Greetings --

In my research and experience, it is essentially impossible to develop, test, and validate any system that uses monthly data. Financial data is notoriously non-stationary. Characteristics of the data change over the development period. There are just too few data points.

If a system is developed, carefully assess the risk of drawdown. Even for positions that are eventually profitable at the end of months-long holding periods (using any data periodicity), the intra-trade drawdown may exceed your personal risk tolerance.

Best regards,
Howard

Hello Howard

About 18 months ago I read a post on a trading website which led me to Mebane Faber, then on to Quantitative Trading Systems via rotational trading (and I did note the addition to the second edition), and then on to Amibroker. A main driver was the desire to find some way to deal intelligently with funds inside a pension fund which incur horrendous trading costs. Having got this close to the nub it's quite amusing in its' own way to hear the message 'Don't bother' (I know that's not exactly what you said, but I'm a realist).

Thanks very much indeed for the heads up, that's valuable information. It's been an interesting journey, and the learning isn't wasted.

Best regards
 
Top