Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (alibaba, howardR, basik85278), 756 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Heiken Ashi, Renko and Median Renko #455830
10/31/15 07:39
10/31/15 07:39
Joined: Aug 2015
Posts: 3
J
JRI Offline OP
Guest
JRI  Offline OP
Guest
J

Joined: Aug 2015
Posts: 3
Hi All,

I have an Median renko EA that uses offline charts to produce live results/bars. I've been trading a simple system sucessfully on the AUS200 manually, however after backtesting on excel the data suggests it, like most systems, will be more profitable when automated.

I have Zorro S and after several weekends trying different approaches I still have issues with/can’t understand how to do the following:

•Apply Heiken Ashi to a strategy. Is it as simple as defining and using something like HAClose() as a variable?
•Plotting Heiken Ashi. Completely lost here!
•How can we identify the change in the colour of the bars, e.g. up/down and define the change in colour as a signal? Would the same code/method be used for Renko?
•Apply Renko or better yet, median renko to a strategy. Again I have no idea of how to apply/refer to the source code supplied in the manual
•Plotting Renko or median renko. Again, lost.
•Defining the size of the Renko bar
•Referring zorro to tick data and not price data - maybe this is in the manual and i need to do more homework?

Any assistance to help resolve these issues would be greatly appreciated. If anyone is interested i'm, happy to post the strategy on the forum once i've automated.

Re: Heiken Ashi, Renko and Median Renko [Re: JRI] #456860
12/13/15 17:14
12/13/15 17:14
Joined: Nov 2015
Posts: 4
R
Repled Offline
Guest
Repled  Offline
Guest
R

Joined: Nov 2015
Posts: 4
I second this !

A simple WORKING example of how to use the bar()-function that plots a Median Renko would help a lot.

Would help if this was included in the manual as well :o)

Last edited by Repled; 12/13/15 21:57.
Re: Heiken Ashi, Renko and Median Renko [Re: Repled] #456872
12/13/15 23:50
12/13/15 23:50
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline
Senior Member
boatman  Offline
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
There is a page in the manual about this:

Code:
bar(vars Open, vars High, vars Low, vars Close, vars Price, DATE Start, DATE Time): int 
User-supplied function for defining a bar; used to create special bar types such as Renko Bars or Range Bars, or to replace the mean price by a different algorithm. The function is called whenever a new price quote arrives or a price tick is read from a historical file. It can modify the candle and determine when the bar ends.

Parameters:
Open, High,
Low, Close, Price  Series with two elements of the corresponding price; f.i. Close[1] is the close price of the previous bar, and Close[0] is the most recent price. The prices of the current bar can be modified by the bar function. Price is the mean price and can be omitted when not used in the function. 
 
Start Optional start time of the bar in the OLE DATE format. Can be omitted when not used in the function.  
Time Optional time of the most recent tick resp. price quote. Can be omitted when not used in the function. 

Returns:
0 - close the bar at the normal end of the BarPeriod.
1 - close the bar now.
4 - keep the bar open until closed by returning 1, and call the bar function at every price tick. 
8 - call the bar function only once at the end of every bar.



This code will create HA bars and plot the up bars as blue and down bars as magenta. The code sets up the HA bars during the initial run of the script. The variables in the run function (Open, High, Low, Close and Price) now refer to the HAOpen, HAHigh, HALow etc so just call these to apply them in your script.

Code:
// Haiken Ashi Bars
int bar(vars Open,vars High,vars Low,vars Close)
{
  Close[0] = (Open[0]+High[0]+Low[0]+Close[0])/4;
  Open[0] = (Open[1]+Close[1])/2;
  High[0] = max(High[0],max(Open[0],Close[0]));
  Low[0] = min(Low[0],min(Open[0],Close[0]));
  return 8;
}

function run() {
	vars Open = series(priceOpen());
	vars High = series(priceHigh());
	vars Low = series(priceLow());
	vars Close = series(priceClose());
	vars Price = series(price());
	ColorUp = BLUE;
	ColorDn = MAGENTA;
}



To identify the change in colour, you could do (I haven't tested this, but you get the idea):

Code:
bool change;
if ((Close[0] > Close[1] and Close[1] < Close[2]) or (Close[0] < Close[1] and Close[1] > Close[2])) change = true;






Last edited by boatman; 12/13/15 23:54.
Re: Heiken Ashi, Renko and Median Renko [Re: boatman] #456875
12/14/15 08:48
12/14/15 08:48
Joined: Nov 2015
Posts: 4
R
Repled Offline
Guest
Repled  Offline
Guest
R

Joined: Nov 2015
Posts: 4
Hello boatman,

Thank you! Not so hard after all :o)
Yes, i get the peak-valley code, done it plenty in MT4.

