Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
2 registered members (Quad, AndrewAMD), 1,007 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 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: 27,935
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,935
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