Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Edgar_Herrera, VoroneTZ, Akow), 973 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 8 of 20 1 2 6 7 8 9 10 19 20
Re: One Night Stand System [Re: Sphin] #456231
11/15/15 20:05
11/15/15 20:05
Joined: Jun 2013
Posts: 1,609
D
DdlV Offline
Serious User
DdlV  Offline
Serious User
D

Joined: Jun 2013
Posts: 1,609
Re. the issue of backtest vs. trading, have you tried whatever settings make the backtest approximate trading as much as possible (such as TICKS)?

HTH.

Re: One Night Stand System [Re: DdlV] #456252
11/16/15 00:53
11/16/15 00:53
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Successful exit this morning of the USD/CHF trade. So the script is functioning on Zorro 1.32.

Attached Files ONS Sphin 16-11-2015.jpg
Last edited by RTG; 11/16/15 00:53.
Re: One Night Stand System [Re: RTG] #456359
11/20/15 00:57
11/20/15 00:57
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Setups this morning

Attached Files ONS Sphin 20-11-2015.jpg
Last edited by RTG; 11/20/15 01:00.
Re: One Night Stand System [Re: RTG] #456378
11/20/15 20:07
11/20/15 20:07
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
The more I debug the more I am confused. I tested 3 different situations and got 3 different results. But all tested Zorro versions behave identical. RTG, you got a lucky Zorro version! laugh And sorry for the long post but most of it are extracts from log files.

The debug code is:

Code:
bool SMAShortR = rising(SMAShort);
bool SMAShortF = falling(SMAShort);
bool SMALongR = rising(SMALong);
bool SMALongF = falling(SMALong);
printf("\n%s: SMAShort:%.5f (%i|%i), SMALong: %.5f (%i|%i)",Asset,SMAShort[0],SMAShortF,SMAShortR,SMALong[0],SMALongF,SMALongR);

within the run function, that will print each bar the Asset, both SMAs and additionally (1|0) if a SMA is falling or (0|1) if a SMA is rising.

Further the run function contains both conditions and prints additional statements if the conditions become true:
Code:
if (dow() == 5 && NumOpenLong == 0 && NumPendingLong == 0 && SMAShort[0] > SMALong[0] && rising(SMAShort) && rising(SMALong)) {
	Margin = 0.1 * OptimalFLong * Capital;
	printf("\nNow I setup a long trade with a margin of %.5f and a BuyStop of %.5f",Margin,BuyStop);
	enterLong(0,BuyStop);
}

else if (dow() == 5 && NumOpenShort == 0 && NumPendingShort == 0 && SMAShort[0] < SMALong[0] && falling(SMAShort) && falling(SMALong)) {
	Margin = 0.1 * OptimalFShort * Capital;
	printf("\nNow I setup a short trade with a margin of %.5f and a SellStop of %.5f",Margin,SellStop);
	enterShort(0,SellStop);			
}



In live trading today for Zorro the conditions do not become true. The results of today:
Code:
[199: Fri 20.11.15 00:00]  1.06717
AUD/JPY: SMAShort:87.64640 (0|1), SMALong: 86.44920 (1|0)
AUD/USD: SMAShort:0.71158 (1|0), SMALong: 0.71495 (1|0)     <- true short
CHF/JPY: SMAShort:122.14255 (1|0), SMALong: 123.27503 (1|0) <- true short
EUR/JPY: SMAShort:132.20616 (1|0), SMALong: 133.86478 (1|0) <- true short
EUR/USD: SMAShort:1.07097 (1|0), SMALong: 1.11468 (1|0)     <- true short
GBP/USD: SMAShort:1.52224 (0|1), SMALong: 1.52888 (0|1)
NZD/CHF: SMAShort:0.65758 (0|1), SMALong: 0.64897 (0|1)     <- true long
NZD/JPY: SMAShort:80.34877 (1|0), SMALong: 79.50937 (0|1)
USD/CHF: SMAShort:1.00769 (0|1), SMALong: 0.98152 (0|1)     <- true long
USD/JPY: SMAShort:123.03126 (0|1), SMALong: 120.91281 (1|0)
USOil: SMAShort:43.43371 (1|0), SMALong: 44.72632 (1|0)     <- true short

But there are no "Now I setup ..." prints, so Zorro does not recognize the conditions are true, although in 7 cases they are.