When having your attention. You don't happen to have a good example of how to set up and plot Tick-data?

Here is a working Renko example if someone is interested:

Code:
// Renko bars, variant 2 in the manual
int bar(vars Open, vars High, vars Low, vars Close)
{	

	var BarRange = 0.0030;
	var OpenDiff;
	var CloseDiff;
	
	OpenDiff = abs(Close[0]-Open[1]);
	CloseDiff = abs(Close[0]-Close[1]);
	if(OpenDiff < CloseDiff) {
	// If this matches we have a valley or peak
	  Open[0] = Open[1];
	} else {                              
	// This is for when we are moving with the trend
	  Open[0] = round(Close[1],BarRange);
	}
	if(Close[0]-Open[0] >= BarRange) {  // Going up
	  Close[0] = Open[0]+BarRange;
	  High[0] = Close[0];
	  Low[0] = Open[0];
	  return 1;
	}
	if(Open[0]-Close[0] >= BarRange) { // Going Down
	  Close[0] = Open[0]-BarRange;
	  High[0] = Open[0];
	  Low[0] = Close[0];
	  return 1;
	}
	return 4;
}

function run()
{
	set(PLOTNOW);
	StartDate = 2006;
	BarPeriod = 60;
	MaxBars = 400;
		
	//* Plot Parameters
	PlotScale = 8;
	PlotWidth = 10000;
	PlotHeight1 = 500;
	PlotHeight2 = 200;
	

	vars Open = series(priceOpen());
	vars High = series(priceHigh());
	vars Low = series(priceLow());
	vars Close = series(priceClose());
	vars Price = series(price());
	ColorUp = BLUE;
	ColorDn = MAGENTA;
}


Re: Heiken Ashi, Renko and Median Renko [Re: Repled] #456886
12/14/15 19:01
12/14/15 19:01
Joined: Feb 2015
Posts: 652
Milano, Italy
M
MatPed Offline
User
MatPed  Offline
User
M

Joined: Feb 2015
Posts: 652
Milano, Italy
thank u, I will look at it. Ciao

Last edited by MatPed; 12/14/15 19:01.
Re: Heiken Ashi, Renko and Median Renko [Re: boatman] #487991
12/17/23 02:52
12/17/23 02:52
Joined: Mar 2021
Posts: 35
Ocean county, Florida
NewtraderX Offline
Newbie
NewtraderX  Offline
Newbie

Joined: Mar 2021
Posts: 35
Ocean county, Florida
How would you plot this on a zorro chart?
Originally Posted by boatman
There is a page in the manual about this:

Code
bar(vars Open, vars High, vars Low, vars Close, vars Price, DATE Start, DATE Time): int 
User-supplied function for defining a bar; used to create special bar types such as Renko Bars or Range Bars, or to replace the mean price by a different algorithm. The function is called whenever a new price quote arrives or a price tick is read from a historical file. It can modify the candle and determine when the bar ends.

Parameters:
Open, High,
Low, Close, Price  Series with two elements of the corresponding price; f.i. Close[1] is the close price of the previous bar, and Close[0] is the most recent price. The prices of the current bar can be modified by the bar function. Price is the mean price and can be omitted when not used in the function. 
 
Start Optional start time of the bar in the OLE DATE format. Can be omitted when not used in the function.  
Time Optional time of the most recent tick resp. price quote. Can be omitted when not used in the function. 

Returns:
0 - close the bar at the normal end of the BarPeriod.
1 - close the bar now.
4 - keep the bar open until closed by returning 1, and call the bar function at every price tick. 
8 - call the bar function only once at the end of every bar. 


This code will create HA bars and plot the up bars as blue and down bars as magenta. The code sets up the HA bars during the initial run of the script. The variables in the run function (Open, High, Low, Close and Price) now refer to the HAOpen, HAHigh, HALow etc so just call these to apply them in your script.

Code
	// Haiken Ashi Bars
int bar(vars Open,vars High,vars Low,vars Close)
{
  Close[0] = (Open[0]+High[0]+Low[0]+Close[0])/4;
  Open[0] = (Open[1]+Close[1])/2;
  High[0] = max(High[0],max(Open[0],Close[0]));
  Low[0] = min(Low[0],min(Open[0],Close[0]));
  return 8;
}

function run() {
	vars Open = series(priceOpen());
	vars High = series(priceHigh());
	vars Low = series(priceLow());
	vars Close = series(priceClose());
	vars Price = series(price());
	ColorUp = BLUE;
	ColorDn = MAGENTA;
}


To identify the change in colour, you could do (I haven't tested this, but you get the idea):

Code
bool change;
if ((Close[0] > Close[1] and Close[1] < Close[2]) or (Close[0] < Close[1] and Close[1] > Close[2])) change = true;





How would you plot this on a zorro chart?


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