Hello Everyone
I wish I have bought Amibroker the first day of my trading career.
Incredible piece of software. Loving it.
Quick question:
Say we divide bull/bear market with a simple 150d sma on SPY.
How can we merge a rotational long only strategy for the bull market with a non rotational one for the bear market with specific buy and sell rules?
Reference:
http://www.amibroker.com/kb/2016/04/17/long-only-rotational-back-test/
“Since there are no signals used, only PositionScore assigned to given symbol matters.”
Not trying to alter the position score here, but to have two separate strategies so that we can control the buy and sell signals in the non-rotational one.
Can we merge them both? How?
Here are the code samples:
Market definition / Strategy Switch:
Index = Foreign("SPY","C",True);
IndexMA = MA(Index, 150);
BullMarket = Index >= IndexMA;
BearMarket = Index < IndexMA;
Strategy 1: Long Only Rotational
SetBacktestMode( backtestRotational );
SetOption("MaxOpenPositions",5);
SetOption("WorstRankHeld",5);
SetPositionSize( 20, spsPercentOfEquity );
PositionScore = 1000 + ROC( Close, 252 ); // make sure it is positive by adding big constant
Strategy 2: Bear Only Non-Rotational
if( Name() == "TLT" )
{
PositionSize = -100;
Buy = Cross( IndexMA, Index );
Sell = Cross( Index, IndexMA );
}