Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, SBGuy, TipmyPip, ozgur), 875 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Efficiently testing multiple iterations of a random strategy #449348
03/16/15 11:13
03/16/15 11:13
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline OP
Senior Member
boatman  Offline OP
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
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

Re: Efficiently testing multiple iterations of a random strategy [Re: boatman] #449411
03/19/15 10:55
03/19/15 10:55
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline OP
Senior Member
boatman  Offline OP
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
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

Re: Efficiently testing multiple iterations of a random strategy [Re: boatman] #449412
03/19/15 12:43
03/19/15 12:43
Joined: Feb 2015
Posts: 652
Milano, Italy
M
MatPed Offline
User
MatPed  Offline
User
M

Joined: Feb 2015
Posts: 652
Milano, Italy
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


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