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
2 registered members (AndrewAMD, rki), 395 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Workshop4 oddness #483017
04/22/21 17:37
04/22/21 17:37
Joined: Apr 2021
Posts: 3
M
MatD Offline OP
Guest
MatD  Offline OP
Guest
M

Joined: Apr 2021
Posts: 3
Hi there! I'm new to Zorro, but old to programming!

I'm working through the tutorials and thought I'd tweak Workshop4, here's the code (i just replaced the '300' values in the tutorial with 'Lookback' because that looked like the right thing to do:

[img]https://www.dropbox.com/s/3m3urvr2rij6bag/code1.PNG?dl=0[/img]

This produces the same output as the original tutorial:

[img]https://www.dropbox.com/s/y1mp7aqq7d4yj83/Out1.PNG?dl=0[/img]

BUT if I change the LookBack to 298 (instead of 300), the Equity almost doubles by the end of the series:

[img]https://www.dropbox.com/s/vdcr93dq8e8yoc7/Out2.PNG?dl=0[/img]


I'm a long way from understanding what's going on - I'll get there eventually - but my question is; How can this simple code be so sensitive to a small change like that?

Looking forward to finding out a lot more!
Kind regards
-Mat


[b][/b]

Attached Files Out2.PNGOut1.PNGcode1.PNG
Re: Workshop4 oddness [Re: MatD] #483018
04/23/21 06:12
04/23/21 06:12
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
Outliers like that are not usual, but can happen. You could run an optimization over the lookback period from 250 to 350 and check if there are more outliers.

Re: Workshop4 oddness [Re: MatD] #483021
04/23/21 07:56
04/23/21 07:56
Joined: Apr 2021
Posts: 19
S
simonkrebs Offline
Newbie
simonkrebs  Offline
Newbie
S

Joined: Apr 2021
Posts: 19
Yeah, that's really interesting. Looks like 298 is a random hit. I would be careful relying on such values though, that looks like overfitting.

I did some parameter optimization as suggested by JCL, here are the results:

Code
V 2.359 on Fri 21-04-23 09:51:54 (Zorro S Subscription)
Train: Workshop4  2012..2017
Assets AssetsIB
Parameter 1 step  1:  260.00 => 0.84  98/327
Parameter 1 step  2:  262.00 => 0.95  92/342
Parameter 1 step  3:  264.00 => 0.82  92/350
Parameter 1 step  4:  266.00 => 0.84  86/344
Parameter 1 step  5:  268.00 => 0.95  89/339
Parameter 1 step  6:  270.00 => 0.96  83/342
Parameter 1 step  7:  272.00 => 0.96  87/350
Parameter 1 step  8:  274.00 => 1.11  86/367
Parameter 1 step  9:  276.00 => 0.76  83/354
Parameter 1 step 10:  278.00 => 0.76  80/359
Parameter 1 step 11:  280.00 => 0.75  78/340
Parameter 1 step 12:  282.00 => 0.75  79/343
Parameter 1 step 13:  284.00 => 1.10  92/316
Parameter 1 step 14:  286.00 => 1.10  88/312
Parameter 1 step 15:  288.00 => 1.09  91/311
Parameter 1 step 16:  290.00 => 0.90  81/315
Parameter 1 step 17:  292.00 => 1.18  84/319
Parameter 1 step 18:  294.00 => 0.99  75/324
Parameter 1 step 19:  296.00 => 1.08  80/314
Parameter 1 step 20:  298.00 => 1.58  89/299
Parameter 1 step 21:  300.00 => 1.28  90/309
Parameter 1 step 22:  302.00 => 1.17  93/295
Parameter 1 step 23:  304.00 => 1.07  82/301
Parameter 1 step 24:  306.00 => 1.39  88/321
Parameter 1 step 25:  308.00 => 0.97  83/319
Parameter 1 step 26:  310.00 => 0.87  82/328
Parameter 1 step 27:  312.00 => 0.90  87/316
Parameter 1 step 28:  314.00 => 1.18  90/322
Parameter 1 step 29:  316.00 => 0.89  85/324
Parameter 1 step 30:  318.00 => 0.92  79/325
Parameter 1 step 31:  320.00 => 1.18  87/313
Parameter 1 step 32:  322.00 => 0.97  86/314
Parameter 1 step 33:  324.00 => 1.03  89/302
Parameter 1 step 34:  326.00 => 0.97  85/301
Parameter 1 step 35:  328.00 => 1.01  88/305
Parameter 1 step 36:  330.00 => 0.96  83/308
Parameter 1 step 37:  332.00 => 0.78  84/306
Parameter 1 step 38:  334.00 => 0.99  80/299
Parameter 1 step 39:  336.00 => 0.87  74/302
Parameter 1 step 40:  338.00 => 0.93  87/298
Parameter 1 step 41:  340.00 => 0.91  83/318
Selected p1[20] = 298  => 1.29

EUR/USD: 298=> 1.858


Seems like 298-306 produces the best results in backtest.

Attached Files Bildschirmfoto 2021-04-23 um 09.54.40.png
Re: Workshop4 oddness [Re: MatD] #483022
04/23/21 08:18
04/23/21 08:18
Joined: Apr 2021
Posts: 3
M
MatD Offline OP
Guest
MatD  Offline OP
Guest
M

Joined: Apr 2021
Posts: 3
Hi many thanks for the replies.

My immediate thoughts are that if even a simple model like this is so sensitive to small changes in parameters, it will be hard to gain confidence in the robustness of *any* (algo) strategy, especially more complex ones.

Presumably different classes of strategies are more/less sensitive to initial conditions (and over-training)?

(Also, @simonkrebs please could you post your code that ran the test? I would help me get my head around a few things!)

Last edited by MatD; 04/23/21 08:26.
Re: Workshop4 oddness [Re: MatD] #483023
04/23/21 17:28
04/23/21 17:28
Joined: Apr 2021
Posts: 19
S
simonkrebs Offline
Newbie
simonkrebs  Offline
Newbie
S

Joined: Apr 2021
Posts: 19
Of course, here's the code. Just did some slight changes on Workshop4:

Code
// Trend Trading ///////////////////
#include <profile.c>

function run()
{
	EndDate = 20171231; // fixed simulation period 
	Verbose = 2;
	LookBack = 350;	// needed for MMI
	asset("EUR/USD");
	set(LOGFILE,PLOTNOW,PARAMETERS); // log all trades
	
	int Time = optimize(300,260,340,2);

	vars Prices = series(priceClose());
	vars Trends = series(LowPass(Prices,Time));
	
	Stop = 30*ATR(100); // very distant stop
	
	vars MMI_Raws = series(MMI(Prices,Time));
	vars MMI_Smooths = series(LowPass(MMI_Raws,Time));
	
	if(falling(MMI_Smooths)) 
	{
		if(valley(Trends))
			enterLong();
		else if(peak(Trends))
			enterShort();
	}
	
	plot("MMI_Raw",MMI_Raws,NEW,GREY);
	plot("MMI_Smooth",MMI_Smooths,0,BLACK);
	//plotTradeProfile(-50); 
}


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1