Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
M1 Oversampling
by 11honza11. 04/20/24 20:57
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
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 177 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Using ":L" & ":S" causes 2 possible bug(s) or is it bad coding? #476039
01/21/19 10:32
01/21/19 10:32
Joined: Jan 2019
Posts: 73
berlin
L
laz Offline OP
Junior Member
laz  Offline OP
Junior Member
L

Joined: Jan 2019
Posts: 73
berlin
OFF-TOPIC
Hi guys, this is my first post here and I'm really excited to be here. Many thanks to the creators of Zorro, you have really developed a great program - its surface is tiny - but there is something in it. Thank you also for the effort you put into assisting your users. I've been programming for many years, but I'm new to Lite-C and Zorro. English is not my mother tongue and everything I know about programming I have taught myself. That's why I sometimes express myself inaccurately or wrongly, thanks for your understanding.
OFF-TOPIC


I've found 2 errors, maybe I've also programmed something wrong, please take a look at it. I've upload 4 files to test with, parameter_test_"1-4".c.

Let's start with file (parameter_test_1.c)...

After [TRAIN] everything looks fine, training is fast and we get some results. We have optimized 2 parameters, we see 2 pictures in the parameter charts htm file.

If we change only 1 line in the code now, the problems will start: (in parameter_test_2.c)
Code:
while(asset(loop("EURUSD")))
while(algo(loop("TRND"))) {

changes to:

while(asset(loop("EURUSD")))
while(algo(loop("TRND:L","TRND:S"))) {


We now need twice as long as we train 2 different components, that's normal. We should now be able to see parameter charts
in which the optimized values for 2x2 parameters are visible. Zorro creates a parameter chart with 4 images,
but if you look closer, the 2 x 2 are the same?
Code:
<h1>parameter_test_2 Parameter Charts</h1>
<p> EURUSD TRND Parameter 1 (10 Cycles Average: 172.1)<br> <br><img src="parameter_test_2_EURUSD_TRND_p1.png"></p>
<p> EURUSD TRND Parameter 2 (10 Cycles Average: 1.798)<br> <br><img src="parameter_test_2_EURUSD_TRND_p2.png"></p>
<p> EURUSD TRND Parameter 1 (10 Cycles Average: 172.1)<br> <br><img src="parameter_test_2_EURUSD_TRND_p1.png"></p>
<p> EURUSD TRND Parameter 2 (10 Cycles Average: 1.798)<br> <br><img src="parameter_test_2_EURUSD_TRND_p2.png"></p>


Here is the first problem, test it with parameter_test_2.c
It shows 4 but only 2 not 2X2=4 graphics have been created, "parameter_test_2_EURUSD_TRND_p1.png" and "parameter_test_2_EURUSD_TRND_p2.png".

Not 2 for :L and 2 for :S...

Has anyone noticed this or have I already done something wrong here? I thought it was because I forgot to assign
the enterLong and enterShort to the respective component. So let's do that:(in parameter_test_3.c)
Code:
if(valley(sig)) enterLong(); else
if(peak(sig)) enterShort();

changes to:

if(strstr(Algo,":L") && valley(sig)) enterLong(); else
if(strstr(Algo,":S") && peak(sig)) enterShort();


At this point, something was strange, Zorro was slowing down and you can see that the runtimes have increased.
Code:
EXITRUN @ bar 9955 time = 3234.774 ms
EXITRUN @ bar 9955 time = 6970.485 ms


Nothing strange in the log file, only the runtimes are much larger. I stopped it, it's time to make Verbose more active.

Does that happen because Zorro does not close the trades anymore? Or is something crashing here?
I changed the script and added exitLong() and exitShort() in (parameter_test_4.c). This works and is just as fast as version parameter_test_2.

But... Unfortunately at the end of this trip I realized that the parameter charts from parameter_test_4.c are still wrong wink...

Thanks for your help laugh

[EDIT] I've removed the part with diag and Chinese signs in it because that seems to be only here for me...

Attached Files
parameter_test_1.c (36 downloads)
parameter_test_2.c (50 downloads)
parameter_test_3.c (57 downloads)
parameter_test_4.c (37 downloads)
Last edited by laz; 01/23/19 21:25.
Re: Using ":L" & ":S" causes 2 possible bug(s) or is it bad coding? [Re: laz] #476040
01/21/19 15:32
01/21/19 15:32
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Since most of us don't have the time to download your zip file and dig through your stuff, consider boiling down your question to a single miniature-sized script and say, "I expect X, but I get Y". You'll get answers quickly that way. laugh

Re: Using ":L" & ":S" causes 2 possible bug(s) or is it bad coding? [Re: AndrewAMD] #476042
01/21/19 16:51
01/21/19 16:51
Joined: Jan 2019
Posts: 73
berlin
L
laz Offline OP
Junior Member
laz  Offline OP
Junior Member
L

Joined: Jan 2019
Posts: 73
berlin
Hi Andrew. I have added all files and i changed my first post to make it more clear.

In short:

parameter_test_1.c runs fine, but has only 1 component called TRND.
parameter_test_2.c runs fine, we now use 2 components TRND:L & TRND:S but parameter chart is wrong, it shows 2 times the same pictures
parameter_test_3.c is slow has many open handles and it sometimes creates chinese signs in diag file (for me with Verbose = 7|DIAG; enabled )
parameter_test_4.c runs fine but the parameter chart is still wrong

I think the problem in parameter_test_3.c are the open trades, it does not close the trades anymore or something else is going wrong. I'm confused because of the chinese signs in diagfile.

I hope it's more clear now wink...

Last edited by laz; 01/21/19 17:13.
Re: Using ":L" & ":S" causes 2 possible bug(s) or is it bad coding? [Re: laz] #476044
01/21/19 18:53
01/21/19 18:53
Joined: Feb 2017
Posts: 369
D
Dalla Offline
Senior Member
Dalla  Offline
Senior Member
D

Joined: Feb 2017
Posts: 369
One thing I would try is to name the algos something other than
TRND:L and TRND:S. Maybe just TRNDL and TRNDL. Since the strategy report short long/short trades using the :L/:S suffix, maybe they are used internally by Zorro.

Re: Using ":L" & ":S" causes 2 possible bug(s) or is it bad coding? [Re: Dalla] #476045
01/21/19 19:37
01/21/19 19:37
Joined: Jan 2019
Posts: 73
berlin
L
laz Offline OP
Junior Member
laz  Offline OP
Junior Member
L

Joined: Jan 2019
Posts: 73
berlin
Hi Dalla, that works but the manual says:

http://manual.zorro-trader.com/algo.htm

Quote:
If different algorithms or parameters for long and short trades are used, the identifiers should end with ":L" or ":S" for being consistent with the trade names used in the message window and parameter files. Long trades should be suppressed by script on ":S" algos and vice versa.

Thanks for the hint, did I get it wrong?

Incidentally, I have already tried that, then you have an OptimalF for the component but either OptimalFLong = 0 or OptimalFShort = 0.

(TRENDL -> OptimalFLong has a value and OptimalFShort = 0) or
(TRENDS -> OptimalFShort has a value and OptimalFLong = 0)

Last edited by laz; 01/21/19 19:56.
Re: Using ":L" & ":S" causes 2 possible bug(s) or is it bad coding? [Re: laz] #476047
01/22/19 09:04
01/22/19 09:04
Joined: Feb 2017
Posts: 369
D
Dalla Offline
Senior Member
Dalla  Offline
Senior Member
D

Joined: Feb 2017
Posts: 369
It was just a thought, but you should probably trust the manual rather than me :-)

Re: Using ":L" & ":S" causes 2 possible bug(s) or is it bad coding? [Re: Dalla] #476049
01/22/19 17:16
01/22/19 17:16
Joined: Jan 2019
Posts: 73
berlin
L
laz Offline OP
Junior Member
laz  Offline OP
Junior Member
L

Joined: Jan 2019
Posts: 73
berlin
Hello Dalla smile. I know you, because I've read a lot of you here in the forum, by Andrew too. I respect you guys and know that you are experienced Zorro users...

By the way, the problem with the Chinese characters in diag file seems to be a problem only with me, I had that yesterday with another script. When opening the diag file with gedit there are sometimes cryptic unreadable characters in it.

I hope you are not angry with me that I do not implement the tip, as you can see here there are several different sources in which :L and :S are used:

https://opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=407922
https://opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=408151#Post408151
http://www.forexfabrik.de/topic/3273-zorro-trader
https://forums.babypips.com/t/automated-trading-course-part-2-strategy-design/46305/24

Jcl has posted:
Quote:
They are the same algorithms as before, only now separately for long and short trades by adding a “:L” or a “:S” to the algorithm identifier. Accordingly, some code within the trade functions must ensure that only the right sort of trades are opened:

if(strstr(Algo,":L") and crossUnder(Signal,-Threshold))
enterLong();
else if(strstr(Algo,":S") and crossOver(Signal,Threshold))
enterShort();

But the links they are very old, some are from 2012...? I'm just wondering why this has not been noticed yet, so I was also unsure if I even ask;).

Please check the attached script, the "Parameter Charts" it generates are clearly wrong. It shows the same pictures twice?

Attached Files
babypips_jcl_LS.c (37 downloads)
Last edited by laz; 01/23/19 20:46.
Re: Using ":L" & ":S" causes 2 possible bug(s) or is it bad coding? [Re: laz] #476050
01/23/19 02:54
01/23/19 02:54
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
You have the **option** of using separate ":L" and ":S" suffixed algos, and now you can see the consequences of this approach.

It is easier to keep the algo names completely different in the first place, because:

1) They are more distinct in all respects (such as chart names), and
2) Optimal F values will not be assigned to algo longs/shorts where trades do not take place.
3) Since you will be **required** to only do long trades with ":L" and short with ":S", you will find that there is not much difference anyways.

