Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, dr_panther, 2 invisible), 1,056 guests, and 0 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
Page 1 of 5 1 2 3 4 5
Luxor system - Jaekle and Tomasini #421825
04/25/13 20:12
04/25/13 20:12
Joined: Apr 2013
Posts: 6
H
hyperfish Offline OP
Newbie
hyperfish  Offline OP
Newbie
H

Joined: Apr 2013
Posts: 6
Hello everyone,

and thanks jcl and all involved for your very interesting system.

To find out a bit more about the programming side of things, I have tried to replicate the Luxor system described in the book by Jaekle and Tomasini and mentioned in the literature list on this forum. It seems very simple and yet I am unable to replicate equity curves that look even remotely as good as the book's basic case without exit, time filter or transaction costs. Here is my script:

Code:
function run()
{
	StartDate = 20021021;
	EndDate = 20080704;
	set(LOGFILE|PLOTNOW); // log all trades
	//Try and replicate best given graph
	Slippage = 0;
	Spread = 0;
	BarPeriod = 30;
	
	var longPeriod = 30;
	var shortPeriod = 10;	
	vars Price = series(priceClose());
	vars slowMA = series(SMA(Price, longPeriod));
	vars fastMA = series(SMA(Price, shortPeriod));	
	var buyStopLevel = 0;
	var sellStopLevel = 0;	
	bool goLong = false;
	bool goShort = false;	
	
	if (fastMA[0] > slowMA[0])
	{
		goLong = true;
	}
	if (fastMA[0] < slowMA[0])
	{	
		goShort = true;
	}

	if(crossOver(fastMA, slowMA) == true) 
	{
		//Just reset stop level of trade suggested by MA distance sign
		buyStopLevel = priceHigh(0) + PIP;		
	} 
	else if(crossUnder(fastMA, slowMA) == true) 
	{
		sellStopLevel = priceLow(0) - PIP;		
	}

	if ((goLong == true) && (NumOpenLong == 0))
	{
		enterLong(0, buyStopLevel);		
	}
	else if ((goShort == true) && (NumOpenShort == 0))
	{
		enterShort(0, sellStopLevel);		
	}
	
	plot("FastMA",fastMA[0],0,RED);
	plot("SlowMA",slowMA[0],0,GREEN);
	PlotWidth = 800;
	PlotHeight1 = 320;
}



So this is a basic MA crossover system except that entries use a stop order for filtering. The book's results are given in the curve on page 44 and the table on page 45. The results I have obtained are miles away! This seems odd for such a simple strategy and so I wonder a) whether there is some stupid coding error in the above or b) if not, whether differences of the order of magnitude seen (e.g. their # of trades - 1913, mine - 2675) are to be expected between different data feeds at this TF.

I am aware the book also prints '3' for the short MA period but I believe that is a typo - when I use 3 I get better performance but, plausibly, a lot more trades still (3691).

Thanks for any input!

Re: Luxor system - Jaekle and Tomasini [Re: hyperfish] #421852
04/26/13 11:21
04/26/13 11:21
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
I have the same book laugh and tried the Luxor system some time ago (maybe I can find the old script somewhere). I could well reproduce the results from Jaekle and Tomasini - but the system is not profitable, as you see from the equity curve:



This is a typical curve of a system that was fitted to a certain time period, up to 2010. It is not profitable outside of that period.

You can produce lots of such systems, and they look good in books, but better don't trade them. This does not reduce the quality of the book, which explains automated trading very well.

Interestingly, the equity curve was from a WFO test if I remember right - so the market changed in a way after 2010 that even WFO could not save that system.

Re: Luxor system - Jaekle and Tomasini [Re: jcl] #421854
04/26/13 12:18
04/26/13 12:18
Joined: Apr 2013
Posts: 6
H
hyperfish Offline OP
Newbie
hyperfish  Offline OP
Newbie
H

Joined: Apr 2013
Posts: 6
Hi jcl, and thanks for replying.

