Gamestudio Links
Zorro Links
Newest Posts
retrain - data?
by danatrader. 09/20/20 05:27
Single advise model for portfolio
by jmlocatelli. 09/19/20 22:24
New Zorro version 2.30
by danatrader. 09/19/20 08:25
Special Bars Script
by danatrader. 09/19/20 00:41
NeoDumont's open world treadmill project
by NeoDumont. 09/19/20 00:30
Key_Pressed Variable
by Dooley. 09/18/20 22:46
lock profit without trail
by Grat. 09/18/20 14:30
how to use BrokerHistory2
by Grat. 09/18/20 14:29
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
5 registered members (danatrader, NewBorn, Grat, AndrewAMD, 1 invisible), 429 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
NewBorn, 3dvg, secretagentman, distribution, EditeY
18515 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Behaviour of user-defined bars #479042
02/08/20 07:29
02/08/20 07:29
Joined: Oct 2018
Posts: 67
J
JamesHH Offline OP
Junior Member
JamesHH  Offline OP
Junior Member
J

Joined: Oct 2018
Posts: 67
I am testing a strategy based on Renko bars, by setting
Code
bar = Renko1
where Renko1 is from SpecialBars.c. First I ran it with
Code
BarPeriod = 1
and
Code
BarRange = 500.0
and everything went as expected. For example, in the log I have:

Code
[1: Sun 17-12-17 23:02] (19000.00)
[2: Mon 17-12-18 00:33] (18500.00)
[3: Mon 17-12-18 01:00] (18000.00)
...


and I can see in ZHistoryEditor that at the end of bar 2, the close price dips below 18500 for the first time at 00:33.

Then I wanted daily granularity rather than 1-min. The manual says BarPeriod only affects the start time and the number of allocated bars, but I tried
Code
BarPeriod = 1440
anyhow. The results made no sense to me. From the log:

Code
[1: Tue 17-12-19 09:00] (18500.00)
[2: Wed 17-12-20 02:45] (18000.00)
[3: Wed 17-12-20 18:26] (17500.00)
[4: Thu 17-12-21 10:06] (17000.00)


However, at 17-12-20 02:45 the price is nowhere near 18000 (same for all of the entries). Is this some bug, or else why is the log showing these close times for the Renko bars?

Re: Behaviour of user-defined bars [Re: JamesHH] #479043
02/08/20 09:03
02/08/20 09:03
Joined: Apr 2008
Posts: 320
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 320
Austria
Well Barperiod = 1440 is wrong. Renko bars have no daily granularity. The manual has a chapter on special bars and there is also mentioned how you must set the bar period.

https://manual.zorro-project.com/bar.htm

The prices of some special bars are artificial but I believe renko bars have the real prices. So I dont know the problem with your prices but if you need help in detail you can get a support ticket and contact Support.

Re: Behaviour of user-defined bars [Re: Petra] #479049
02/08/20 17:47
02/08/20 17:47
Joined: Oct 2018
Posts: 67
J
JamesHH Offline OP
Junior Member
JamesHH  Offline OP
Junior Member
J

Joined: Oct 2018
Posts: 67
Originally Posted by Petra
Well Barperiod = 1440 is wrong. Renko bars have no daily granularity. The manual has a chapter on special bars and there is also mentioned how you must set the bar period.

https://manual.zorro-project.com/bar.htm

The prices of some special bars are artificial but I believe renko bars have the real prices. So I dont know the problem with your prices but if you need help in detail you can get a support ticket and contact Support.


Yes, I read the manual page.

My post wasn't very clear, but I am pointing out the strange behaviour when BarPeriod = 1440, with *your* script SpecialBars.c.

I can submit a bug report if you can't explain why the prices don't match and want to fix it.

Last edited by JamesHH; 02/08/20 19:25.
Re: Behaviour of user-defined bars [Re: JamesHH] #479058
02/11/20 11:25
02/11/20 11:25
Joined: Jul 2000
Posts: 27,341
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,341
Frankfurt
Which price exactly does not match with which one?

Re: Behaviour of user-defined bars [Re: jcl] #479080
02/13/20 03:05
02/13/20 03:05
Joined: Oct 2018
Posts: 67
J
JamesHH Offline OP
Junior Member
JamesHH  Offline OP
Junior Member
J

Joined: Oct 2018
Posts: 67
Originally Posted by jcl
Which price exactly does not match with which one?


I was just trying to understand what BarPeriod does when using the bar function, since I am not clear on what the manual says. However, I am not actually using bar now for what I am working on.

Anyhow, when I ran SpecialBars.c with BarPeriod = 1, setting the dates and the asset to my own and turning on logging, the log entries are "correct" as shown in my original post. The bars are timestamped in the log exactly when the OHLC data completes a Renko bar. On the other hand, with BarPeriod = 1440, the log entries are nowhere near the actual value of the Renko bar, which is what I meant when I said the prices do not match.

While I don't know what BarPeriod really does here, I wanted to point out that the code in the script for the function Renko1 is incorrect. I am not sure if that has something do with what I am seeing with the large BarPeriod. It is incorrect because it is possible for the price to move by more than
Code
2 * BarRange
in one OHLCV bar and then Close[0] will not get the correct value.

Here is what I think it should be:
Code
// Renko Bars, variant 1 
int Renko(vars Open, vars High, vars Low, vars Close)
{
  Open[0] = round(Close[1], BarRange);
  var delta = Close[0] - Open[0];
  if (delta >= BarRange) {
    int num_ranges = floor(delta / BarRange);
    Close[0] = Open[0] + num_ranges * BarRange;
    High[0] = Close[0];
    Low[0] = Open[0];
    return 1;
  }
  if (delta <= -BarRange) {
    int num_ranges = floor(-delta / BarRange);
    Close[0] = Open[0] - num_ranges * BarRange;
    High[0] = Open[0];
    Low[0] = Close[0];
    return 1;
  }
  return 4;
}

Re: Behaviour of user-defined bars [Re: JamesHH] #479092
02/15/20 13:34
02/15/20 13:34
Joined: Apr 2008
Posts: 320
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 320
Austria
I understand from the manual under "bars" that a totally wrong bar period will result in not enough allocated bars. I dont know what consequences that has on prices but suppose that many things will then not work.

You code seems to allow the renko bars to have a multiple of their bar range, are you sure this is correct? I always thought that Renko bars must not exceed their bar range.

Re: Behaviour of user-defined bars [Re: Petra] #479107
02/18/20 18:41
02/18/20 18:41
Joined: Oct 2018
Posts: 67
J
JamesHH Offline OP
Junior Member
JamesHH  Offline OP
Junior Member
J

Joined: Oct 2018
Posts: 67
Originally Posted by Petra
I understand from the manual under "bars" that a totally wrong bar period will result in not enough allocated bars. I dont know what consequences that has on prices but suppose that many things will then not work.


The manual states "Set BarPeriod at the approximate average bar duration, in order to allocate enough bars for the lookback period." While I don't exactly understand this, since LookBack = 0 in the SpecialBars.c script can we not assume that there are always enough allocated bars?

Quote

You code seems to allow the renko bars to have a multiple of their bar range, are you sure this is correct? I always thought that Renko bars must not exceed their bar range.


Yes, I am new to TA. I assumed that the bar size should be the greatest multiple of the bar range within the price move, but probably they should all be the same size as you explained.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1