Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,619 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Stuck in the Series again! #428386
08/26/13 18:19
08/26/13 18:19
Joined: Jun 2013
Posts: 41
Ohio, USA
P
Pork Offline OP
Newbie
Pork  Offline OP
Newbie
P

Joined: Jun 2013
Posts: 41
Ohio, USA
I'm thinking that the following should work:

function run()
{
vars P=series();
vars high=series(priceHigh());
int highndx;
int i;

for(i=0;i=LOOKBACK;i++)
{
if(high[i]<high[i+1])
{
highndx = i+1;
break;
}
}

P[0]=high[highndx];

}

But I am obviously wrong as I get a syntax error on the P[0]=high[highndx] . Pretty certain the problem has something to do with pointers. This hsa to be something stupid that I have missed because it it too stupid. Certainly you can move an array value to an array value.
Thanks
P
edit where error is.

Last edited by Pork; 08/26/13 18:20.
Re: Stuck in the Series again! [Re: Pork] #428387
08/26/13 18:41
08/26/13 18:41
Joined: Jul 2000
Posts: 28,024
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,024
Frankfurt
Your code has no syntax error. But it has an infinite loop. Can someone find it?

Re: Stuck in the Series again! [Re: jcl] #428390
08/26/13 18:51
08/26/13 18:51
Joined: Jun 2013
Posts: 41
Ohio, USA
P
Pork Offline OP
Newbie
Pork  Offline OP
Newbie
P

Joined: Jun 2013
Posts: 41
Ohio, USA
I been looking at this tooo long.
There is only one loop, so it has to be infinite, but I don't see it.
Break should exit the for when the condition matches.
so either the condition will never match or i will never be equal to loopback.
P

Re: Stuck in the Series again! [Re: Pork] #428393
08/26/13 19:22
08/26/13 19:22
Joined: May 2013
Posts: 245
S
swingtraderkk Offline
Member
swingtraderkk  Offline
Member
S

Joined: May 2013
Posts: 245
LookBack is not defined, so zorro tries to calculate it by adding one each time?

Re: Stuck in the Series again! [Re: swingtraderkk] #428399
08/26/13 20:15
08/26/13 20:15

A
acidburn
Unregistered
acidburn
Unregistered
A



for (initialization; comparison; continuation) { ... }

i=LOOKBACK is NOT comparison.

That's what's obvious, without running the script..

Re: Stuck in the Series again! [Re: ] #428400
08/26/13 20:34
08/26/13 20:34
Joined: Apr 2013
Posts: 57
3
3DCat Offline
Junior Member
3DCat  Offline
Junior Member
3

Joined: Apr 2013
Posts: 57
Try i<LookBack for your comparison (and also not i==LookBack)

edit: i guess your i=LookBack assignment always returns true thus your loop runs endlessly(am i right?)

Last edited by 3DCat; 08/26/13 20:53.
Re: Stuck in the Series again! [Re: 3DCat] #428414
08/27/13 08:11
08/27/13 08:11
Joined: Jul 2000
Posts: 28,024
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,024
Frankfurt
Yes, the comparison is wrong and LOOKBACK is a flag - what you meant was LookBack. C is case sensitve.

The "P[0]=high[highndx];" line however is correct.

Re: Stuck in the Series again! [Re: jcl] #428433
08/27/13 12:36
08/27/13 12:36
Joined: Jun 2013
Posts: 41
Ohio, USA
P
Pork Offline OP
Newbie
Pork  Offline OP
Newbie
P

Joined: Jun 2013
Posts: 41
Ohio, USA
Thanks All,
Appreciate the help.
The LOOKBACK being a flag was not a problem I was thinking about.
Good to know there is an option.
Changing code feverisly laugh
I seem to struggle with some of the more simple concepts of C.
P


Moderated by  Petra 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1