I am skeptical about the money-making prowess of Luxor as well. Please note that I am trying to replicate the results pre any optimisation stage. I undertook this purely as a programming exercise - the idea being that, if I cannot manage a system as simple as this one, there is probably no point in continuing. blush You got similar results to the book so it would be fantastic if you did manage to find your original script if that is not too much bother.

Also, I agree on the quality of the Jaekle and Tomasini book; would you know about any other comparable books at a similar or higher technical level?

Many thanks.

Re: Luxor system - Jaekle and Tomasini [Re: hyperfish] #421883
04/27/13 05:13
04/27/13 05:13
Joined: Nov 2012
Posts: 209
S
SFF Offline
Member
SFF  Offline
Member
S

Joined: Nov 2012
Posts: 209

Re: Luxor system - Jaekle and Tomasini [Re: SFF] #421894
04/27/13 13:20
04/27/13 13:20
Joined: Apr 2013
Posts: 6
H
hyperfish Offline OP
Newbie
hyperfish  Offline OP
Newbie
H

Joined: Apr 2013
Posts: 6
Thanks SFF,

that guy certainly seems to have good credentials. I will have a look out for this one.
The other books in this area that I am aware of are those by Robert Pardo. His earliest one is from 1992 (and it comes with very retro dot matrix printer performance tables) so he may well have been the pioneer! One impression I get from all these texts is that they all get a bit "rule of thumb" when it comes to the statistics. This may be a conscious choice re targeting of the text or it may mean that this is as precise as we can get in this area (statistical interpretation of results often ends up being somewhat subjective) - which of these is the case I do not know. A textbook answer would be superb but may not exist. Anyway.

The reason I am a bit hung up about my Luxor problem is this. Here is a simple system for which I have a reasonably detailed set of results (from the J and T book). It is natural to want to replicate them. I find the following results against the benchmark ones - I hope the copyright police won't execute me for the second picture.





I think we can agree that the difference between the two equity curves is non-negligible - the book curve suggests further evaluation while the curve generated by my script invites immediate binning. I see the following different possible reasons for this:
1) there is an error in my script: this would be my preferred reason. It should be easy to correct my script above if it does not, actually, describe an MA crossover strategy where we are always in the market (after the initial entry, which will indeed not be according to system) and where entries are made on a one pip break of the signal candle.
2) there is a bug in either TradeStation (which J&T use) or Zorro. This is a facile way out and, given both systems have no doubt been tested exhaustively with substantially more complex systems, it is extremely improbable.
3) this difference is caused by a difference between data feeds: this is the potential reason I am worried about. Clearly, data from different sources will never completely match meaning that every data point we collect for testing will in fact represent an instance of a random variable subject to sampling error. We would hope and assume that the error introduced is not systematic (that is, e.g. 'large' candles are on average two pips larger in one datafeed that in the other), but corresponds to a white noise (zero-mean, constant variance) term, such that any data induced performance divergences largely average themselves out over a test set of sufficient length. To be honest I have not made any particular effort to vet the Zorro data as I assume its quality has been deemed sufficient for any algo testing purposes. If this is the case then it suggests the dependence of system performance on input data is extreme, sufficient in fact to completely change our evaluation of a system (from interesting to pointless). If so, any effort to design a winning system seems meaningless to me unless we at the same time ensure it works across data feeds by, for instance, containing the testing logic within a further (resampling) loop.
4) the curve shown in the book was not actually generated by their printed code. Well.

So this is why I am hoping possible reason 1) is the answer. Indeed, there may also be further possible explanations I have not thought of! Maybe anyone has an idea?

Last edited by hyperfish; 04/27/13 14:12.
Re: Luxor system - Jaekle and Tomasini [Re: hyperfish] #421896
04/27/13 14:11
04/27/13 14:11
Joined: Apr 2008
Posts: 586
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 586
Austria
I do not know the system but at least this line looks wrong in your code. You set buyStopLevel to 0:

var buyStopLevel = 0;

and you don't set it afterwards except for the rare crossing points, so you enter most trades with entry stop 0. This seems wrong because then you would not need an entry stop at all.

