Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (AndrewAMD, Nymphodora, Quad, TipmyPip, Imhotep), 852 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Is this renko implementation an error? #469656
11/28/17 19:33
11/28/17 19:33
Joined: Oct 2017
Posts: 10
O
Oligon Offline OP
Newbie
Oligon  Offline OP
Newbie
O

Joined: Oct 2017
Posts: 10
Hi guys!

I tried to experiment these last few days with the renko bars example found on the zorro manual:

Code:
var BarRange = 0.0005;

int bar(vars Open,vars High,vars Low,vars Close)
{
  Open[0] = round(Close[1],BarRange);
  if(Close[0]-Open[0] >= BarRange) {
    Close[0] = Open[0]+BarRange;
    High[0] = Close[0];
    Low[0] = Open[0];
    return 1;
  }
  if(Open[0]-Close[0] >= BarRange) {
    Close[0] = Open[0]-BarRange;
    High[0] = Open[0];
    Low[0] = Close[0];
    return 1;
  }
  return 4;
}



Then I coded a very simple strategy to buy after two consecutive bullish bars and sell after two consecutive renko bars. The results were too good to be true, so I thought that there must be something wrong. The logic seems fine and when I zoomed on the resulting chart, it seemed ok and to be executing the trades correctly.

My last experiment was to trade it live on a demo account yesterday and today I did the simulation for yesterday just to compare. When I did that, I found that Zorro is not doing the same on the demo account as it did on the simulation. Of course, the demo test was a complete fail, with trades resulting in fractions of a cent and doing a ton more trades than the simulation on the same period of time.

Can anyone help me understand what is going on here? Is there a bug on the backtesting of renko bars? Do I have to set up something additional to make it work in live or demo trading?

Any help would be very helpful, thank you!!

Re: Is this renko implementation an error? [Re: Oligon] #469660
11/29/17 07:48
11/29/17 07:48
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
"Modified prices affect the corresponding price functions (priceOpen, priceHigh, priceLow, priceClose, price) and price-dependent indicators. They also affect simulated trade results when the TICKS flag is not set. For realistic results set the TICKS flag."

Take that serious. Have you set TICKS?

Re: Is this renko implementation an error? [Re: jcl] #469667
11/30/17 05:48
11/30/17 05:48
Joined: Oct 2017
Posts: 10
O
Oligon Offline OP
Newbie
Oligon  Offline OP
Newbie
O

Joined: Oct 2017
Posts: 10
Yes, I have set the TICKS flag, that's another thing that should be working fine, but on the live test, it was not the same.

Here is the rest of the code, it's very simple:

Code:
function run()
{
	set(PLOTNOW+TICKS);
	StartDate = 2005;
	BarPeriod = 60;
	
	if(priceClose(0) > priceClose(1) and priceClose(1) > priceClose(2)){
		reverseLong(1);
	}
	if(priceClose(0) < priceClose(1) and priceClose(1) < priceClose(2)){
		reverseShort(1);
	}
}




What could be going wrong?

Thanks jcl!!

Re: Is this renko implementation an error? [Re: Oligon] #469681
12/01/17 07:39
12/01/17 07:39
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Looks ok to me. But it should not produce a too good backtest. Can you contact Support with that script? They'll check what the problem is, and will send you a fix if it's backtest bias.

Re: Is this renko implementation an error? [Re: jcl] #469685
12/01/17 18:05
12/01/17 18:05
Joined: Oct 2017
Posts: 10
O
Oligon Offline OP
Newbie
Oligon  Offline OP
Newbie
O

Joined: Oct 2017
Posts: 10
Alright, will sure do that!

I hope it can be fixed, it would be nice to keep experimenting with special bars.

Thank you for your help!

Re: Is this renko implementation an error? [Re: Oligon] #469706
12/03/17 14:14
12/03/17 14:14
Joined: Mar 2017
Posts: 23
A
atr Offline
Newbie
atr  Offline
Newbie
A

Joined: Mar 2017
Posts: 23
I tried to test the following script with multiple assets and I got the following error message:

Chart...Error 47: No bars to plot!

Does anybody know how to do a script with Renko bars and multiple assets?

This is the script:


var BarRange = 0.0030; // 0.3 cents bar range

// Renko Bars, variant 1
int bar(vars Open,vars High,vars Low,vars Close)
{
Open[0] = round(Close[1],BarRange);
if(Close[0]-Open[0] >= BarRange) {
Close[0] = Open[0]+BarRange;
High[0] = Close[0];
Low[0] = Open[0];
return 1;
}
if(Open[0]-Close[0] >= BarRange) {
Close[0] = Open[0]-BarRange;
High[0] = Open[0];
Low[0] = Close[0];
return 1;
}
return 4;
}

