Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

Backtest Framework for Amibroker (AFL)
.OMAR.
over 13 years ago
Amibroker (AFL)

Rating:
3 / 5 (Votes 3)
Tags:
trading system, amibroker, exploration

This is a backtesting framework with a nice moving average crossover example.

Similar Indicators / Formulas

OPTIMIZED ICHIMOKU
Submitted by ritesh.bafna88 over 11 years ago
Reaction Trend System
Submitted by ajayjain90 almost 14 years ago
Behgozin Strength Finder
Submitted by hotaro3 over 11 years ago
KPL with RSI
Submitted by pdkg_gal almost 14 years ago
Intraday Trend Break System
Submitted by nishantndk almost 14 years ago
ema crossovers
Submitted by rushee.g1100 almost 14 years ago

Indicator / Formula

Copy & Paste Friendly
_SECTION_BEGIN("Framework_Template");
/////////////////////////////////////////////////////////////////////
///////////////Start - Backtest Framework Parameters/////////////////
/////////////////////////////////////////////////////////////////////

//Init
	SetBarsRequired(10000,10000); 

// Backtest settings
	//	Set AA options: 
	//	Set Apply to = [Use Filter] Market = ASX, Exclude Indexes
	//	Set Range = 1/1/1997 to 1/1/2007

// Trading Style Parameters
	//	Set AA options: 
	//	Set Positions = Long
	//	Set Periodicity = Daily

// Locked Comparison Parameters
	SetOption("InitialEquity", 100000 );
	SetOption("CommissionMode", 2 );
 	SetOption("CommissionAmount", 30.00 );
	BuyPrice = High;
	SellPrice = Low;
	ShortPrice = Low;
	CoverPrice = High;
	
// Minimum method parameters
	SetTradeDelays(1,1,1,1);

// Trading method parameters
	SetOption("FuturesMode", False ); 
	SetOption("AllowSameBarExit", False ); 
	SetOption("AllowPositionShrinking", False );
	SetOption("ReverseSignalForcesExit", True );
	SetOption("PriceBoundChecking", True );
	SetOption("UsePrevBarEquityForPosSizing", False );
	
	RoundLotSize = 1;
	PositionSize = 5000;

// Portfolio Settings
	SetOption("MaxOpenPositions", 10 ); 
	//	Set AA options: 
	//	Set Limit trade size as % of entry bar volume = 10
	//	Set Disable trade size limit when bar Volume is zero = False

/////////////////////////////////////////////////////////////////////
///////////////End - Backtest Framework Parameters///////////////////
/////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////
///////////////Start - Trading method code///////////////////////////
/////////////////////////////////////////////////////////////////////
//
// System: EMaCross
//
/////////////////////////////////////////////////////////////////////

// Optimize Parameters 
	Short_EMA_Var = Optimize("Short_EMA_Variable",6,1,10,1);
	Long_EMA_Var = Optimize("Long_EMA_Variable",73,30,100,1);

// Stock Selection
	//Buy only if PositionSize is 10% or less than 3 months average turnover.
	Turnover_Filter = (MA((Volume * C),60)*.10) > PositionSize; 

	//Set the order for which stock trades when get mulitple signals in one bar in backtesting
	PositionScore = 100-RSI(); // prefer stocks that have low RSI;

// Signal
	Long_EMA = EMA( Close, Long_EMA_Var);
	Short_EMA = EMA( Close, Short_EMA_Var);

	Buy  = Cross( Short_EMA, Long_EMA ) AND Turnover_Filter; 
	Sell = Cross( Long_EMA, Short_EMA );

// Cleanup signal
	Buy = ExRem(Buy,Sell);
	Sell = ExRem(Sell,Buy);
	

// Plot Price & Volume
	SetChartOptions(0,chartShowArrows|chartShowDates);
	_N(Title = "EMACrossT " + Date() + " Open "+O+" Hi "+H+" Low "+L+" Close "+C+" Volume "+WriteVal(V,1) + "\nBase Index:" + GetBaseIndex() );

	Color = IIf(O > C, colorBlack, colorYellow);
	Plot( Close, "Price", color, styleCandle);
 
	BarColor = 
		IIf( V > Ref(V,-1),  colorLightBlue , /* up volume */ 
		IIf( V < Ref(V,-1),  colorDarkBlue, /* down volume */
                     colorGreen /*otherwise*/ ));
	Plot( Volume, "Turnover", BarColor, styleHistogram | styleThick | styleOwnScale);

// Plot Raw signals
	Plot( Short_EMA, "Short_EMA", colorBlue, styleLine);
	Plot( Long_EMA, "Long_EMA", colorRed, styleLine);
	shape = Buy * shapeSmallCircle + Sell * shapeSmallCircle;
	PlotShapes( shape, IIf( Buy, colorLime , colorRed ),0);

// Display details for live trade explore 
	Filter = (Buy OR Sell);
	AddTextColumn(WriteIf(Buy,"Buy","Sell"),"Buy/Sell");
	AddColumn(PositionScore,"Position");

/////////////////////////////////////////////////////////////////////
///////////////End - Trading method code/////////////////////////////
/////////////////////////////////////////////////////////////////////
_SECTION_END();

0 comments

Leave Comment

Please login here to leave a comment.

Back