In backtest it depends - if the simulation ends on a Friday, then you will find like for today:
Code:
[229: Fri 20.11.15 00:00]  
AUD/JPY: SMAShort:87.65658 (0|1), SMALong: 86.45531 (1|0)
AUD/USD: SMAShort:0.71160 (1|0), SMALong: 0.71498 (1|0)
Now I setup a short trade with a margin of 18.10000 and a SellStop of 0.70153
CHF/JPY: SMAShort:122.14400 (1|0), SMALong: 123.27348 (1|0)
Now I setup a short trade with a margin of 99.90000 and a SellStop of 120.74000
EUR/JPY: SMAShort:132.21563 (1|0), SMALong: 133.87261 (1|0)
Now I setup a short trade with a margin of 99.90000 and a SellStop of 130.63700
EUR/USD: SMAShort:1.07096 (1|0), SMALong: 1.11471 (1|0)
Now I setup a short trade with a margin of 53.10000 and a SellStop of 1.06160
GBP/USD: SMAShort:1.52221 (0|1), SMALong: 1.52886 (0|1)
NZD/CHF: SMAShort:0.65756 (0|1), SMALong: 0.64893 (0|1)
Now I setup a long trade with a margin of 0.00000 and a BuyStop of 0.66823
NZD/JPY: SMAShort:80.37250 (1|0), SMALong: 79.50871 (0|1)
USD/CHF: SMAShort:1.00745 (0|1), SMALong: 0.98147 (0|1)
Now I setup a long trade with a margin of 99.90000 and a BuyStop of 1.02221
USD/JPY: SMAShort:123.01745 (0|1), SMALong: 120.91655 (1|0)
USOil: SMAShort:43.51261 (1|0), SMALong: 44.73911 (1|0)
Now I setup a short trade with a margin of 22.60000 and a SellStop of 39.91000

In contrast to live trading Zorro confirms at least the 7 true conditions in the backtest of today as you can see printed, but it does not setup trades. I can imagine that Zorro does not setup new trades on the very last day/bar of the simulation.

This can be adjusted e.g. also for last Friday with "EndDate = 20151113;" and the result is similar:
Code:
[224: Fri 13.11.15 00:00] 
AUD/JPY: SMAShort:86.99101 (0|1), SMALong: 86.74006 (1|0)
AUD/USD: SMAShort:0.71483 (1|0), SMALong: 0.71665 (1|0)
Now I setup a short trade with a margin of 18.10000 and a SellStop of 0.70153
CHF/JPY: SMAShort:122.79858 (1|0), SMALong: 123.53941 (1|0)
Now I setup a short trade with a margin of 99.90000 and a SellStop of 121.67200
EUR/JPY: SMAShort:132.70861 (1|0), SMALong: 134.26398 (1|0)
Now I setup a short trade with a margin of 99.90000 and a SellStop of 131.46501
EUR/USD: SMAShort:1.07799 (1|0), SMALong: 1.11715 (1|0)
Now I setup a short trade with a margin of 53.10000 and a SellStop of 1.06735
GBP/USD: SMAShort:1.51720 (1|0), SMALong: 1.53036 (1|0)
Now I setup a short trade with a margin of 63.20000 and a SellStop of 1.50264
NZD/CHF: SMAShort:0.66013 (1|0), SMALong: 0.64352 (0|1)
NZD/JPY: SMAShort:80.84656 (1|0), SMALong: 79.08822 (0|1)
USD/CHF: SMAShort:0.99684 (0|1), SMALong: 0.97678 (0|1)
Now I setup a long trade with a margin of 99.90000 and a BuyStop of 1.00885
USD/JPY: SMAShort:121.99323 (0|1), SMALong: 121.02335 (1|0)
USOil: SMAShort:45.06625 (1|0), SMALong: 44.92631 (1|0)



Only if you include at least the following Monday (here: EndDate = 20151116) then you'll see the result like expected in all cases - Zorro setup trades if the conditions become true:
Code:
[224: Fri 13.11.15 00:00]  
AUD/JPY: SMAShort:86.99101 (0|1), SMALong: 86.74006 (1|0)
AUD/USD: SMAShort:0.71483 (1|0), SMALong: 0.71665 (1|0)
Now I setup a short trade with a margin of 18.10000 and a SellStop of 0.70153
(AUD/USD::S) Short 2@0.7015 Entry stop
CHF/JPY: SMAShort:122.79858 (1|0), SMALong: 123.53941 (1|0)
Now I setup a short trade with a margin of 99.90000 and a SellStop of 121.67200
(CHF/JPY::S) Short 2@121.67 Entry stop
EUR/JPY: SMAShort:132.70861 (1|0), SMALong: 134.26398 (1|0)
Now I setup a short trade with a margin of 99.90000 and a SellStop of 131.46501
(EUR/JPY::S) Short 10@131.47 Entry stop
EUR/USD: SMAShort:1.07799 (1|0), SMALong: 1.11715 (1|0)
Now I setup a short trade with a margin of 53.10000 and a SellStop of 1.06735
(EUR/USD::S) Short 5@1.0674 Entry stop
GBP/USD: SMAShort:1.51720 (1|0), SMALong: 1.53036 (1|0)
Now I setup a short trade with a margin of 63.20000 and a SellStop of 1.50264
(GBP/USD::S) Short 4@1.5026 Entry stop
NZD/CHF: SMAShort:0.66013 (1|0), SMALong: 0.64352 (0|1)
NZD/JPY: SMAShort:80.84656 (1|0), SMALong: 79.08822 (0|1)
USD/CHF: SMAShort:0.99684 (0|1), SMALong: 0.97678 (0|1)
Now I setup a long trade with a margin of 99.90000 and a BuyStop of 1.00885
(USD/CHF::L) Long 2@1.0088 Entry stop
USD/JPY: SMAShort:121.99323 (0|1), SMALong: 121.02335 (1|0)
USOil: SMAShort:45.06625 (1|0), SMALong: 44.92631 (1|0)
[...]
[225: Mon 16.11.15 00:00]



