Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (ozgur, EternallyCurious, howardR, 1 invisible), 623 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 5 1 2 3 4 5
Re: Median Renko bars for Zorro [Re: ] #424778
06/21/13 14:51
06/21/13 14:51
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
With 'reverse order' I meant from new to old. New data is appended at the begin of the series. Shifting them could theoretically be avoided with some tricks, for instance allocating a larger array and moving its pointer. However such tricks are not used in the current Zorro version. The shifting has not much effect on the backtest speed.

Re: Median Renko bars for Zorro [Re: GlennR] #424779
06/21/13 14:52
06/21/13 14:52

A
acidburn OP
Unregistered
acidburn OP
Unregistered
A



Originally Posted By: GlennR
Empty your piggy bank & send it to the broker! wink


But, have you also noticed that the win rate of the strategy is only 28%? It's not that it's flawless, it's just that the wins are more than enough to cover for all the losses and then some. Yes, it's a trend following strategy. The simplest you could imagine, anybody can code it in a few minutes.

What if renko's are uncovering the truth behind candlesticks, which hide it pretty well all the time? What if I really need to empty the piggy bank? wink

It seems to me that 99% of traders/investors are trading with the candlesticks, and what do we usually say about following the herd? This fact, and some inherent positive capabilities of various other charting methods, is what wildly attracts me to them. I might stumble on some road blocks during the way, but I'm not giving up until I hit the wall. grin

Re: Median Renko bars for Zorro [Re: jcl] #424780
06/21/13 14:58
06/21/13 14:58

A
acidburn OP
Unregistered
acidburn OP
Unregistered
A



Originally Posted By: jcl
With 'reverse order' I meant from new to old. New data is appended at the begin of the series. Shifting them could theoretically be avoided with some tricks, for instance allocating a larger array and moving its pointer. However such tricks are not used in the current Zorro version. The shifting has not much effect on the backtest speed.


Ah, I see. OK then, it seems that you don't think that it's impossible to implement renkos as things stand, so I'll continue hacking. I do have some new ideas now.

I only miss your answer on the topic of applying standard Zorro analytics tools (indicators etc...) on the normal C arrays? Can that work? Say, I implement a C array, order the elements as needed, can I then give it's pointer to the RSI() and have the calculations done, the same way as if I provided a series to the function? I think this is crucial.

Re: Median Renko bars for Zorro [Re: ] #424781
06/21/13 15:06
06/21/13 15:06
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Yes, all Zorro indicators can use normal C arrays. A series is also a normal C array, it's just shifted at every bar.

Re: Median Renko bars for Zorro [Re: jcl] #424782
06/21/13 15:08
06/21/13 15:08

A
acidburn OP
Unregistered
acidburn OP
Unregistered
A



Originally Posted By: jcl
Yes, all Zorro indicators can use normal C arrays. A series is also a normal C array, it's just shifted at every bar.


Cool, thanks! The future is bright again. wink

Unless this poor notebook dies of overheating... mad

Re: Median Renko bars for Zorro [Re: ] #424802
06/22/13 00:34
06/22/13 00:34
Joined: Apr 2013
Posts: 107
UK
G
Geek Offline
Member
Geek  Offline
Member
G

Joined: Apr 2013
Posts: 107
UK
Interesting thread, I enjoy reading things that inspire lateral thinking.

Good luck with this acidburn and keep us updated on your journey for the holy grail laugh

Re: Median Renko bars for Zorro [Re: Geek] #424858
06/22/13 23:12
06/22/13 23:12

A
acidburn OP
Unregistered
acidburn OP
Unregistered
A



Originally Posted By: Geek
Interesting thread, I enjoy reading things that inspire lateral thinking.

Good luck with this acidburn and keep us updated on your journey for the holy grail laugh


Thanks, Geek!

I have some good news, and some bad news.

The good news is that I really made a nice progress with this, as you can tell by the attached code. The bad news is that I think this is not worth pursuing further. The problem is that Zorro is so centered on BarPeriod clock, that trying to break out of that concept is a world of pain! At moments it felt like I was rewriting the Zorro... in Zorro!

I mostly succeeded making the volatility based bars (not renko's, not CBR's, but conceptually close!). But the plots are still created at BarPeriod resolution, so they're just not useful to develop strategies on custom bars. Unless jcl chimes in with some breakthrough idea, of course, but even then I see lots of obstacles on the way. The slight problem is also that there's no realloc. And I also see how troublesome it would become to take care of the proper lookback for strategies with multiple indicators.

I heavily commented the code, so if anybody wants to continue with this, be my guest! I guess I just got tired of fighting the system. laugh But, I learned a lot about Zorro in the process, so it was actually a time good spent.

