Australian (ASX) Stock Market Forum

Combining Equity Curves in Amibroker

Joined
12 April 2009
Posts
16
Reactions
4
Hi All,
This is just one of many ways you may use or not , to produce an equity curve

  1. // YOUR TRADING SYSTEM HERE
  2. // ....
  3. SetCustomBacktestProc("");
  4. if( Status("action") == actionPortfolio )
  5. {
  6. bo = GetBacktesterObject();
  7. bo.Backtest();

  8. AddToComposite( bo.EquityArray,"~~~MY_EQUITY_COPY",
  9. "X",atcFlagDeleteValues | atcFlagEnableInPortfolio );
  10. }
And so combing them together may be this

/ Create an array of the individual equity curves
equityCurves = {Equity1, Equity2, Equity3, Equity4};
// Use the PortfolioBacktest() function to combine the equity curves into a single portfolio equity curve
portfolioEquityCurve = PortfolioBacktest(equityCurves, 1, 1);
// Plot the portfolio equity curve
Plot(portfolioEquityCurve, "Portfolio Equity", colorBlue);

PortfolioBacktest function will assume equal weighting for all equity curves. If you want to assign different weight to each strategy you can use the PortfolioBacktestW() function.

How do we use the PortfolioBacktestW() , to weigh all the individual equity curves ?

Example , (A) has 500 trades with 18% drawdown
(B) has 200 trades with 8% drawdown
if those are the two criteria that you may use out of the gzillions of criteria available with a equity curve


would anyone be able to suggest a " weighing " a codable formula to be able to use the PortfolioBacktestW() function .

Any thougrghts , comments opinions all welcomed

cheers

michael b
 
Hi All,
This is just one of many ways you may use or not , to produce an equity curve

  1. // YOUR TRADING SYSTEM HERE
  2. // ....
  3. SetCustomBacktestProc("");
  4. if( Status("action") == actionPortfolio )
  5. {
  6. bo = GetBacktesterObject();
  7. bo.Backtest();

  8. AddToComposite( bo.EquityArray,"~~~MY_EQUITY_COPY",
  9. "X",atcFlagDeleteValues | atcFlagEnableInPortfolio );
  10. }
And so combing them together may be this

/ Create an array of the individual equity curves
equityCurves = {Equity1, Equity2, Equity3, Equity4};
// Use the PortfolioBacktest() function to combine the equity curves into a single portfolio equity curve
portfolioEquityCurve = PortfolioBacktest(equityCurves, 1, 1);
// Plot the portfolio equity curve
Plot(portfolioEquityCurve, "Portfolio Equity", colorBlue);

PortfolioBacktest function will assume equal weighting for all equity curves. If you want to assign different weight to each strategy you can use the PortfolioBacktestW() function.

How do we use the PortfolioBacktestW() , to weigh all the individual equity curves ?

Example , (A) has 500 trades with 18% drawdown
(B) has 200 trades with 8% drawdown
if those are the two criteria that you may use out of the gzillions of criteria available with a equity curve


would anyone be able to suggest a " weighing " a codable formula to be able to use the PortfolioBacktestW() function .

Any thougrghts , comments opinions all welcomed

cheers

michael b
// Define the equity curves to be included in the portfolio
EquityCurve1 = Backtest(strategy1);
EquityCurve2 = Backtest(strategy2);
EquityCurve3 = Backtest(strategy3);

// Calculate the drawdown percentage and total trades for each equity curve
Drawdown1 = DrawDown(EquityCurve1);
Trades1 = TotalTrades(EquityCurve1);
Drawdown2 = DrawDown(EquityCurve2);
Trades2 = TotalTrades(EquityCurve2);
Drawdown3 = DrawDown(EquityCurve3);
Trades3 = TotalTrades(EquityCurve3);

// Assign weighting to each equity curve based on drawdown and total trades
Weight1 = (1 - Drawdown1/100) * (1 - Trades1/1000);
Weight2 = (1 - Drawdown2/100) * (1 - Trades2/1000);
Weight3 = (1 - Drawdown3/100) * (1 - Trades3/1000);

// Use PortfolioBacktestW to create a portfolio of the equity curves
Portfolio = PortfolioBacktestW(EquityCurve1, EquityCurve2, EquityCurve3, Weight1, Weight2, Weight3);

// Plot the portfolio equity curve
Plot(Portfolio, "Portfolio", colorBlue);
 
Top