Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
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
1 registered members (Nymphodora), 490 guests, and 7 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
Page 1 of 2 1 2
function Maximum and Minimum in Lite C #448724
02/19/15 00:51
02/19/15 00:51
Joined: Sep 2013
Posts: 73
M
Mangal Offline OP
Junior Member
Mangal  Offline OP
Junior Member
M

Joined: Sep 2013
Posts: 73
In the Tutorial it is writen that "maxv" is the function for maximun in Lite C. However it gives an error when compiling the following:

vars H1 = series(priceHigh(36));
vars H2 = series(priceHigh(35));
vars H3 = series(priceHigh(34));
vars H4 = series(priceHigh(33));
vars H5 = series(priceHigh(32));

vars A11 = maxv (H1[0],H2[0],H3[0],H4[0],H5[0]);

It gives and error saying that "maxv" is not defined. Can anyone tell me where the mistake is? The idea is to get the High from High 36 to High 32.

Re: function Maximum and Minimum in Lite C [Re: Mangal] #448726
02/19/15 03:03
02/19/15 03:03
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline
Senior Member
boatman  Offline
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
I think the function you are after is MaxVal, not maxv.

Also, if you want to define A11 using type vars, you need to include the series definition.

vars A11 = series(MaxVal(Data, TimePeriod));

However, I'm not sure if you can use this to achieve what you want (which as I understand it is the highest high from 36 bars ago to 32 bars ago??). For this, you might need to use a series of nested if...else if statements using the function 'max' which I believe can only support two arguments at a time (hence the need for nested if...else if's).

Re: function Maximum and Minimum in Lite C [Re: boatman] #448728
02/19/15 03:17
02/19/15 03:17
Joined: Sep 2013
Posts: 504
California
G
GPEngine Offline
User
GPEngine  Offline
User
G

Joined: Sep 2013
Posts: 504
California
You can use series shift operator, '+'. http://zorro-trader.com/manual/en/series.htm

vars H = series(priceHigh());
var h32to36 = MaxVal(H+32, 5);

Re: function Maximum and Minimum in Lite C [Re: GPEngine] #448729
02/19/15 03:17
02/19/15 03:17
Joined: Sep 2013
Posts: 504
California
G
GPEngine Offline
User
GPEngine  Offline
User
G

Joined: Sep 2013
Posts: 504
California
That's some wicked lag.

Re: function Maximum and Minimum in Lite C [Re: GPEngine] #448740
02/19/15 11:03
02/19/15 11:03
Joined: Sep 2013
Posts: 73
M
Mangal Offline OP
Junior Member
Mangal  Offline OP
Junior Member
M

Joined: Sep 2013
Posts: 73
Thank you to both you. The last solution as "var h32to36 = MaxVal(H+32, 5);" can save me a lot of time. However, when later on using it in some "if" condition it gives an error saying that it requires array or pointer type. Say for instante:

vars H = series(priceHigh());
var A11 = MaxVal(H+31, 6);
var A12 = MaxVal(H+25, 6);
var A13 = MaxVal(H+19, 6);
var A14 = MaxVal(H+13, 6);
var A15 = MaxVal(H+7, 6);


vars P = series(price(0));

if (A14[0] < A15[0] and P[0] < A14[0]) enter long();

When compiling it gives the message "subscript requires array or pointer type"

Is it because A11 should be vars type? How to go around it?

I think I got it. Thank you.

vars H = series(priceHigh());
vars A11 = series(MaxVal(H+31, 6));
vars A12 = series(MaxVal(H+25, 6));
vars A13 = series(MaxVal(H+19, 6));
vars A14 = series(MaxVal(H+13, 6));
vars A15 = series(MaxVal(H+7, 6));

Last edited by Mangal; 02/19/15 14:47.
Re: function Maximum and Minimum in Lite C [Re: Mangal] #448746
02/19/15 16:41
02/19/15 16:41
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
When you only compare the recent data, you need no series. if (A14 < A15 ...) would be sufficient.

Re: function Maximum and Minimum in Lite C [Re: jcl] #449243
03/10/15 03:16
03/10/15 03:16
Joined: Sep 2013
Posts: 73
M
Mangal Offline OP
Junior Member
Mangal  Offline OP
Junior Member
M

Joined: Sep 2013
Posts: 73
Trying to check if it really gives the HH of the number of bars desired:

function run()

{
BarPeriod = 1440;
vars H = series(priceHigh());
var h32to36 = MaxVal(H+32,5);
printf("Result = %.f", h32to36);

}

It gives Result = 1. How to do so also it gives decimals and check what it really does? I am trying to see how it works.

Re: function Maximum and Minimum in Lite C [Re: Mangal] #449244
03/10/15 06:05
03/10/15 06:05
Joined: Sep 2013
Posts: 504
California
G
GPEngine Offline
User
GPEngine  Offline
User
G

Joined: Sep 2013
Posts: 504
California
printf("\nResult = %.5f", h32to36);

http://www.cplusplus.com/reference/cstdio/printf/

Re: function Maximum and Minimum in Lite C [Re: GPEngine] #449249
03/10/15 13:16
03/10/15 13:16
Joined: Sep 2013
Posts: 73
M
Mangal Offline OP
Junior Member
Mangal  Offline OP
Junior Member
M

Joined: Sep 2013
Posts: 73
Thank you GP. I am trying it and it gives a quiet long series of numbers with decimals, but no one of them coincides with the MaxVal of h32 to h36 back from yesterday (included).

Re: function Maximum and Minimum in Lite C [Re: Mangal] #449262
03/11/15 05:40
03/11/15 05:40
Joined: Sep 2013
Posts: 504
California
G
GPEngine Offline
User
GPEngine  Offline
User
G

Joined: Sep 2013
Posts: 504
California
I'm not sure how to respond. Read this and check for gaps in your understanding?
http://zorro-trader.com/manual/en/run.htm

Page 1 of 2 1 2

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1