Gamestudio Links
Zorro Links
Newest Posts
Historical ticks for Lookback backfill
by Zheka. 07/08/20 09:10
Trade Mode without a broker
by jj02520024. 07/08/20 01:20
How to handle algo name in Simulate.c
by happysun. 07/07/20 08:56
Erasing a datapoint in a plot array
by jcl. 07/06/20 09:51
typo
by jcl. 07/06/20 09:44
Video Panel System
by Emre. 07/06/20 09:39
Market Internals Data
by Spirit. 07/05/20 07:50
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
9 registered members (AndrewAMD, kvm, jenGs, Zheka, 3run, alibaba, Ayumi, 20BN, 1 invisible), 354 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
TraderKevin, deus777, carolthesecond, Roger399, vrindger
18474 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
make an array of series #477679
07/21/19 15:33
07/21/19 15:33
Joined: Jul 2019
Posts: 26
M
maxwellreturn Offline OP
Newbie
maxwellreturn  Offline OP
Newbie
M

Joined: Jul 2019
Posts: 26
hi guys is it possible obtain something like this?
Code
vars Price = series(priceClose());
var per = 50;
  int i = optimize(0,0,2,1);
vars a[3] = {
                    series(SMA(Price,per)),
                    series(EMA(Price,per)),
                   series(TEMA(Price,per))
                    };
vars Trends1 = a[i];
if(crossOver(Price,Trends1))
enterLong;
if(crossUnder(Price,Trends1))
exitLong;


obviously it goes on error frown
thanks

Re: make an array of series [Re: maxwellreturn] #477680
07/21/19 15:45
07/21/19 15:45
Joined: Feb 2017
Posts: 1,017
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,017
Chicago
Did you read the error and adjust likewise?

Re: make an array of series [Re: maxwellreturn] #477683
07/21/19 16:48
07/21/19 16:48
Joined: Jul 2019
Posts: 26
M
maxwellreturn Offline OP
Newbie
maxwellreturn  Offline OP
Newbie
M

Joined: Jul 2019
Posts: 26
yeah it give me a syntax error :
syntax error
< series(SMA(Price,per)),>.

thank you for your time andrew

Last edited by maxwellreturn; 07/21/19 16:49.
Re: make an array of series [Re: maxwellreturn] #477685
07/21/19 17:25
07/21/19 17:25
Joined: Feb 2017
Posts: 1,017
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,017
Chicago
Now if you read the manual and look at the definitions of the functions SMA, EMA, and TEMA, you will learn the second argument needs to be an int rather than a var. (A var is actually a double.)

Re: make an array of series [Re: AndrewAMD] #477692
07/21/19 23:10
07/21/19 23:10
Joined: Jul 2019
Posts: 26
M
maxwellreturn Offline OP
Newbie
maxwellreturn  Offline OP
Newbie
M

Joined: Jul 2019
Posts: 26
thank you andrew you are right i ve changed in "int per = 50" but i still get the same sintax error frown

headhache

Last edited by maxwellreturn; 07/21/19 23:19.
Re: make an array of series [Re: maxwellreturn] #477693
07/22/19 02:47
07/22/19 02:47
Joined: Feb 2017
Posts: 1,017
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,017
Chicago
Now here’s the other issue:

You are optimizing to select one of three series calls in an array, but you chose to call all three series in all cases? Even if it did compile, very suboptimal.

So do this:
Declare a vars, no definition, no array.
Then based on the optimize output, use an if-then statement to determine which series call goes to the vars.

Re: make an array of series [Re: AndrewAMD] #477698
07/22/19 09:47
07/22/19 09:47
Joined: Jul 2019
Posts: 26
M
maxwellreturn Offline OP
Newbie
maxwellreturn  Offline OP
Newbie
M

Joined: Jul 2019
Posts: 26
thank you andrew i get it in this way if it can help other forum's users
Code
	
vars Price = series(priceClose());
int per = 50;
int x = 3;
 int i = optimize(0,0,2,1);
 vars Trends1;
vars Trends2;
   if(i == 0) {
		Trends1 = series(SMA(Price,per));
		Trends2 = series(SMA(Price,per*x));
		}  
	else if(i ==	1) {
		Trends1 = series(EMA(Price,per));
		Trends2 = series(EMA(Price,per*x));
		}       
	else if(i ==	2) { 
	Trends1 = series(TEMA(Price,per));
	Trends2 = series(TEMA(Price,per*x));
	}    


but i still dont understand what im doing wrong in the previous array. I still get the syntax error and i tried various combination of ";","}", "," or blank spaces but nothing, still get the same error

Re: make an array of series [Re: maxwellreturn] #477703
07/23/19 00:59
07/23/19 00:59
Joined: Feb 2017
Posts: 1,017
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,017
Chicago
Originally Posted by maxwellreturn
but i still dont understand what im doing wrong in the previous array. I still get the syntax error and i tried various combination of ";","}", "," or blank spaces but nothing, still get the same error
This is probably a limitation of Lite-C. I don't think you can initialize an array with functions upon declaration.

Re: make an array of series [Re: maxwellreturn] #477705
07/23/19 07:22
07/23/19 07:22
Joined: Jul 2000
Posts: 27,256
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,256
Frankfurt
That's right. Arrays are initialized with constants, not with functions.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1