Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
M1 Oversampling
by 11honza11. 04/20/24 20:57
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 177 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Help with WFO #487268
02/27/23 21:45
02/27/23 21:45
Joined: Sep 2020
Posts: 5
Derby, UK
aliswee Offline OP
Newbie
aliswee  Offline OP
Newbie

Joined: Sep 2020
Posts: 5
Derby, UK
So I am working on an experiment where I backtest a commonly touted "successful" trading strategy over a long period of time but currently my script cuts out after the first train cycle of WFO...

Once it completes the first cycle the last message I have is:

"Parameters stored in Mega_BackTest_SMA_1.par"

Then up pops the plots for the optimizations and it Zorro doesn't go past there. I have trained the Workshop6.c file, this works fine but the portfolio one from the Black Book acts in the same manner. Would appreciate any ideas as to why this may be happening? I've made tweaks to almost every line of this code to see if moving it or something will make the WFO work but alas I am stuck.

Script for my code*

*Note this is just a silly massive backtest of an SMA Crossover, so don't worry I'm not going to trade it, but I would like it to work!

Code
// 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;
}



All the best everyone,

Re: Help with WFO [Re: aliswee] #487270
02/28/23 08:04
02/28/23 08:04
Joined: Feb 2016
Posts: 15
Russia
nsg Offline
Newbie
nsg  Offline
Newbie

Joined: Feb 2016
Posts: 15
Russia
On my end, your script is fully functional as is. Goes through all five cycles without any problem.

Might be a silly question, but since it "pops the plots for the optimizations" are you sure that you're hitting "Test" after "Train"?

Re: Help with WFO [Re: nsg] #487276
03/02/23 07:16
03/02/23 07:16
Joined: Sep 2020
Posts: 5
Derby, UK
aliswee Offline OP
Newbie
aliswee  Offline OP
Newbie

Joined: Sep 2020
Posts: 5
Derby, UK
Hey NSG, thanks for testing it out.

Seems like I might have an issue with zorro on my laptop so may need to update or reinstall.

Yes, I've tested after training, but then the log says there is no par 2 file so stops.


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1