Gamestudio Links
Zorro Links
Newest Posts
Can't plot daily high & low
by Junker. 10/13/19 23:51
Imgui Lite-c Development
by txesmi. 10/13/19 09:40
A9
by Dooley. 10/11/19 18:53
Need Help Finding Cause of Crash
by Dooley. 10/11/19 18:51
What algorithm is used for BALANCED?
by JamesHH. 10/11/19 17:32
Votes for future features
by AndrewAMD. 10/11/19 14:12
Price not shown correctly via MT4 bridge
by gamadeus. 10/10/19 05:48
Loading Keybindings from a File
by Dooley. 10/10/19 03:44
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
5 registered members (Michael_Schwarz, YG8, kvm, JamesHH, 1 invisible), 637 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
FrankW, TedMar, raimucuk, vivaldi2, filip
18304 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Re: advise calls in TRAINMODE/TESTMODE slow #477923
08/14/19 16:05
08/14/19 16:05
Joined: Jan 2019
Posts: 71
berlin
L
laz Offline OP
Junior Member
laz  Offline OP
Junior Member
L

Joined: Jan 2019
Posts: 71
berlin
Hi guys,

I'm using the advise (NEURAL) functions with Zorro 2.14.
Code
#define INP_LEN 200 
var INP[INP_LEN]; 

avl = adviseLong (NEURAL,obl,INP,INP_LEN);
avs = adviseShort(NEURAL,obs,INP,INP_LEN);
My Input Array has length 200, atm all Inputs are 0 to test something i have seen in TRAINMODE.
Code
73274 Bars 2017-12-26..2018-12-31 generated
AUDUSD MTH0 | Bars 73273 | Bar 1000 | 13385.37 ms 
AUDUSD MTH0 | Bars 73273 | Bar 2000 | 495.60 ms 
AUDUSD MTH0 | Bars 73273 | Bar 3000 | 1348.97 ms 
AUDUSD MTH0 | Bars 73273 | Bar 4000 | 2248.71 ms 
AUDUSD MTH0 | Bars 73273 | Bar 5000 | 2985.90 ms 
AUDUSD MTH0 | Bars 73273 | Bar 6000 | 3813.51 ms 
...
AUDUSD MTH0 | Bars 73273 | Bar 16000 | 11858.95 ms 
AUDUSD MTH0 | Bars 73273 | Bar 17000 | 12596.68 ms 
AUDUSD MTH0 | Bars 73273 | Bar 18000 | 13511.14 ms 
AUDUSD MTH0 | Bars 73273 | Bar 19000 | 14189.44 ms
...
AUDUSD MTH0 | Bars 73273 | Bar 37000 | 28506.39 ms 
AUDUSD MTH0 | Bars 73273 | Bar 38000 | 28744.40 ms 
AUDUSD MTH0 | Bars 73273 | Bar 39000 | 30439.84 ms
While preparing the data for the export you can clearly see, how the time for working with 1000 Bars does increase.
Code
avl = 0;// adviseLong (NEURAL,obl,INP,INP_LEN);
avs = 0;// adviseShort(NEURAL,obs,INP,INP_LEN);
Gives the following result:
Code
AUDUSD MTH0 | Bars 73273 | Bar 27000 | 14.38380 ms 
AUDUSD MTH0 | Bars 73273 | Bar 28000 | 14.35420 ms 
AUDUSD MTH0 | Bars 73273 | Bar 29000 | 14.36570 ms 
AUDUSD MTH0 | Bars 73273 | Bar 30000 | 16.14190 ms 
AUDUSD MTH0 | Bars 73273 | Bar 31000 | 21.45670 ms 
AUDUSD MTH0 | Bars 73273 | Bar 32000 | 14.23840 ms 
AUDUSD MTH0 | Bars 73273 | Bar 33000 | 18.95120 ms 
AUDUSD MTH0 | Bars 73273 | Bar 34000 | 14.29470 ms 
AUDUSD MTH0 | Bars 73273 | Bar 35000 | 15.13100 ms 
AUDUSD MTH0 | Bars 73273 | Bar 36000 | 14.29760 ms 
So i assume that Zorro collects the data in the advise(L/S) calls and is reallocating the memory again and again or something like this?

While doing this Zorro has not called anything in neural(mode = NEURAL_TRAIN), so it looks like i can't fix this?

Any Ideas?

