Gamestudio Links
Zorro Links
Newest Posts
Z9 getting Error 058
by jcl. 04/24/26 17:48
ZorroGPT
by TipmyPip. 04/23/26 14:23
Stooq now requires an API key
by jcl. 04/13/26 09:42
Strange "Alien" Skull created with >Knubber<
by NeoDumont. 04/10/26 18:58
400 free seamless texture pack downl. here !
by NeoDumont. 04/08/26 19:55
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
4 registered members (VoroneTZ, kiamonster, Grant, 1 invisible), 3,511 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
valino, juergenwue, VladMak, Geir, ondrej
19209 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Pointers #441376
05/20/14 13:51
05/20/14 13:51
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline OP
Senior Member
boatman  Offline OP
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
Today I came across an error using the MaxVal() function. The error is 'Pointer expected'.

I've read through some online C tutorials and searched the forum for the answers to these questions, but I must be missing something.

I get that a pointer references a memory address, not a var or vars. But why do some functions need pointers and not variables? Why does the MaxVal() function need a pointer? How do I pass a pointer to MaxVal()? Do I simply type '*' before the variable?

This is the code that generates the error:

var AO_peak = MaxVal(AO(median_price),d); //Max value of AO within lookback period, d

Thanks in advance

Re: Pointers [Re: boatman] #441381
05/20/14 15:53
05/20/14 15:53
Joined: Jul 2000
Posts: 28,094
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,094
Frankfurt
Most functions need that. Maybe you're taken aback by the word "pointer". Here is meant a series, which is a special case of a pointer.

Re: Pointers [Re: jcl] #441382
05/20/14 15:55
05/20/14 15:55
Joined: Jun 2013
Posts: 1,609
D
DdlV Offline
Serious User
DdlV  Offline
Serious User
D

Joined: Jun 2013
Posts: 1,609
Hi boatman. MaxVal is actually a good example of the answer to your basic question. The 2nd of it's parameters is a single value - the length of the lookback, d. The 1st parameter is the values to be searched through for the MaxVal - i.e., a pointer to that list of values, with at least d entries in the list. When you code AO(median_price), you're passing a single value, same as when you pass d.

One solution is to create a series at least d long to store your AO values, and pass that series as the 1st parameter.

HTH.

Re: Pointers [Re: DdlV] #441401
05/21/14 11:01
05/21/14 11:01
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline OP
Senior Member
boatman  Offline OP
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
Thank you both for your responses. Very helpful and much appreciated!

Re: Pointers [Re: boatman] #441402
05/21/14 11:08
05/21/14 11:08
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline OP
Senior Member
boatman  Offline OP
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
I tried this code, and it worked (well, Zorro skipped to the next error in my code, so I guess at least the syntax is correct):

vars Awesome = series(AO(median_price));
var AO_peak = MaxVal(Awesome,d);


Thanks again for your help guys, much appreciated.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1