The main question is why Zorro does not recognize in live trading if the conditions become true while it does in backtest. Sure, I cannot exclude an error in the script, but I would really like to know where it is because I can't see it.

The results in live trading are identical with 1.32, 1.36 and 1.38, the simulation is done with 1.36 only.

Thanks, Sphin

Re: One Night Stand System [Re: Sphin] #456386
11/20/15 22:43
11/20/15 22:43
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline
Senior Member
boatman  Offline
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
As I understand this system, the entries are dependent on the time of day and the day of the week. Without analysing the script and the log files Sphin posted (competing priorities at the moment) I would hazard a guess that the issue may be associated with the MT4 server time or the 'weekend' settings in the script. Has anyone looked into those in any detail?

Re: One Night Stand System [Re: boatman] #456387
11/20/15 23:08
11/20/15 23:08
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
There is no MT4 server involved (FXCM via API) and there is no weekend setting in the script. The whole (and IMO very simple) script is depicted in a former entry within this thread.

Re: One Night Stand System [Re: Sphin] #456389
11/21/15 00:50
11/21/15 00:50
Joined: Jun 2013
Posts: 1,609
D
DdlV Offline
Serious User
DdlV  Offline
Serious User
D

Joined: Jun 2013
Posts: 1,609
Hi Sphin. Like boatman I can't look in detail at the moment, but I've had some success in the past printf'ing an if's entire expression and each of the component sub-expressions; as well as breaking big if's into a series of individual if's. To paraphrase jcl, without a debugger printf is your best friend - don't be afraid to take it to what initially seem like silly extremes! laugh

HTH.

Re: One Night Stand System [Re: DdlV] #456400
11/21/15 11:37
11/21/15 11:37
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Okay, I unterstood that I shall find out which part of the combined conditions exactly fails, that makes sense.

But can anyone point out if the behaviour of Zorro not to open trades at the last bar of the simulation is normal? This is independent of the condition(s) because they are passed through already that moment and the "enter"-command is the very next one to the "print" and there is no condition or similar in between that could be debugged.

Last edited by Sphin; 11/21/15 13:14.
Re: One Night Stand System [Re: Sphin] #456446
11/23/15 11:13
11/23/15 11:13
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
The last bar of the simulation is indicated with the EXITRUN flag. Zorro closes all trades on this bar.

As to the printing, DdlV is right: If the printed conditions contradict the result, then the bug is in the remaining conditions. Quoting Sherlock Holmes: When you have eliminated the impossible, whatever remains, however improbable, must be the truth. My first suspect in your if() line would be the dow() - check if this condition can ever be true before the weekend. It depends on which bars you're using.

Re: One Night Stand System [Re: jcl] #456467
11/24/15 00:59
11/24/15 00:59
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Quote:
The last bar of the simulation is indicated with the EXITRUN flag. Zorro closes all trades on this bar.
This is also an interesting information but my question was if Zorro opens a trade on the last bar or is this prevented in advance e.g. because Zorro would close it the same bar anyway?

The result from live trading (now with additionally printed dow()) of today makes me a little bit amazed:

Code:
[196: Tue 24.11.15 00:00]  1.06305

1 - AUD/JPY: SMAShort:88.00980 (0|1), SMALong: 86.35982 (1|0)

[...]


The "1" for dow() does not correspond to "Tuesday" and in test runs, there is also a "2" like expected.
What do you mean with which bars am I using? The script uses a BarPeriod of 1440 and beside of this I think it uses "normal" bars because I did not change any defaults especially concerning bars.

Page 8 of 20 1 2 6 7 8 9 10 19 20

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