EDIT: Ohh i think i found the reason: https://manual.zorro-project.com/advisor.htm
Quote
For NEURAL_TRAIN the Data parameter is a text string containing all samples in CSV format. The string can be stored in a temporary CSV file and then read by the machine learning algorithm for training the model.
Does Zorro append the new data on every bar, to a string?

Quote
... returned by the neural function; otherwise return 1 if no accuracy is calculated, or 0 for aborting the script when the training failed.
And by the way, 2.14 does not stop training if neural(mode = NEURAL_TRAIN) does return(0);

Last edited by laz; 08/19/19 14:12.
Re: advise calls in TRAINMODE/TESTMODE slow [Re: laz] #477953
08/19/19 12:06
08/19/19 12:06
Joined: Jan 2019
Posts: 71
berlin
L
laz Offline OP
Junior Member
laz  Offline OP
Junior Member
L

Joined: Jan 2019
Posts: 71
berlin
I have now seen, that zorro also works very slowly in TESTMODE when using "empty" adviseLS functions, even if I do not use R at all?

For testing this i have used a modified function result, no R included:
Code
else {
avl = adviseLong (NEURAL,obl,INP,ipc);
avs = adviseShort(NEURAL,obs,INP,ipc);
}

in the r. file:
else if(mode == NEURAL_PREDICT && is(TRAINMODE)) ... not used here
else if(mode == NEURAL_PREDICT && is(TESTMODE)) {return(100.0);}
else if(mode == NEURAL_PREDICT && is(TRADEMODE)) ... not used here

Quote
Multiple assets.......
WFA Test: 2016..2018
BAR_TIME_DBG | Bars 18155 | Bar 4000 | 38103.04 ms <- the first call takes longer because off the R init
BAR_TIME_DBG | Bars 18155 | Bar 5000 | 169496.21 ms <- no R involved from here, very slow
BAR_TIME_DBG | Bars 18155 | Bar 6000 | 186814.09 ms
BAR_TIME_DBG | Bars 18155 | Bar 7000 | 171797.91 ms
BAR_TIME_DBG | Bars 18155 | Bar 8000 | 175170.88 ms

In TESTMODE the runtime is high - but stable high - and not increasing.

Only calling the advise(L/S) functions and returning 100.0 takes so much time?

You can see the difference here:
Code
else {
avl = 100; // adviseLong (NEURAL,obl,INP,ipc);				
avs = 100; // adviseShort(NEURAL,obs,INP,ipc);
}

Quote
Multiple assets.......
WFA Test: 2016..2018
BAR_TIME_DBG | Bars 18155 | Bar 4000 | 292.75 ms
BAR_TIME_DBG | Bars 18155 | Bar 5000 | 829.78 ms
BAR_TIME_DBG | Bars 18155 | Bar 6000 | 817.33 ms
BAR_TIME_DBG | Bars 18155 | Bar 7000 | 867.14 ms

Currently I'm using 7 assets and 4 algos, it takes hours to train and test.

I have build a cache around NEURAL_PREDICT in TESTMODE, in the first run i save the results to a dataset that is loaded in all further runs.

Even with caching it is slow, because of the time the advise() calls already need.

So the caching only gives me a small performance boost, something inside advise() takes a lot of time, can you check this please?

Is Zorro possibly checking if R is running inside advise(NEURAL)?

Last edited by laz; 08/20/19 00:11.
Re: advise calls in TRAINMODE/TESTMODE slow [Re: laz] #477961
08/19/19 16:17
08/19/19 16:17
Joined: Jan 2019
Posts: 71
berlin
L
laz Offline OP
Junior Member
laz  Offline OP
Junior Member
L

Joined: Jan 2019
Posts: 71
berlin
Here is the "minimal" reproducible example...

Just change #define MY_ALIST "Assets\\oanda.csv" to one that includes "AUDUSD","EURUSD" and histo from 2016 to 2018.

Only 2 assets and 2 algos are used, maybe i have done something wrong or there is a problem...

TRAINMODE
1. First hit TRAIN, you see how the time does increase and Zorro is getting slower and slower....
2. Change TEST_NO_ADVISE to TRUE, hit TRAIN again, that's really fast!
Quote
AUDUSD AL0 | Bars 72751 | Bar 1000 | 976.77 ms
AUDUSD AL0 | Bars 72751 | Bar 2000 | 1079.94 ms
...
AUDUSD AL0 | Bars 72751 | Bar 7000 | 4884.04 ms
AUDUSD AL0 | Bars 72751 | Bar 8000 | 5679.69 ms

