AFL Strategy Description:
EOD data portfolio-level backtest with user-specified daily, weekly, monthly, or n months rebalance.
There is a universe of approximately 100 symbols.
There are up to 10 user-defined sectors.
The user begins by defining sectors and assigning each symbol in the universe to a sector. Sector assignments are persistent between tests.
The user specifies a sector allocation as a percentage of the total portfolio $ (e.g., sector 1 = 10% target allocation; sector 2 = 12%).
The user also defines a maximum number of positions for each sector (e.g., sector 1 maxPositions = 3; sector 2 maxPositions = 4).
The user defines a simple binary permission screen (e.g. if symbol > 200d SMA, permission = true). This allows a symbol to be bought or held. When false, a position is to be sold
The user defines a simple price strength indicator (e.g., strength = 30d price change + 90 day price change + 180 day price change).
At the rebalance period, (specified in the setup above), the strategy:
- Calculates the binary permission screen for each symbol
- Calculates the strength indicator for each symbol
- For each sector, calculates the dollars allocated to it. Sector $ = total portfolio $ * sector allocation % (sector allocation % defined above)
- For each position, size of the position $ = Sector $ / maxPositions
- For each sector, rebalances by selecting the top maxPosition symbols by strength rank order AND binary permission screen.
- If a top strength-ranked symbol DOES NOT have permission screen, pass down the rank list to the next highest strength score. If there is less than maxPositions symbols which pass the permission screen in the sectors, hold the remainder of positions as cash
- Buy and sell according to this policy on the NEXT open, high, low or close (user specified)
In Amibroker, download WEEKLY price history for n ETFs from Yahoo (let's say n = 9 here). I should be able to specify a list of 9 ETFs to download and you provide the ability to do so in Amibroker.
At each bar:
*For each ETF, calculate the McGinley Dynamic (MD is a smoothed MA - I will provide the version I would like you to calculate, because there are incorrect versions out there)
*If the weekly close is above the MD, BUY on the NEXT open, high, low or close. Position size = total capital/n.
*If the weekly close is below the MD, have 2 options: 1)hold cash = total capital/n OR 2)SELL SHORT on the NEXT open, high, low or close. Position size again = total capital/n.
Hi! I am proffesionall programmer for Metatrader,TradeStation, Multicharts, Amibroker API, InteractiveBrokers API, C++, VB for more than 10 years. Best regards, Alexander