Gamestudio Links
Zorro Links
Newest Posts
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 962 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Inconsistent series populated by several for loops - how to fix? #463087
11/14/16 19:36
11/14/16 19:36
Joined: Nov 2016
Posts: 7
CA - California
M
Mucko Offline OP
Newbie
Mucko  Offline OP
Newbie
M

Joined: Nov 2016
Posts: 7
CA - California
I have several for loops that look at the last 10 bars for a high/low pattern. One loop records a high values if high pattern found, another loop records the low value if pattern found.

This data is then put into a WMA function for the last x values.

However, I am getting Error 041:Inconsistent Series! error. I believe the issue is that the arrays are not populated with the same length nor at the same time.

I am not sure how to fix this error - any help would be appreciated.

Code snippet (for High):

if (Close[1] > Open[1] and Close[0] < Open[0]) {
double u11 = High[1];

for (qq=1;qq<=len; qq++)
if (qq <= ttfinal)
qqtot+= u11;
else
qqtot += (High[qq - (ttfinal -1)]);


vars u1 = series((qqtot/len));
qqtot = 0;
hcount +=1;
}
vars upp = series(WMA(u1,len));

Re: Inconsistent series populated by several for loops - how to fix? [Re: Mucko] #463099
11/15/16 05:07
11/15/16 05:07
Joined: Nov 2016
Posts: 7
CA - California
M
Mucko Offline OP
Newbie
Mucko  Offline OP
Newbie
M

Joined: Nov 2016
Posts: 7
CA - California
Solved - I think

I think I have solved it with a bit of added code. Still need to test if it gives the same result as the original code (ported from MC/TS), but it does not give inconsistent errors any longer and can plot values which appear correct from initial appearances.

Here is what I had to add, removing the series function from inside the for loop but still inside the if conditional. Rather than loop I simply manually populate and increment.

This is defined outside the conditional:
q = series();

this is inside the conditional:
q[hcount] = (qqtot/len);
hcount +=1;
qqtot = 0;


Moderated by  Petra 

Gamestudio download | chip programmers | 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