TEST_NO_ADVISE TRUE
AUDUSD AL0 | Bars 72751 | Bar 8000 | 8.87 ms
AUDUSD AL0 | Bars 72751 | Bar 9000 | 7.34 ms
...
AUDUSD AL0 | Bars 72751 | Bar 18000 | 12.68 ms
AUDUSD AL0 | Bars 72751 | Bar 19000 | 9.96 ms

TESTMODE
1. Change TEST_NO_ADVISE back to FALSE
2. Hit TEST, you see how much time the simple calls need? It looks fast but wait...
3. Change TEST_NO_ADVISE to TRUE, hit TEST again, that's really fast!

Just calling the advise framework and getting simple returns does take so much time, has no one seen that before?

Attached Files
advise-slow-test-0.c (19 downloads)
Last edited by laz; 08/20/19 00:12.
Re: advise calls in TRAINMODE/TESTMODE slow [Re: laz] #477964
08/20/19 08:24
08/20/19 08:24
Joined: Jul 2000
Posts: 27,024
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,024
Frankfurt
The advise functions are very fast. So I would suspect that something else in your code is slow, like still calling an R function despite your changes to the neural function.

For checking what it is, simply replace NEURAL with PERCEPTRON and train again - if you then see a speed increase in the test, it's something in your R code.

Re: advise calls in TRAINMODE/TESTMODE slow [Re: laz] #477975
08/20/19 13:04
08/20/19 13:04
Joined: Jan 2019
Posts: 71
berlin
L
laz Offline OP
Junior Member
laz  Offline OP
Junior Member
L

Joined: Jan 2019
Posts: 71
berlin
Thanks jcl, but have you downloaded and executed my plain text (not compiled) example (advise-slow-test-0.c)?

I'm sorry but I'm really sure that it can't be in my code, because all what is done by the script is visible in the script?

If you download my posted example from above, you will see that no further R code is used there.

You should be able to reproduce it, or have you tested it with my example and observed a different behavior?

I also had DebugView running, the only R call it does - is the Rstart/Rinit at the beginning, as you can see in my example...

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Edit: I did the test with PERCEPTRON, same problem during TRAIN the runtime is increasing more and more:
Quote
advise-slow-test-0 compiling...............
PERCEPTRON test
72752 Bars 2016-01-03..2018-12-31 generated
AUDUSD AL0 | Bars 72751 | Bar 0 | 0.00 ms
Rules: advise-slow-test-0 2016..2018
Assets Assets\oanda.csv
AUDUSD AL0 | Bars 72751 | Bar 1000 | 303.89 ms
AUDUSD AL0 | Bars 72751 | Bar 2000 | 1109.34 ms
AUDUSD AL0 | Bars 72751 | Bar 3000 | 1861.84 ms
AUDUSD AL0 | Bars 72751 | Bar 4000 | 2664.03 ms
...
AUDUSD AL0 | Bars 72751 | Bar 12000 | 8534.14 ms
AUDUSD AL0 | Bars 72751 | Bar 13000 | 9076.41 ms
AUDUSD AL0 | Bars 72751 | Bar 14000 | 9740.15 ms
AUDUSD AL0 | Bars 72751 | Bar 15000 | 10468.17 ms
But with the perceptron TESTMODE is very fast, so I stick to my assumption that something is wrong in TRAINMODE and in TESTMODE it only seems to occur when using NEURAL, as described above.

Last edited by laz; 08/20/19 13:52.
Re: advise calls in TRAINMODE/TESTMODE slow [Re: laz] #477978
08/20/19 13:58
08/20/19 13:58
Joined: Jul 2000
Posts: 27,024
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,024
Frankfurt
No, sorry, I have not the time to download and test examples these days. If you can't find the reason of the slowness yourself, your final resort would be Zorrol support.

Re: advise calls in TRAINMODE/TESTMODE slow [Re: laz] #477979
08/20/19 14:08
08/20/19 14:08
Joined: Jan 2019
Posts: 71
berlin
L
laz Offline OP
Junior Member
laz  Offline OP
Junior Member
L

Joined: Jan 2019
Posts: 71
berlin
Ok thanks, as it seems to happen inside the advise() function I'm not able to see whats going on.

I'll write the support and report the feedback here wink