EDIT:
Why not do both? A unique algo name **and** “:L” or “:S” at the end?

Last edited by AndrewAMD; 01/23/19 11:17.
Re: Using ":L" & ":S" causes 2 possible bug(s) or is it bad coding? [Re: AndrewAMD] #476055
01/23/19 20:10
01/23/19 20:10
Joined: Jan 2019
Posts: 73
berlin
L
laz Offline OP
Junior Member
laz  Offline OP
Junior Member
L

Joined: Jan 2019
Posts: 73
berlin
Quote:
You have the **option** of using separate ":L" and ":S" suffixed algos, and now you can see the consequences of this approach.

crazy smirk
Quote:
You got a car with 5 gears, but if you switch to the 5 gear you will find the engine out below. Then you go to the dealer and he says: "You have the option to use 5 gears, now you see the consequences..."

tongue

Haha sorry that was a joke, I use Zorro for free and do not want to complain. But it would be great if they could fix that, actually everything works great, except that the parameter charts are wrong.

The other suggestions are possible as a workaround, but I wanted to know if I made a mistake or the program. And actually, I was pretty surprised that so far no one noticed it.

Zorro even seems to calculate the parameters internally, only the images shown in "Parameter Charts" are wrong.

Code:
EURUSD CNTR Parameter 2 (8 Cycles Average: 0.878)
EURUSD CNTR Parameter 2 (8 Cycles Average: 1.173)


correct:
Code:
EURUSD CNTR:L Parameter 2 (8 Cycles Average: 0.878)
EURUSD CNTR:S Parameter 2 (8 Cycles Average: 1.173)


Re: Using ":L" & ":S" causes 2 possible bug(s) or is it bad coding? [Re: laz] #476056
01/23/19 20:20
01/23/19 20:20
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Does your car not have a manual transmission? You learn how to use it by combining proper instruction with real experience. laugh

This is my recommendation: instead of this:

Code:
loop("TRND:L","TRND:S")



Do this:

Code:
loop("TRNDL:L","TRNDS:S")


Page 1 of 2 1 2

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1