Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 600 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
donchian inside an asset loop #471003
02/15/18 16:44
02/15/18 16:44
Joined: Nov 2017
Posts: 34
C
Cheulmen Offline OP
Newbie
Cheulmen  Offline OP
Newbie
C

Joined: Nov 2017
Posts: 34
Hi, I'm trying to calculate inside a loop the DCHannel() to test if there has been or not a breakout, but I'm getting an error 041. I'm using a portfolio system, this is an excerpt:

function run()
{
int N = assetList("Assets");
for (i=0; i<N; i++);
{
asset(Assets[i]);
vars Prices = series(priceClose());

DChannel(50);

vars upb = series (rRealUpperBand);

if (Prices[0] > upb[1])
enterLong();
}
}

What am I doing wrong? I just want to compare the current price of a specific asset with some TA indicator (a Donchian channel in the example) for that asset, to decide if enter or not in the trade. I checked the manual but still I don't understand what's happening.

Re: donchian inside an asset loop [Re: Cheulmen] #471007
02/15/18 18:20
02/15/18 18:20
Joined: Jul 2017
Posts: 784
Z
Zheka Offline
User
Zheka  Offline
User
Z

Joined: Jul 2017
Posts: 784
Your script compiles and runs fine on my end, without errors.

Error 041 is about "series declaration" (look under remarks for "series()" in the manual). So, try declaring series before if and for () statements.

Re: donchian inside an asset loop [Re: Cheulmen] #471008
02/15/18 18:37
02/15/18 18:37
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
I really don't know what you did wrong, because I'm not getting any errors.

Side note: your code would be cleaner if you used the loop function as follows:
Code:
function run()
{
	assetList("AssetsFile.csv");
	while(loop(Assets))
	{
		asset(Loop1);
		vars Prices = series(priceClose());
		DChannel(50);
		vars upb = series (rRealUpperBand);
		if (Prices[0] > upb[1])
		enterLong(); 
	}
}


Last edited by AndrewAMD; 02/15/18 19:58.
Re: donchian inside an asset loop [Re: AndrewAMD] #471010
02/15/18 19:49
02/15/18 19:49
Joined: Nov 2017
Posts: 34
C
Cheulmen Offline OP
Newbie
Cheulmen  Offline OP
Newbie
C

Joined: Nov 2017
Posts: 34
Yes, the script compiles correctly, but when I run it the error appears. The problem if I declare the series outside the for(), is that, as I understand, the rRealUpperBand is not going to belong to each one of the Assets[i]. Actually if I declare it outside the for(), probably Zorro won't be able to determine which is the asset that it should calculate.

Re: donchian inside an asset loop [Re: Cheulmen] #471012
02/15/18 20:18
02/15/18 20:18
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
This error cannot be replicated.

Post your exact c file, post your asset csv file, name your broker.

Re: donchian inside an asset loop [Re: AndrewAMD] #471013
02/15/18 22:13
02/15/18 22:13
Joined: Nov 2017
Posts: 34
C
Cheulmen Offline OP
Newbie
Cheulmen  Offline OP
Newbie
C

Joined: Nov 2017
Posts: 34
Yes, it seems something in my script, two of you already said that it works, so I'll have to figure out whats wrong. I understand that if it can't be replicated, it can't be fixed.

I sincerely thank you for your help, I know that you're trying to help, but I don't want to post the script, it is my trading strategy (this was an attempt to improve it) laugh

Thanks again AndrewAMD & Zheka.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1