Засунуть в папку AmiBroker\Formulas\Equity
Имя Individual.afl
#include @LastBacktestFormula
MaxGraph=0;GraphXSpace=5;
GraphZOrder=1;
Plot( Equity( 0, -2 ), "Equity", -8, styleArea );
if( ParamToggle("Show Buy-and-Hold?", "No|Yes", 1 ) )
{
/* now buy and hold simulation */
Short=Cover=0;
Buy=Status("firstbarintest");
Sell=Status("lastbarintest");
SetTradeDelays(0,0,0,0); PositionSize = -100;
ApplyStop(0,0,0,0);
ApplyStop(1,0,0,0);
ApplyStop(2,0,0,0);
Plot( Equity( 0, -2 ), "Buy&Hold", -9 );
}
Имя IS and OOS Equity.afl
PlotForeign("~~~ISEQUITY","In-Sample Equity", colorRed, styleLine);
PlotForeign("~~~OSEQUITY","Out-Of-Sample Equity", colorGreen, styleLine);
Title = "{{NAME}} - {{INTERVAL}} {{DATE}} {{VALUES}}";
Имя Portfolio.afl
eq = Foreign("~~~EQUITY", "C");
cash = Foreign("~~~EQUITY", "L");
dr = eq - Highest(eq);
bslh = HighestBars(eq);
GraphZOrder=1;
Plot(eq, "Portfolio Equity", colorLightBlue, styleArea );
if( ParamToggle("Show Cash", "No|Yes", 1 ) ) Plot(cash, "Cash", colorGreen, styleArea );
if( ParamToggle("Show Drawdown", "No|Yes", 1 ) ) Plot(dr, "Drawdown", colorDarkRed, styleArea );
if( ParamToggle("Show #bars since last high", "No|Yes", 0 ) ) Plot(bslh, "#bars since last high", colorDarkYellow, styleLine | styleOwnScale, 0, 10 * LastValue( Highest( bslh ) ) );
islastbar = Status("lastbarintest");
isfirstbar = Status("firstbarintest");
bar = BarIndex();
firstbar = LastValue( ValueWhen( isfirstbar, bar ) );
lastbar = LastValue( ValueWhen( islastbar, bar ) );
al = LastValue( ValueWhen( islastbar, LinRegSlope( eq, Lastbar - firstbar + 1 ) ) );
bl = LastValue( ValueWhen( islastbar, LinRegIntercept( eq, Lastbar - firstbar + 1 ) ) );
Lr = al * ( BarIndex() - firstbar ) + bl;
Lr = IIf( bar >= firstbar AND bar <= lastbar , Lr, Null );
if( ParamToggle("Show lin. reg.", "No|Yes", 0 ) )Plot( Lr , "Linear Reg", colorRed, styleThick );