Dear All,
I have been paying around with the idea of implementing a simple equity curve trading technique, in order to establish which of my systems is more syncronized with the market I am trading. Basically I would like to switch on/off a system, based on the equity curve crossing below or above its 30 trades MA.
Any idea of how this could be done in Amibroker?
Thanks for the help.
Br
Davide
Howard did this a while back.
Try it on a single equity.
///////////////////////////////////////////
// EquityCurveFeedback.afl
//
// Howard Bandy
// November 2011
//
// There are many ways to use the equity
// in the trading account, and its variation,
// to act as a filter to allow or block trades.
//
// This code shows one example of applying
// trading system logic to the equity curve
// created by another trading system.
//
// The first system is a simple moving
// average crossover ”” it could be any system.
//
MALength1 = 5; //Optimize(“MALength1?,5,2,50,2);
MALength2 = 1; //Optimize(“MALength2?,1,1,51,2);
Buy = Cross( MA( C, MALength1 ), MA( C, MALength2 ) );
Sell = Cross( MA( C, MALength2 ), MA( C, MALength1 ) );
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );
e = Equity();
Plot( C, “C”, colorBlack, styleCandle );
PlotShapes( Buy*shapeUpArrow + Sell*shapeDownArrow,
IIf( Buy, colorGreen, colorRed ) );
Plot( e, “Equity”, colorGreen, styleLine | styleLeftAxisScale );
// The equity curve is choppy.
// If there are positive serial correlations
// between daily equity values, then we expect
// up days to be followed generally by more up days,
// and down days by more down days.
// So we might try applying a trend following system
// to the equity curve.
// When the equity curve is above its moving average,
// the system is working, and we should take trades.
// When the equity curve is below its moving average,
// the system is out-of-sync, and we should block trades.
// EquityMALength is the lookback period for the equity
// curve moving average.
// We will set Pass to either 0 or 1.
// Pass==0 blocks trades, Pass==1 allows trades.
EquityMALength = 6; //Optimize( “EquityMALength”, 6, 2, 20, 1 );
EquityMA = DEMA( e, EquityMALength );
Plot( EquityMA, “equityMA”, colorBrightGreen, styleLine | styleLeftAxisScale );
Pass = IIf( e >= EquityMA, 1, 0 );
Buy = Buy AND Ref(Pass,-1);
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );
e1 = Equity();
Plot( e1, “FilteredEquity”, colorBlue, styleLine | styleLeftAxisScale );
///////////////////////// end ///////////////////////////