Code:
function run()
{
	set(PLOTNOW);
	// just some random week for playing
	StartDate = 20111202;
	EndDate = 20111209;
	BarPeriod = 1; /* mandatory */

	static int NumPriceBars, NumLRSBars;
	static var Base;
	static vars Price, LRS;

	// need to reset static variabes on every run because they somehow leak
	// between the runs. can't just initialize them in the declarations above
	// (learned that the hard way)
	if (is(INITRUN)) {
		NumPriceBars = 0;
		NumLRSBars = 0;
		Base = 0;
	}

	// we need to allocate memory for the arrays, no series land :(
	if (!Price) {
		// wait for Zorro to provide the total number of bars
		// to get some idea how much memory to allocate
		if (!NumBars)
			return;
		// don't know any better formula atm, and no realloc(), damn!
		Price = malloc(NumBars * sizeof(var));
		LRS = malloc(NumBars * sizeof(var));
		// let's be sure we really got our memory
		if (!Price || !LRS) {
			printf("\nOut of memory!");
			quit();
		}
	}

	// we're getting somewhere, this is our base price
	// I'm scared to use == with floats, but it seems to work
	// at least when comparing with zero
	if (Base == 0) {
		printf("\nInitializing Base...");
		Base = priceClose();
	}

	// finally! we're printing a new bar only when price moves this many
	// pips from the base price, so our new bars will be based on price
	// volatility and not on time period
	if (abs(priceClose() - Base) / PIP >= 10) {
		// if there are previous prices, we need to shift them to the right
		// this is what series data type would do for us behind the scene
		if (NumPriceBars)
			memcpy(Price + 1, Price, (NumPriceBars - 1) * sizeof(var));
		// insert new bar...
		Price[0] = priceClose();
		// increment the counter...
		NumPriceBars++;
		// and reset the base price
		Base = priceClose();
		// mostly the same drill for the indicator, except we also have to
		// take care of the needed lookback ourselves argh &^%$#
		if (NumPriceBars > 10) {
			if (NumLRSBars)
				memcpy(LRS + 1, LRS, (NumLRSBars - 1) * sizeof(var));
			LRS[0] = LinearRegSlope(Price, 10);
			NumLRSBars++;
		}
	}

	// finally we can trade our own bars, can you believe? :)
	if (crossOver(LRS, 0)) {
		if (!NumOpenLong)
			enterLong();
	} else if (crossUnder(LRS, 0)) {
		if (!NumOpenShort)
			enterShort();
	}

	// unfortunately graphs are at the original BarPeriod resolution
	// don't know how to fix that. yes, this is a showstopper :(
	plot("OrigPrice", priceClose(0), 0, BLACK);
	// be extra careful when printing our bars, they're not available
	// right from the start!
	if (NumPriceBars)
		plot("NewPrice", Price[0], 0, BLUE);
	if (NumLRSBars)
		plot("LRS", LRS[0], NEW, RED);

	// finally, we need to release the allocated memory, so we don't run
	// out of memory, traditionally exiting the program releases
	// all the allocated memory, but not in Zorro!
	if (is(EXITRUN)) {
		if (Price) {
			free(Price);
			Price = NULL;
		}
		if (LRS) {
			free(LRS);
			LRS = NULL;
		}
		// some statistics
		printf("\nStats: Bars %d, PriceBars %d LRSBars %d", NumBars, NumPriceBars, NumLRSBars);
	}	
}


Re: Median Renko bars for Zorro [Re: ] #424859
06/22/13 23:24
06/22/13 23:24

A
acidburn OP
Unregistered
acidburn OP
Unregistered
A



And I almost forgot, I eventually found what was wrong with the EURUSD bars I attached earlier in this thread. It's not that the bars had knowledge of the future, but instead they allowed trading at the previous better prices, so trades would end up more profitable than it would be possible in reality. But the end result is the same, equity curves that are just too good to be true.

I've been bitten with a very similar thing before, I guess I never learn. wink Actually, I know very well how to avoid such mistakes in my home-made backtesting gear, but everytime I try to push such data to foreign platforms like Zorro, I repeat the same mistake. Oh, well... laugh

I will surely continue investigating various strange bars, but after a slight pause...

Re: Median Renko bars for Zorro [Re: ] #424861
06/23/13 08:09
06/23/13 08:09
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Thanks for that script! It should work well for trading with Renko bars, only in the chart they are of course plotted with different width because the x axis is based on price bars, not on renko bars.

I do not believe that a profitable system is possible with Renko or similar artificial bars. But if you nevertheless want to pursue that further, we can implement a Zorro function for building price bars in a user defined way. Renko bars will then be plotted correctly and your above script will become somewhat simpler. Of course this method has many limitations, for instance you can have only one asset - portfolio trading is not possible. But let me know if you still want to continue with Renko research and we'll implement that.

Re: Median Renko bars for Zorro [Re: jcl] #424868
06/23/13 11:04
06/23/13 11:04

A
acidburn OP
Unregistered
acidburn OP
Unregistered
A



Originally Posted By: jcl
Thanks for that script! It should work well for trading with Renko bars, only in the chart they are of course plotted with different width because the x axis is based on price bars, not on renko bars.

I do not believe that a profitable system is possible with Renko or similar artificial bars. But if you nevertheless want to pursue that further, we can implement a Zorro function for building price bars in a user defined way. Renko bars will then be plotted correctly and your above script will become somewhat simpler. Of course this method has many limitations, for instance you can have only one asset - portfolio trading is not possible. But let me know if you still want to continue with Renko research and we'll implement that.


I think I'll never stop being interested in this kind of artifical bars (or at least not before I conclude my research with them and possibly come to the same conclusion as you, that they're not really profitable). But to continue I'd really need a decent setup to work with. You're right, with the script I attached, it's almost possible to run various tests and strategies. Unfortunately without a proper charting support, it's not really comfortable. Proper visualization is absolutely required at this stage.

So, my answer is yes, if you can improve the support in Zorro for such kind of bars, I would gladly continue my research. The only question is how much effort on your part is needed to support them properly. I leave that decision up to you. Because for the first time it looks non trivial, and I certainly wouldn't want to distract you from all other great improvements that you're working on and adding to now my absolutely favorite platform for system deveopment.

Page 2 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