If you want to keep the variable value even when the function is terminated, you need a static variable:

static var buyStopLevel = 0;

Re: Luxor system - Jaekle and Tomasini [Re: Petra] #421900
04/27/13 15:24
04/27/13 15:24
Joined: Apr 2013
Posts: 6
H
hyperfish Offline OP
Newbie
hyperfish  Offline OP
Newbie
H

Joined: Apr 2013
Posts: 6
Hi Petra,

aaaarghh! You got me there. Zorro makes things so simple that I ended up thinking it makes things even simpler than it actually does! You are right, both entry levels have to be static or they will reset to zero at the next bar. Sell and buy stops at zero are, I gather, interpreted as market entries so that explains why there were so many additional trades (They are now down to 1872 - in line with the book.). I did check a segment of the results curve but (Murphy's Law) got one where the stop entries were filled at signal-1, otherwise the problem would have been apparent.

Anyway, in case this helps anyone, here is the new version of the script with equity curve. Note the debug statement - this is pretty much indispensable to check for issues and I should have put it there from the start.

Code:
function run()
{
	StartDate = 20021021;
	EndDate = 20080704;
	set(LOGFILE|PLOTNOW); // log all trades
	//Try and replicate best given graph
	Slippage = 0;
	Spread = 0;
	BarPeriod = 30;
	
	var longPeriod = 30;//optimize(30, 10, 60, 5);
	var shortPeriod = 10;//optimize(10, 1, min(longPeriod, 20), 1);	
	vars Price = series(priceClose());
	vars slowMA = series(SMA(Price, longPeriod));
	vars fastMA = series(SMA(Price, shortPeriod));	
	static bool debug = true;	
	static double buyStopLevel = 0;
	static double sellStopLevel = 0;	
	bool goLong = false;
	bool goShort = false;
	LookBack = longPeriod;	
	
	if (fastMA[0] > slowMA[0])
	{
		goLong = true;
	}
	if (fastMA[0] < slowMA[0])
	{	
		goShort = true;
	}

	if(crossOver(fastMA, slowMA) == true) 
	{
		//Just reset stop level of trade suggested by MA distance sign
		buyStopLevel = priceHigh(0) + PIP;		
	} 
	else if(crossUnder(fastMA, slowMA) == true) 
	{
		sellStopLevel = priceLow(0) - PIP;		
	}

	if ((goLong == true) && (NumOpenLong == 0))
	{
		enterLong(0, buyStopLevel);		
	}
	else if ((goShort == true) && (NumOpenShort == 0))
	{
		enterShort(0, sellStopLevel);		
	}
	
	if( (debug) && (is(LOOKBACK) == false) )
	{
		debug = msg("Lookback = %i, Low = %.5f, High = %.5f, BuyStopLevel = %.5f, SellStopLevel = %.5f, FastMA = %.5f, SlowMA = %.5f, GoShort = %i, GoLong = %i, CrossOver = %i, CrossUnder = %i, LongPos = %i, ShortPos = %i ", 
			is(LOOKBACK), priceLow(0), priceHigh(0), buyStopLevel, sellStopLevel, fastMA[0],slowMA[0], goShort, goLong, crossOver(fastMA, slowMA), crossUnder(fastMA, slowMA), NumOpenLong, NumOpenShort);
	}	
}





What is interesting is that the equity curve now does resemble the book curve ("features" match) BUT looks like a detrended version - the book curve shows an attractive upward drift that is not present in mine. Does anyone have any idea where that might come from? I guess it might be the result of reinvestment but the book script simply uses (EasyLanguage) "Buy" and "Sell" without any position size indication so I assume it is constant...

Anyway, thank you very much for this suggestion Petra.

Re: Luxor system - Jaekle and Tomasini [Re: hyperfish] #421956
04/29/13 07:01
04/29/13 07:01
Joined: Nov 2012
Posts: 209
S
SFF Offline
Member
SFF  Offline
Member
S

Joined: Nov 2012
Posts: 209
Did anyone read his books?
http://www.blueowlpress.com/#books

Re: Luxor system - Jaekle and Tomasini [Re: SFF] #421958
04/29/13 08:38
04/29/13 08:38
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
No, but they look interesting at a first glance. Problem is that when you read one system development book, such as the Jaekle & Tomasini, you probably won't learn much new from the other books unless they introduce some revolutionary new ideas.

Hyperfish: I believe your code is missing an additional entry condition from the original system, that's why you're getting worse results than in the book. This was my script which reproduces the book result:
Code:
function run()
{
	StartDate = 20021021;
	EndDate = 20080704;
	BarPeriod = 30;
	LookBack = 30;
	set(TICKS|PLOTNOW);
	PlotWidth = 800;

	asset("GBP/USD");

// no commissions...	
	Spread = 0;
	Slippage = 0;
	RollLong = RollShort = 0; 
	
	vars Price = series(priceClose()),
		Fast = series(SMA(Price,3)),
		Slow = series(SMA(Price,30));
	
	static var BuyLimit,SellLimit,BuyStop,SellStop;
	
	if(crossOver(Fast,Slow)) {
		BuyStop = priceHigh() + 1*PIP;
		BuyLimit = priceHigh() + 5*PIP;
	}
	if(crossUnder(Fast,Slow)) {
		SellStop = priceLow() - 1*PIP;
		SellLimit = priceLow() - 5*PIP;
	}
		
	if(!NumOpenLong && Fast[0] > Slow[0] && Price[0] < BuyLimit)
		enterLong(1,BuyStop);
	if(!NumOpenShort && Fast[0] < Slow[0] && Price[0] > SellLimit)
		enterShort(1,SellStop);
}



The result:



And you're also right with 3). Systems with time frames below one hour can become very feed dependent. Although the Luxor system result is reproducible, short timeframe results normally can't be reproduced well with price data from other sources. This does not mean that some feed has 'better quality' than the other, it's just the way how price data is sampled. Forex prices depend on the liquidity providers that are currently used by the broker. So a system that uses short timeframes becomes very fragile, and its results are normally not valid for different market situations or for different liquidity providers.

Re: Luxor system - Jaekle and Tomasini [Re: jcl] #421976
04/29/13 16:05
04/29/13 16:05
Joined: Apr 2013
Posts: 6
H
hyperfish Offline OP
Newbie
hyperfish  Offline OP
Newbie
H

Joined: Apr 2013
Posts: 6
Hello SFF, jcl,

and many thanks for the script jcl. You are right, I did not use the limit condition in the EasyLanguage listing as it is not discussed in the text as far as I could see, and as it actually worsens results for the specific GBP/USD data set. Modulo the setting of TICKS, which is probably a good default idea, and the nulling of swap costs, the scripts are then the same and results with the (supposedly applicable) 10 fast MA period are similar, resembling my second post picture and a lot worse than the curve presented in the book. This is an interesting exercise as I would not have expected 30 minute TF results, on a system based on averaged (thus smoothed) quantities, to oscillate this wildly (that it will happen with "scalping EAs" is probably common sense) and I guess it is a good idea to target the 240M or above TFs.

Re the book debate, thanks for this new author SFF, I like the sober and meticulous tone of his website as well as the free articles offered. He does suggest in one of them that he won't discuss applicable statistical tests as the generated confidence intervals are typically humungous and in particular extend to negative average returns so maybe the conclusion is that algorithm design is in the end an art more than a science. Forgive me if this question seems a bit naive to you jcl, but have you then found that the material in books like J+T, Robert Pardo etc. is all you ever need for evaluating your system ideas (which clearly need to come from elsewhere) and for deciding whether you are happy with moving from design to live trading? It may well be.

Anyway, thanks for helping me with this basic scripting exercise, which has already taught me something about timeframes that I cannot remember reading in any of the books mentioned - admittedly this may just be because of my poor memory!

Page 1 of 5 1 2 3 4 5

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