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
4 registered members (fogman, Grant, AndrewAMD, juanex), 989 guests, and 8 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
Pointer Question #411839
11/20/12 11:31
11/20/12 11:31
Joined: Nov 2012
Posts: 209
S
SFF Offline OP
Member
SFF  Offline OP
Member
S

Joined: Nov 2012
Posts: 209
Hi,

I was taught that pointer is stored with address and series is an array.

So what is the address of this sentence below stored to Price pointer?
or the address itself is the price value here?

var *Price = series(price());

In the sentence below, Why it is not using "*Trend" instead of just "Trend"?
When I want to use the latest value of trend, don't I use (*Trend(0))?

if(valley(Trend))

I took those sentence from the script below.

Thanks in advance.


Code:
function run()
{
  var *Price = series(price());
  var *Trend = series(LowPass(Price,1000));
  var *Signals = series(0);
 
  Stop = 4*ATR(100);
  if(valley(Trend)) {
    if(Sum(Signals,4) == 0) // no signals in the last 4 bars?
      enterLong();
    Signals[0] = 1; // store the signal
  } else if(peak(Trend)) {
    if(Sum(Signals,4) == 0)
      enterShort();
    Signals[0] = 1;
  } else
    Signals[0] = 0;
}


Last edited by SFF; 11/20/12 11:33.
Re: Pointer Question [Re: SFF] #411869
11/20/12 15:05
11/20/12 15:05
Joined: Jul 2000
Posts: 27,935
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,935
Frankfurt
Yes, a series is an array. In C an array has the type of a pointer.

The pointer has the name "Price", while "var *Price" is used in the definition to indicate that it's a var pointer and not a var. The "*" does not belong to the name.

The latest value of Trend is Trend[0]. To make the confusion complete, in C you can also write "*Trend", which is the same as Trend[0]. However in all examples we write Trend[0] and use "*Trend" only in the definition.

Re: Pointer Question [Re: jcl] #412511
11/28/12 10:37
11/28/12 10:37
Joined: Nov 2012
Posts: 209
S
SFF Offline OP
Member
SFF  Offline OP
Member
S

Joined: Nov 2012
Posts: 209
Thank you for your reply.

In the code below,
Don't need to put * in the function parameter?

For example,If I use * in it, the code will be look like this:

var *Price = series(price());
var *DomPeriod = series(DominantPeriod(*Price,30));
var LowPeriod = LowPass(*DomPeriod,500);
var *HP = series(HighPass(*Price,LowPeriod));
var *Signal = series(Fisher(*HP,500));

and for *DomPeriod,
It is calculated with 30 bars and in the next line, then It calculates 500 bars.
I don't understand this.
How many bars are stored in the first line?

Thanks in advance.

// calculate the buy/sell signal
var *Price = series(price());
var *DomPeriod = series(DominantPeriod(Price,30));
var LowPeriod = LowPass(DomPeriod,500);
var *HP = series(HighPass(Price,LowPeriod));
var *Signal = series(Fisher(HP,500));
var Threshold = 1.0;

Re: Pointer Question [Re: SFF] #412512
11/28/12 10:49
11/28/12 10:49
Joined: Jul 2000
Posts: 27,935
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,935
Frankfurt
No, the * in the function parameter is wrong. In C, adding a '*' means getting the content of the series. But the function does not want the content, it wants the series as a parameter. The '*' is not a part of the name.

The '500' in the LowPass line is the period for the lowpass filter.

- We've gotten many similar questions, the '*' before the name seems to be a source of confusion for people learning C. Because knowing pointers is not really required for strategy development, in the next tutorial version we'll avoid it altogether and will define series without the '*'. So if the '*' confuses you, just forget it and switch to the new online tutorial:

http://zorro-trader.com/manual/en/tutorial_trade.htm

Re: Pointer Question [Re: jcl] #412513
11/28/12 10:59
11/28/12 10:59
Joined: Nov 2012
Posts: 209
S
SFF Offline OP
Member
SFF  Offline OP
Member
S

Joined: Nov 2012
Posts: 209
Thank you for your guide.

Anyway if we have images in the tut it would be better.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1