Correct setup for US30


I have downloaded 1-minute data using TickStory and imported them into Amimroker using ASCII import.
All fine.

I would like to backtest those data, however I am not able to correctly setup an testing environment.
Can you please help?

I have created a simple afl to be able to compare a right data selection with MetaTrader.

Here is a code I test:

// Backtest Setup
SetOption( "InitialEquity", 5000);       							// Adjust this to match your starting equity
SetOption("MaxOpenPositions", 3);       							// Use this to limit the maximum number of trades you are willing to take
SetOption("AccountMargin", 100);           							// Adjust the level of leverage here. 100 = No Leverage, 50 = Up to $2 exposure for every $1 of equity
SetOption("usecustombacktestproc", False);
SetOption("CommissionMode",1);             							// Set the commission mode according to how your broker charges you commissions on each trade
																	// Mode 1 - percent of trade 
																	// Mode 2 - $ per trade 
																	// Mode 3 - $ per share/contract
SetOption("CommissionAmount", 0.5);        							// Set commission amount here to match the commission mode you select above
SetTradeDelays(1,1,1,1);                   							// Trades are delayed by 1 bar. Signals executed on the next bar after the signal
BuyPrice 	= Open;                        							// Buy stocks at the open of the bar following the signal
SellPrice	= Open;                        							// Sell stocks at the open of the bar following the signal
Short = Cover = 0;

// Trading Rules 
EMA_H			= EMA(H,34);										// EMA 34 of Highs
EMA_L  		    = EMA(L,34);										// EMA 34 of Lows

BuyRule1		= Low < EMA_H && EMA_H < Close; //Cross(C,EMA_H);	// Buy, when CLOSE price cross EMA 34 of Highs
SellRule1		= Cross(EMA_L,C);							        // Sell when cross below EMA of Lows

Buy 			= BuyRule1; 
Sell 			= SellRule1;										

//PositionScore = C/Ref(C,-200);									/ When there are more trading signals than you have available capital, give highest priority to stocks that have moved the highest % in the last 200 bars

// Position Sizing & Risk Management
//RiskPerShare = 6*Ref(ATR(14),-1);									// Set the stop loss width to 6 times yesterday's Average True Range
//ApplyStop(stopTypeLoss, stopModePoint,  RiskPerShare, 1, False );	// Place stop loss in the market and hold it constant for the duration of the trade

//The position size model is % risk per trade
//PercentRiskPerTrade = 0.5;
//PctSize = PercentRiskPerTrade * BuyPrice / RiskPerShare;
//SetPositionSize( PctSize, spsPercentOfEquity );						// Set the position size to ensure if the stop loss is hit you only lost 0.5% of your account


CurrentEquity =  5000; 											// Adjust this value to match your account equity before running exploration

//NumberOfSharestoBuy = round(CurrentEquity*PercentRiskPerTrade/RiskPerShare/100);		// Calculate number of shares to buy using total equity, risk per trade and stop loss width

if ( Status( "action" ) == actionExplore )
    AddColumn( Buy, "Buy", 1 );
    AddColumn( Close, "Close" );
	AddColumn( PositionScore,"Position Score - Take Highest Score First",format = 1.4 );
	AddColumn( RiskPerShare,"Initial Stop Width",format = 1.4);
	AddColumn( NumberOfSharestoBuy,"Number of Shares to Buy",format = 1);
	AddColumn( C*NumberOfSharestoBuy,"Dollar Value of Position",format = 1);
	SetSortColumns( -5 );  // This sorts the exploration signals by position score so you know which trade to take first
	Filter = IIf(Buy,1,0);

// Plot System indicators on the chart
PlotOHLC(Open,High,Low,Close,"Price", styleCandle);
//StopLevel = Open - RiskPerShare; // For plotting purposes only
Plot( C, "Price", colorDefault, styleCandle );
Plot(EMA_H,"EMA Highs",colorGreen, styleLine | styleThick);
Plot(EMA_L,"EMA Lows",colorRed, styleLine | styleThick);


How to set up backtesting correctly, so it will buy 1 lot minimum and match MetaTrader testing as much as possible?



See Back Testing Ideas and Portfolio Back Testing.

Do you have AmiBroker license?