Efficiently testing multiple iterations of a random strategy

Posted By: boatman

Efficiently testing multiple iterations of a random strategy - 03/16/15 11:13

I got this idea from another website and think that it would be a fantastic addition to our strategy development toolkit. I think that we can implement it in Zorro, but that it would take a little more programming nous than I possess.

The idea is to test the performance of your strategy against the performance of a strategy that mimics the frequency and duration of your strategy's trades, but takes random entries. You could run the random strategy a large number of times (say, 1000) and develop a frequency distribution of whatever performance metric is of interest. Finally, you would then work out where your strategy's actual performance metric lies on this frequency distribution. This would give you insight into whether your strategy was in fact better than a randomly generated strategy and whether it had predictive power.

Developing a random strategy that matches the trade frequency and duration of the actual strategy shouldn't be too difficult. I believe this accomplishes that task, but when I run the script, I get Error 111, crash in script:

Code:
//Randomly generate entries to match a strategy's simulation period, number of trades and trade duration 

function run()
{
	BarPeriod = 1440;
	StartDate = 2010; //Set start and end dates to match those from the acutal strategy's simulation
	EndDate = 2014;
	
	int StrategyTrades = 500; //Number of trades in the actual strategy 
	int StrategyDuration = 5; //Average trade length in the strategy, from the performance report
	
	ExitTime = StrategyDuration;
	
	if(Bar % (NumBars/StrategyTrades) >= 0) {
		if(random() < 0)
			enterShort();
		else 
			enterLong();
		}
	}



The second part of the problem would be forcing Zorro to run the strategy multiple times and output the relevant performance metric to a file after each run. I have no idea how to accomplish this, but suspect that it could potentially be accomplished as part of a script run from the command line. Can any programmers out there recommend an approach for accomplishing this?

Cheers
Posted By: boatman

Re: Efficiently testing multiple iterations of a random strategy - 03/19/15 10:55

If there are no ideas as to how to accomplish the second part of this problem, can anyone suggest why the script above results in a crash error?

Thanks in advance
Posted By: MatPed

Re: Efficiently testing multiple iterations of a random strategy - 03/19/15 12:43

I do not know why it crashes, but I would try a different programming approach:
Create an array of int of size (num bar in the period )fill it with "0" and StrategyTrades random "1". For each bar check if the array contains 1, open the trade. I guess it will work
© 2024 lite-C Forums