// Big 10 year back test //////
#include <profile.c>
function tradeSMA(){
// store the current price data a series for analysis
vars Prices = series(priceClose()); // store prices as a list
// optimize the "input" for the fast indicator
var fastMAPeriod = optimize(32, 8, 64, 8);
// mulitply the fast input period to get the slow one (avoids flip-over)
var slowMAFactor = optimize(4, 2, 8, 1);
// store a series for the slow and fast MA for analysis
vars SlowMA = series(MovingAverage(Prices, fastMAPeriod*slowMAFactor, MAType_SMA));
vars FastMA = series(MovingAverage(Prices, fastMAPeriod, MAType_SMA));
// Stop = optimize(5, 1, 20, 1) *(ATR(50));
// get your trade signals here
if(crossOver(FastMA, SlowMA))
{
enterLong();
} else if(crossUnder(FastMA, SlowMA)) // continuous trading
{
enterShort();
}
// Just show the trading strategy
//ColorEquity = 0;
//ColorDD = 0;
// plot the indicator lines on the chart
//plot("Fast MA", FastMA, LINE, RED); // draw slow MA line
//plot("Slow MA", SlowMA, LINE, BLUE); // draw fast MA line
}
function run()
{
// get a log of all trades, plot the equity curve at the end
set(LOGFILE, PARAMETERS); // log all trades and show equity curve
// start date of backtest in yyyymmdd
StartDate = 2005;
// end date of backtest in yyyymmdd
EndDate = 2022;
// set the timeframe to daily candles
BarPeriod = 1440;
// gather data for indicators before beginning trading
LookBack = 2000;
// hypothetical $10k account
// Capital = 10000;
// set the roll, slippiage and spread costs to zero to get pure compairson of trades*
RollCost = Slippage = Spread = 0; // Set cost to zero for fair comparison
//Walk Forward Optimization
// let Zorro use all but two cores to run the simulation
NumCores = -2;
// number of cycles in the backtest
NumWFOCycles = 5;
while(asset(loop("EUR/USD", "GBP/USD", "AUD/USD", "USD/CHF", "USD/CAD", "USD/JPY")))
{
// Set risk to be 1% of capital
//var riskPercent = 1;
//Risk = riskPercent*Capital/100;
Lots = 1;
tradeSMA();
}
PlotWidth = 600;
PlotHeight1 = 300;
}