Last edited by laz; 08/20/19 14:09.
Re: advise calls in TRAINMODE/TESTMODE slow [Re: laz] #477984
08/21/19 11:30
08/21/19 11:30
Joined: Jan 2019
Posts: 71
berlin
L
laz Offline OP
Junior Member
laz  Offline OP
Junior Member
L

Joined: Jan 2019
Posts: 71
berlin
I can now add, that the increasing runtime problem in TRAINMODE is caused by the length of the INPUT array.

If you only use 10 or 20 inputs it is still fast enough, you will normally not recognize it, try it with 200 or 400 and you will see how slow it gets...

It would be nice, if someone could check this again, to rule out that it is my pc.

I'm still writing with the support, they don't believe it at the moment...

Just edit the Asset List and hit TRAIN...
Quote
AUDUSD AL0 | Bars 72751 | Bar 1000 | 1687.30 ms
AUDUSD AL0 | Bars 72751 | Bar 2000 | 4019.43 ms
AUDUSD AL0 | Bars 72751 | Bar 3000 | 7046.14 ms
AUDUSD AL0 | Bars 72751 | Bar 4000 | 10052.15 ms
AUDUSD AL0 | Bars 72751 | Bar 5000 | 13112.27 ms
AUDUSD AL0 | Bars 72751 | Bar 7000 | 19015.53 ms
AUDUSD AL0 | Bars 72751 | Bar 8000 | 22016.81 ms
AUDUSD AL0 | Bars 72751 | Bar 9000 | 24695.24 ms

Attached Files
advise-slow-test-0.c (9 downloads)
Last edited by laz; 08/21/19 12:50.
Re: advise calls in TRAINMODE/TESTMODE slow [Re: laz] #477990
08/22/19 11:43
08/22/19 11:43
Joined: Jan 2019
Posts: 71
berlin
L
laz Offline OP
Junior Member
laz  Offline OP
Junior Member
L

Joined: Jan 2019
Posts: 71
berlin
The support has now recognized the problem and will take care of it, but it may take a while...

Re: advise calls in TRAINMODE/TESTMODE slow [Re: laz] #478079
09/03/19 20:05
09/03/19 20:05
Joined: Jan 2019
Posts: 71
berlin
L
laz Offline OP
Junior Member
laz  Offline OP
Junior Member
L

Joined: Jan 2019
Posts: 71
berlin
I found a solution for the problem in TESTMODE :

The if(!wait(0)) return(0.0); in neural() creates the delay, at least on my machine.

Removing it works, i can press buttons, everything works, but much faster!!!

with if(!wait(0)) return(0.0); // >>> this creates a huge delay !!!

advise-slow-test-0 compiling..............
EURUSD AL1 | Bars 72751 | Bar 15000 | 527.22 ms
EURUSD AL1 | Bars 72751 | Bar 16000 | 21165.36 ms
EURUSD AL1 | Bars 72751 | Bar 17000 | 24793.54 ms
EURUSD AL1 | Bars 72751 | Bar 18000 | 25280.05 ms
EURUSD AL1 | Bars 72751 | Bar 19000 | 24935.06 ms

without if(!wait(0)) return(0.0);

advise-slow-test-1 compiling..............
EURUSD AL1 | Bars 72751 | Bar 15000 | 574.12 ms
EURUSD AL1 | Bars 72751 | Bar 16000 | 167.46 ms
EURUSD AL1 | Bars 72751 | Bar 17000 | 368.84 ms
EURUSD AL1 | Bars 72751 | Bar 18000 | 371.19 ms
EURUSD AL1 | Bars 72751 | Bar 19000 | 358.33 ms
EURUSD AL1 | Bars 72751 | Bar 20000 | 359.30 ms
EURUSD AL1 | Bars 72751 | Bar 21000 | 360.95 ms
EURUSD AL1 | Bars 72751 | Bar 22000 | 351.55 ms

I'll send a copy to the support...

But everyone can test it in its own project, just overwrite the neural() function and test it without the wait()...

Download both, edit assetList and hit TEST...

Attached Files
advise-slow-test-0.c (5 downloads)
advise-slow-test-1.c (5 downloads)
Last edited by laz; 09/05/19 22:49.
Re: advise calls in TRAINMODE/TESTMODE slow [Re: laz] #478110
09/09/19 09:21
09/09/19 09:21
Joined: Jul 2000
Posts: 27,024
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,024
Frankfurt
wait(0) triggers the Windows message system and is of course very slow. Can take several hundred microseconds on slow systems. Don't call it on any iteration in a fast loop.

Page 1 of 2 1 2

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