function run()
{
set(PLOTNOW+TICKS+TESTNOW);
StartDate = 20050101;
BarPeriod = 60;

while(asset(loop("EUR/USD","GBP/USD","USD/JPY")))
{
if(priceClose(0) > priceClose(1)
and priceClose(1) > priceClose(2)){
reverseLong(1);
}
if(priceClose(0) < priceClose(1)
and priceClose(1) < priceClose(2)){
reverseShort(1);
}

}

}

Re: Is this renko implementation an error? [Re: atr] #469707
12/03/17 14:18
12/03/17 14:18
Joined: Mar 2017
Posts: 23
A
atr Offline
Newbie
atr  Offline
Newbie
A

Joined: Mar 2017
Posts: 23
By the way, testing only the EUR/USD with the script above I got the following results:

Simulated account AssetsFix
Bar period 1 hour (avg 350 min)
Test period 2005-01-03..2017-12-01 (19380 bars)
Lookback period 80 bars (3 days)
Montecarlo cycles 200
Simulation mode Realistic ticks (slippage 5.0 sec)
Avg bar 240.0 ticks 30.0 pips range
Spread 0.5 pips (roll -0.02/0.01)
Commission 0.60
Contracts per lot 1000.0

Gross win/loss 8891$ / -7019$ (+21493p)
Average profit 145$/year, 12$/month, 0.55770707b/day
Max drawdown -157$ 8.4% (MAE -162$ 8.7%)
Total down time 81% (TAE 95%)
Max down time 18 weeks from Apr 2009
Max open margin 10$
Max open risk 14$
Trade volume 3608500$ (279508$/year)
Transaction costs -137$ spr, -132$ slp, -1.60$ rol, -189$ com
Capital required 86$

Number of trades 3149 (244/year, 5/week, 1/day)
Percent winning 34.4%
Max win/loss 52$ / -13$
Avg trade profit 0.59448257b 6.8p (+94.3p / -39.0p)
Avg trade slippage -0.04204255b -0.5p (+2.8p / -2.2p)
Avg trade bars 5 (+9 / -2)
Max trade bars 44 (44 hours)
Time in market 84%
Max open trades 1
Max loss streak 14 (uncorrelated 20)

Annual return 169%
Profit factor 1.27 (PRR 1.20)
Sharpe ratio 1.28
Kelly criterion 0.97
R2 coefficient 0.980
Ulcer index 2.3%

Confidence level AR DDMax Capital

10% 225% 113$ 64$
20% 202% 128$ 72$
30% 189% 138$ 77$
40% 181% 146$ 80$
50% 172% 154$ 84$
60% 163% 163$ 89$
70% 155% 173$ 93$
80% 142% 192$ 102$
90% 130% 211$ 112$
95% 113% 246$ 128$
100% 81% 350$ 179$

Portfolio analysis OptF ProF Win/Loss Wgt%

EUR/USD .137 1.27 1083/2066 100.0
EUR/USD:L .133 1.25 545/1030 46.1
EUR/USD:S .141 1.28 538/1036 53.9

Re: Is this renko implementation an error? [Re: atr] #469723
12/04/17 21:00
12/04/17 21:00
Joined: Mar 2017
Posts: 23
A
atr Offline
Newbie
atr  Offline
Newbie
A

Joined: Mar 2017
Posts: 23
In the manual it is written that

"User-defined bar lengths can normally be used with single-asset strategies only, as different assets would produce different bars. For a portfolio system, user-defined bars had to be simulated with the TimeFrame mechanism or with a tick function. "

Can anyone can help me about how to write correctly the following script with renko bars and multiple assets?

var BarRange = 0.0030; // 0.3 cents bar range

// Renko Bars, variant 1
int bar(vars Open,vars High,vars Low,vars Close)
{
Open[0] = round(Close[1],BarRange);
if(Close[0]-Open[0] >= BarRange) {
Close[0] = Open[0]+BarRange;
High[0] = Close[0];
Low[0] = Open[0];
return 1;
}
if(Open[0]-Close[0] >= BarRange) {
Close[0] = Open[0]-BarRange;
High[0] = Open[0];
Low[0] = Close[0];
return 1;
}
return 4;
}

function run()
{
set(PLOTNOW+TICKS+TESTNOW);
StartDate = 20050101;
BarPeriod = 60;

while(asset(loop("EUR/USD","GBP/USD","USD/JPY")))
{
if(priceClose(0) > priceClose(1)
and priceClose(1) > priceClose(2)){
reverseLong(1);
}
if(priceClose(0) < priceClose(1)
and priceClose(1) < priceClose(2)){
reverseShort(1);
}

}

}


Thanks!

Re: Is this renko implementation an error? [Re: atr] #478070
09/02/19 15:32
09/02/19 15:32
Joined: Nov 2015
Posts: 8
R
ricky_k Offline
Newbie
ricky_k  Offline
Newbie
R

Joined: Nov 2015
Posts: 8
Hey atr,

Have you tried looking at the (fairly) new SpecialBars.c script?
Perhaps that can help.

ricky


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