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), 552 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 20 1 2 3 19 20
One Night Stand System #452807
06/26/15 01:49
06/26/15 01:49
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
I thought I would start coding and testing this somewhat famous strategy. I like that it is invested for a small proportion of time and seems to capture a decent amount of price movement.

From the pdf located at: http://www.forexmt4.com/_MT4_Systems/one%20night%20stand/OneNIghtStand%20Ruleset.pdf

One Night Stand Ruleset:

To show how easy and profitable a Forex trading business can be structured is by viewing the theoretical results of a well-known public system that I've traded ever since Joe Krutsinger gave it to me (and everyone else) at a trading seminar fifteen years ago. It was Joe's custom at every seminar he spoke, to give away the currency trading system One Night Stand to the attendees. He stated only one person in a hundred was able to keep trading it because of a perversity element required. He did say that he believed it worked so well due to the human tendency to resist staying in the currency markets over weekends, and expected it to continue to work well into the future.
I've traded it in the currencies ever since. And the system works just the same as it did a decade and half ago. It isn't hard for me to trade because I'm used to buying new highs and selling new lows. The rules I use are as follows:
● Buy only on Fridays--- at one pip above the highest high of the last ten days--- if the 10 day simple moving average is above the 40 day simple moving average.
● Sell only on Fridays--- at one pip below the lowest low of the last ten days--- if the 10 day simple moving average is below the 40 day simple moving average.
● If you get filled on either rule, exit on Monday morning's open, or Tuesday morning's open, if Monday is a holiday.
Some individuals wish to use a money management stop after entry. This works very well. You can choose any value from 40 to 90 pips for a consistent stop with very little difference in profitability.
As you can see from the equity curves displayed for the various currencies, the system has been working very well since it was released in the late '80's. What is not usually appreciated by those investigating this system is this--- these returns are accomplished staying in the market less than 15% of the time!
Interestingly, a large number of important government reports come out on Fridays, and have for many years. That probably helps the persistence of this trade too. I do believe the main reason One Night Stand still works is for the reasons Joe Krutsinger gave many times from the platform.
Individuals and banking institutions are reluctant to stay heavily positioned over weekends if they don't have to. And they don't have to. So, traders like us pick up a risk premium for doing what others are unwilling to do.

My Zorro coding of this strategy;

function run()
{
// BarPeriod = 60; // Hourly Bars
Verbose = 14;
// Detrend = 1;
vars Price = series(price());
vars SMA10 = series(SMA(Price, 10));
vars SMA40 = series(SMA(Price, 40));

Stop = 90 * PIP;
Capital = 100000;
Margin = 0.01* Capital * sqrt(1 + max(0,WinTotal-LossTotal)/Capital);
// Risk = 0.01 * Capital * sqrt(1 + max(0,WinTotal-LossTotal)/Capital);
//
var BuyLimit,SellLimit,BuyStop,SellStop;

if(SMA10[0] > SMA40[0])
{
BuyStop = HH(10) + 1*PIP;
}

if(SMA10[0] < SMA40[0])
{
SellStop = LL(10) - 1*PIP;
}

if(NumOpenLong < 5 & dow() == 5 & SMA10[0] > SMA40[0])
enterLong(0, BuyStop);
else if(NumOpenShort < 5 & dow() == 5 & SMA10[0] < SMA40[0])
enterShort(0, SellStop);

if(TradeIsOpen and dow() == 1)
exitLong();
if(TradeIsOpen and dow() == 1)
exitShort();

plot("SMA10", SMA10[0], LINE, BLUE);
plot("SMA40", SMA40[0], LINE, ORANGE);
}

Backtest on USD/JPY

BackTest: ONS USD/JPY 2010..2015
Monte Carlo Analysis... Median AR 6%
Profit 4153$ MI 64$ DD 8670$ Capital 11804$
Trades 310 Win 50% Avg +1.8p Bars 3
CAGR 1% PF 1.11 SR 0.20 UI 119% R2 0.00

ONS compiling..................
BackTest: ONS USD/JPY 2010..2015
Monte Carlo Analysis... Median AR 47%
Profit 44180$ MI 674$ DD 11631$ Capital 10431$
Trades 857 Win 54% Avg +6.5p Bars 11
CAGR 7% PF 1.45 SR 0.91 UI 11% R2 0.38

Time in market 30%

Backtest on GBP/USD

Profit 44180$ MI 674$ DD 11631$ Capital 10431$
Trades 857 Win 54% Avg +6.5p Bars 11
CAGR 7% PF 1.45 SR 0.91 UI 11% R2 0.38
Copied to Clipboard!
Generate Chart - please wait... ok

ONS compiling................
BackTest: ONS GBP/USD 2010..2015
Monte Carlo Analysis... Median AR 22%
Profit 20774$ MI 320$ DD 15841$ Capital 8156$
Trades 927 Win 52% Avg +3.9p Bars 10
CAGR 4% PF 1.17 SR 0.42 UI 21% R2 0.50

Time in market 31%

Backtest on EUR/USD

Profit 20774$ MI 320$ DD 15841$ Capital 8156$
Trades 927 Win 52% Avg +3.9p Bars 10
CAGR 4% PF 1.17 SR 0.42 UI 21% R2 0.50
Copied to Clipboard!
Generate Chart - please wait... ok

ONS compiling.................
BackTest: ONS EUR/USD 2010..2015
Monte Carlo Analysis... Median AR 77%
Profit 91711$ MI 1415$ DD 25974$ Capital 10329$
Trades 920 Win 56% Avg +9.9p Bars 10
CAGR 13% PF 1.42 SR 0.98 UI 11% R2 0.44

Time in market 31%

My coding is not perfect. I want to split the timeframe that the run function uses and the timeframe the buy and stop sell functions use.

The buy and sell stop functions should use daily bars. When I coded them with different timeframes the script crashes.

Last edited by RTG; 06/26/15 01:51.
Re: One Night Stand System [Re: RTG] #452812
06/26/15 06:26
06/26/15 06:26
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline
Senior Member
boatman  Offline
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
Why do you need to analyse different time frames? My reading of the system description is that it is based on daily bars?

I set the bar period to 1440 and aligned the bars to midnight. I couldn't reproduce the results in the PDF you linked to. Nothing even close in fact!

Just to make your code a bit simpler:
I don't think you need the if statements around the setting of your buy and sell stops - they are covered in the if statements controlling your trade entries. Also, I don't think you need to limit the number of trades - you can only ever enter one trade in either direction at a time as a result of the strategy's rules.

Good luck! Will be interested to hear if you can reproduce those equity curves.

Re: One Night Stand System [Re: boatman] #452822
06/26/15 14:27
06/26/15 14:27
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
The function HH(10) is analysing the last 10 bars, whereas the system rules should analyse the last 10 days.

How did you align the bars to midnight?

Re: One Night Stand System [Re: RTG] #452825
06/26/15 19:16
06/26/15 19:16
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Proposal for a very basic variation without money management etc.:

Code:
function run() {

BarPeriod = 1440;

vars Price = series(price());
vars SMA10 = series(SMA(Price, 10));
vars SMA40 = series(SMA(Price, 40));

//Stop = 90 * PIP;

var BuyStop,SellStop;

BuyStop = HH(10) + 1*PIP;
SellStop = LL(10) - 1*PIP;

if (dow() == 5 && NumOpenLong == 0 && NumPendingLong == 0 && SMA10[0] > SMA40[0]) 
	enterLong(0,BuyStop);
else if (dow() == 5 && NumOpenShort == 0 && NumPendingShort == 0 && SMA10[0] < SMA40[0])
	enterShort(0,SellStop);			

if (dow() != 5 && dow() != 6 && dow() != 7) {
	exitLong();
	exitShort();
}

}



At least in EUR/USD it looks interessting laugh But you have to omit the Stop, not for weak nerves ...

Re: One Night Stand System [Re: RTG] #452835
06/27/15 02:50
06/27/15 02:50
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline
Senior Member
boatman  Offline
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
Originally Posted By: RTG
The function HH(10) is analysing the last 10 bars, whereas the system rules should analyse the last 10 days.

How did you align the bars to midnight?


There's a script for doing this in the 'Script Tips and Tricks' section of the manual. Very useful!

If you set BarPeriod = 1440, the function HH(10) will analyse the last 10 days.

Re: One Night Stand System [Re: boatman] #452846
06/28/15 08:51
06/28/15 08:51
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Looks interesting on the pairs "USD/CHF", "USD/JPY" , "GBP/USD", "EUR/USD".

Tried a portoflio loop but the script didn't like it and ran only one pair.

Re: One Night Stand System [Re: RTG] #452854
06/28/15 14:48
06/28/15 14:48
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Just as easy as described in workshop 6:

Code:
function tradeOneNightStand() {
	
vars Price = series(price());
vars SMA10 = series(SMA(Price, 10));
vars SMA40 = series(SMA(Price, 40));

//Stop = 90 * PIP;

var BuyStop,SellStop;

BuyStop = HH(10) + 1*PIP;
SellStop = LL(10) - 1*PIP;

if (dow() == 5 && NumOpenLong == 0 && NumPendingLong == 0 && SMA10[0] > SMA40[0]) 
	enterLong(0,BuyStop);
else if (dow() == 5 && NumOpenShort == 0 && NumPendingShort == 0 && SMA10[0] < SMA40[0])
	enterShort(0,SellStop);			

if (dow() != 5 && dow() != 6 && dow() != 7) {
	exitLong();
	exitShort();
}
	
}


function run() {

BarPeriod = 1440;

while(asset(loop("USD/CHF", "USD/JPY" , "GBP/USD", "EUR/USD")))
	tradeOneNightStand();

}



produces result:

Code:
Portfolio analysis  OptF  ProF  Win/Loss  Wgt%

EUR/USD avg         .501  2.59   44/21    57.7  
GBP/USD avg         .289  1.42   31/26    15.9  
USD/CHF avg         .499  1.28   31/30    12.1  
USD/JPY avg         .466  1.50   32/30    14.2  

EUR/USD             .479  2.59   44/21    57.7  
EUR/USD:L           .278  1.65   14/10    12.7  
EUR/USD:S           .724  3.68   30/11    45.1  
GBP/USD             .297  1.42   31/26    15.9  
GBP/USD:L           .000  0.72   13/16    -6.7  
GBP/USD:S           .578  2.59   18/10    22.6  
USD/CHF             .932  1.28   31/30    12.1  
USD/CHF:L           .999  1.77   17/13    12.8  
USD/CHF:S           .000  0.97   14/17    -0.8  
USD/JPY             .314  1.50   32/30    14.2  
USD/JPY:L           .932  3.32   22/15    26.4  
USD/JPY:S           .000  0.29   10/15   -12.1



Like already mentioned: it's a very basic version ... and in our days I definitely won't advise to keep positions open over the weekend without setting a stop!

Re: One Night Stand System [Re: Sphin] #452862
06/29/15 00:05
06/29/15 00:05
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
So a portfolio loop has to be segregated into at least two seperate functions.

Re: One Night Stand System [Re: RTG] #452865
06/29/15 07:52
06/29/15 07:52
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Functions are used to keep the code orderly. They are unrelated to a portfolio loop.

Re: One Night Stand System [Re: jcl] #452974
07/02/15 15:15
07/02/15 15:15
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
So what about testing this strategy vs a random selection of opening a trade on one day and closing it the next?

Re: One Night Stand System [Re: RTG] #452984
07/02/15 22:07
07/02/15 22:07
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
In my understanding a decisive fact should be the 'trade over the weekend', so if you want to put it on a random base simply omit the trend filter and enter long or short randomly.

Re: One Night Stand System [Re: Sphin] #453407
07/24/15 23:49
07/24/15 23:49
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Live running demo running on myfxbook.

http://www.myfxbook.com/members/Sheffield/ons/1315213

Last edited by RTG; 07/24/15 23:50.
Re: One Night Stand System [Re: RTG] #454001
08/24/15 01:42
08/24/15 01:42
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Im noticing that the script exits positions before 9am ET time. Currently the script is run on an amazon VPS set to New York time.

For instance today, it exited all the positions around 1am Monday morning.

This being the exit condition of the script, the intention is to exit at 9am New York time on the first trading day after the Friday.


if (ldow(ET) != 5 && dow() != 6 && dow() != 7 && lhour(ET) >= 9) {
exitLong();
exitShort();

Re: One Night Stand System [Re: RTG] #454002
08/24/15 02:36
08/24/15 02:36
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Midnight in Greenwich is sunset in New York.

You're trading in days, not in hours. If you want to always open and close positions at a certain time, set BarZone and BarOffset accordingly. However for gap trading it probably makes sense to close the trade as early as possible, so Monday 00:00 might be ok.

Re: One Night Stand System [Re: jcl] #454015
08/24/15 14:13
08/24/15 14:13
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
I think it maybe more obvious than that. Why don't I just get rid of the ET offset since the VPS is located is located in the USA anyway?

Re: One Night Stand System [Re: RTG] #454016
08/24/15 14:18
08/24/15 14:18
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
It is irrelevant for the script where the VPS is located.

Re: One Night Stand System [Re: jcl] #454026
08/25/15 04:01
08/25/15 04:01
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Does BarOffset always work in minutes?

In this case, I can set BarOffset = ET + 9.5 * 60.

From the zorro help file.

BarOffset
Bar start time offset in minutes. Bars and frames normally start at a date/time boundary; f.i. 60-minute bars start at every full hour, and daily bars start at UTC midnight. This can be changed with BarOffset. For daily bars, BarOffset determines the UTC minute into the day when the candle opens, and can be used for setting the bar begin to a certain time zone.

Re: One Night Stand System [Re: RTG] #454030
08/25/15 07:54
08/25/15 07:54
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Yes, in minutes, but without ET.

For bars beginning at 9:30 AM in New York, use BarZone = ET and BarOffset = 9*60+30.

And test the system with TICKS - it uses pending entries and exits after 1 bar, so without TICKS the result will be very inaccurate.

Re: One Night Stand System [Re: RTG] #454720
09/15/15 19:37
09/15/15 19:37
Joined: Oct 2012
Posts: 11
parrondo Offline
Newbie
parrondo  Offline
Newbie

Joined: Oct 2012
Posts: 11
Hi, RTG
do you have and orphan EURJPY trade in your myfxbook acount for this system?

I mean, this will distort the results for sure.

Thank you for your input.

Re: One Night Stand System [Re: parrondo] #454722
09/16/15 00:17
09/16/15 00:17
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Yes, zorro stopped responding and when restarted it subsequently 'forgot' the trade was open. I assumed the script would close out the position on the Monday and didn't think to check it myself until later in the week.

It is a demo account even though it says it is a real account on fxbook.

Re: One Night Stand System [Re: RTG] #454844
09/25/15 01:32
09/25/15 01:32
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
It looks like the script has stopped worki. Pending trades do not setup as previously on a Friday.

Anyone know why this would be the case?

Last edited by RTG; 09/25/15 14:18.
Re: One Night Stand System [Re: RTG] #455063
10/06/15 03:12
10/06/15 03:12
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
One thing I would like to change is the Margin for the asset "USOil" only.

I would like to reduce it by a factor of about the current oil price in USD, which is about 45.

I have tried the following which seems to reduce the margin for all assets by a factor of 45. This seems to have the effect of reducing all position sizes by a factor of 45, not just the oil asset.

Capital = 50000;
if(asset("USOil")){
Margin = 0.01 * (Capital + (WinTotal-LossTotal))/45; }
else {
Margin = 0.01 * (Capital + (WinTotal-LossTotal));}

Re: One Night Stand System [Re: RTG] #455066
10/06/15 10:36
10/06/15 10:36
Joined: Feb 2015
Posts: 652
Milano, Italy
M
MatPed Offline
User
MatPed  Offline
User
M

Joined: Feb 2015
Posts: 652
Milano, Italy
Hi RTG, once Margin have been reduced the first time for USOil, it will be reduced for the all the next assets. Store the Margin in a var and restore to the proper value in the else statement.

Ciao

Re: One Night Stand System [Re: MatPed] #455070
10/06/15 15:25
10/06/15 15:25
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
HI. I am not quite sure what you mean right now but I will sleep on it.

Re: One Night Stand System [Re: RTG] #455072
10/06/15 15:32
10/06/15 15:32
Joined: Jun 2013
Posts: 1,609
D
DdlV Offline
Serious User
DdlV  Offline
Serious User
D

Joined: Jun 2013
Posts: 1,609
Hi RTG. asset(string) is a function that changes asset. Asset is the current asset. Do you want instead something like if(Asset=="USOil")?

HTH.

Re: One Night Stand System [Re: DdlV] #455073
10/07/15 02:30
10/07/15 02:30
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Still not working for me.

Is the issue that Margin is being set twice, and the run function can only use one value?

Re: One Night Stand System [Re: RTG] #455085
10/08/15 03:40
10/08/15 03:40
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Got it to work by splitting Oil off into its own function with its own margin and then bringing it back in the run function.

Re: One Night Stand System [Re: RTG] #455118
10/10/15 13:24
10/10/15 13:24
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Quote:
As yet I haven't worked out why the script stopped setting up the pending entry stop levels on Friday

This is from a Z-Systems-Thread but I think it is related to the system discussed in here.

1. What code of the system in detail you are trading live?
2. "Stopped setting up entry stop levels" means that Zorro does not open trades at a certain level but as market orders or how does Zorro behave?
3. What Zorro version do you use and did you change it during trading?

Re: One Night Stand System [Re: Sphin] #455139
10/10/15 23:36
10/10/15 23:36
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
1. I will paste the code at the bottom of this post.

2. Zorro used to setup the entry stop levels every Friday as one would expect.
Ie the console would display something like “USD/CHF entry long stop @ 1.05” and do this for all assets at 12am Friday UTC time. From there it would wait until price crossed these thresholds, then it would enter (or not if price didn’t cross the threshold).

Since the crash and installation of version 1.34, it will not do this unless a smaller bar period is used. It works on bar periods from 1 minute to 720 minutes but not at 1440 minutes (which is what the trading system requires).

3. It was working under the previous Zorro version which was 1.32 I believe. After the vps crash I upgraded to 1.34. I can't say if the issue is connected to 1.34.

Here is the code I tried on Friday using 30 minute bars in an attempt to get it to setup properly once again.

include <profile.c>

function tradeOneNightStand() {
TimeFrame = 48;
vars Price = series(price());
vars SMA10 = series(SMA(Price, 10));
vars SMA40 = series(SMA(Price, 40));

set(PARAMETERS+FACTORS);

Margin = 0.02 * (Capital + WinTotal-LossTotal);

//Stop = 150 * PIP;

var BuyStop,SellStop;

BuyStop = HH(10) + 1*PIP;
SellStop = LL(10) - 1*PIP;

if (dow() == 5 && NumOpenLong == 0 && NumPendingLong == 0 && SMA10[0] > SMA40[0])
enterLong(0,BuyStop);
else if (dow() == 5 && NumOpenShort == 0 && NumPendingShort == 0 && SMA10[0] < SMA40[0])
enterShort(0,SellStop);

if (dow() != 5 && dow() != 6 && dow() != 7){
exitLong();
exitShort();

}
}
//split oil asset from currencies because of outsized positions
function tradeOil(){
TimeFrame = 48;
asset("USOil");
vars Price = series(price());
vars SMA10 = series(SMA(Price, 10));
vars SMA40 = series(SMA(Price, 40));

set(PARAMETERS+FACTORS);

Margin = 0.005 * (Capital + WinTotal-LossTotal);

//Stop = 150 * PIP;

var BuyStop,SellStop;

BuyStop = HH(10) + 1*PIP;
SellStop = LL(10) - 1*PIP;

if (dow() == 5 && NumOpenLong == 0 && NumPendingLong == 0 && SMA10[0] > SMA40[0])
enterLong(0,BuyStop);
else if (dow() == 5 && NumOpenShort == 0 && NumPendingShort == 0 && SMA10[0] < SMA40[0])
enterShort(0,SellStop);

if (dow() != 5 && dow() != 6 && dow() != 7 ){
exitLong();
exitShort();}
}

function run() {

LookBack = 40*48;
Verbose = 14;
BarPeriod = 30;
StartDate = 2005;
Capital = 50000;
// NumWFOCycles = 3;

// method 2: invest the square root of the total profit
// Margin = OptimalF * Capital * sqrt(1 + max(0,WinTotal-LossTotal)/Capital);

//while(asset(loop("AUD/CAD","USD/SEK","USD/JPY","USD/HKD","USD/CNH","USD/CHF","USD/CAD","NZD/USD","NZD/JPY","GBP/USD",
//"GBP/NZD","GBP/JPY","GBP/CHF","GBP/CAD","GBP/AUD","EUR/USD","EUR/JPY","EUR/GBP","EUR/CHF","EUR/CAD",
//"EUR/AUD","CHF/JPY","CAD/JPY","AUD/USD","AUD/NZD","AUD/JPY")))

while(asset(loop("USD/CHF","USD/JPY","GBP/USD","EUR/USD","EUR/JPY","USD/CAD")))
{
tradeOneNightStand();
}
tradeOil();

//ColorUp = 0;
//ColorDn = 0;
//ColorEquity = 0;
//plotTradeProfile(20);
//plotMAEGraph(-1);
//plotPriceProfile(10,0);
//plotQuarterProfit();
//plotMonthProfit();
plotMonthProfit();
}

Re: One Night Stand System [Re: RTG] #455149
10/11/15 12:02
10/11/15 12:02
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
"set" can be used in a single function? Nice, I thought it could be used in the run() and once only.

In my Zorro (1.36.4 - and the .4 meanwhile is important because each version shows, if only slightly but different results) setting BarPeriod to 1440 (and omit TimeFrame of course) works and let the strategy doing as expected. Involving LOGFILE flag shows trades like:

Code:
[42: Fri 04.03.05 00:00]  1.3137-1.3166-1.3098-1.3114
(USD/CHF::S) Short 20@1.1571 Entry stop
(USD/JPY::L) Long 100@105.91 Entry stop
(GBP/USD::L) Long 71@1.9266 Entry stop
(EUR/USD::L) Long 100@1.3282 Entry stop
(GBP/USD::L) Entry stop 1.9266 hit at 00:00
[GBP/USD::L4314] Long 71@1.9266  at 00:00

[43: Mon 07.03.05 00:00]  1.30880-1.32560  +0 -161 0/1

Monday 07.03.05  Loss -161$ ----
(USD/CHF::S) Missed entry 1.1571 at exit command
(USD/JPY::L) Missed entry 105.91 at exit command
[GBP/USD::L4314] Sell 71@1.9241: -161$ at 00:00
(EUR/USD::L) Missed entry 1.3282 at exit command



There are only trades in assets that are known to AssetsFix.dta, the default one (that I use) therefore trades only these 4 assets in the log.

Using a TimeFrame has 2 important impacts here to the trades, first it does not use 00:00 for the entry stops but any time I guess maybe resulting from the time of starting the strategy and shifted 48 times in the future or similar, and the second one is more important: TimeFrame keeps EntryTime untouched, so the entry stops are only valid for the time of the BarPeriod, here: 30 minutes. These facts are also revealed by the log:

Code:
[7440: Fri 12.08.05 04:00]  1.2464-1.2465-1.2461-1.2464
(USD/CHF::S) Short 20@1.2451 Entry stop
(USD/JPY::L) Long 100@112.81 Entry stop
(GBP/USD::L) Long 71@1.8140 Entry stop
(EUR/USD::L) Long 100@1.2479 Entry stop

[7441: Fri 12.08.05 04:30]  1.24580-1.24680  +0 +0 0/0
(USD/CHF::S) Missed entry 1.2451 after 1 bar
(USD/JPY::L) Missed entry 112.81 after 1 bar
(GBP/USD::L) Missed entry 1.8140 after 1 bar
(EUR/USD::L) Missed entry 1.2479 after 1 bar



To avoid this I guess you can synchronise the TimeFrame with frameSync() and increase the EntryTime accordingly. But I think it's really easier to use BarPeriod = 1440.

Re: One Night Stand System [Re: Sphin] #455160
10/11/15 23:45
10/11/15 23:45
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
The TimeFrame exercise was an attempt to get the pending trades once again in live testing. I would prefer too to use 1440 minute bars.

For the purposes of testing, I have changed the entry dow() to today's day (Monday) and removed the TimeFrame, going back to the 1440 minute bars.

Re: One Night Stand System [Re: RTG] #455166
10/12/15 01:18
10/12/15 01:18
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
I added the printf function to find out what the BuyStop and SellStops are for the oil asset.

BuyStop = HH(10) + 1*PIP;
SellStop = LL(10) - 1*PIP;
printf("\nSellStop %+4.2f");
printf("\nBuyStop %+4.2f");

This is the result. Right now I can't think why the SellStop = the BuyStop in every instance. Edit (I didn't add the variable after the string as in printf("\nSellStop %4.2f", SellStop);

It works now.

BuyStop +47.19
SellStop +47.19
BuyStop +47.19
SellStop +47.19
BuyStop +49.11
SellStop +49.11
BuyStop +49.74
SellStop +49.74
BuyStop +50.08
SellStop +50.08
BuyStop +50.96
SellStop +50.96

Last edited by RTG; 10/12/15 01:49.
Re: One Night Stand System [Re: RTG] #455223
10/13/15 17:51
10/13/15 17:51
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
I played a little with optimizing the script.

Code:
function tradeOneNightStand() {
	
  vars Price = series(price());
  vars SMAShort = series(SMA(Price, optimize(10,5,20)));
  vars SMALong = series(SMA(Price, optimize(40,30,80,5)));

  Stop = optimize(100,100,500,10) * PIP;

  var BuyStop,SellStop;

  BuyStop = HH(10) + 1*PIP;
  SellStop = LL(10) - 1*PIP;

  if (dow() == 5 && NumOpenLong == 0 && NumPendingLong == 0 && SMAShort[0] > SMALong[0] && rising(SMAShort) && rising(SMALong)) {
	Margin = 0.1 * OptimalFLong * Capital;
	enterLong(0,BuyStop);
  }

  else if (dow() == 5 && NumOpenShort == 0 && NumPendingShort == 0 && SMAShort[0] < SMALong[0] && falling(SMAShort) && falling(SMALong)) {
	Margin = 0.1 * OptimalFShort * Capital;
	enterShort(0,SellStop);			
 }	

  if (dow() != 5 && dow() != 6 && dow() != 7) {
	exitLong();
	exitShort();
  }
}


function run() {

 set(PARAMETERS+FACTORS);
 BarPeriod = 1440;
 StartDate = 2005;
 NumWFOCycles = 5;
 Capital = 50000;
 LookBack = 120;

 while(asset(loop("USD/CHF","USD/JPY","GBP/USD","EUR/USD","EUR/JPY","USD/CAD"))) 
	tradeOneNightStand();
 }


Don't forget to train first. Less trades but interesting results and a touch of security with a bit of stop.

What settings for USOil do you use in your AssetsFix? I must admit I do not really understand the information on FXCM web site. laugh

Last edited by Sphin; 10/13/15 22:35.
Re: One Night Stand System [Re: Sphin] #455226
10/13/15 23:32
10/13/15 23:32
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Name Price Spread RollLong/Short PIP PIPCost Margin Lot Comm
AUD/CAD 0.96837 0.00013 0.1900 -0.4800 0.0001 0.06946 8.000 1000.0 0.8
AUD/CHF 0.72544 0.00008 0.3500 -0.8200 0.0001 0.09272 40.000 1000.0 0.8
AUD/JPY 91.817 0.00500 0.2700 -0.6000 0.0100 0.07325 8.000 1000.0 0.8
AUD/NZD 1.12018 0.00015 -0.2900 0.1200 0.0001 0.06004 8.000 1000.0 0.8
AUD/USD 0.73677 0.00003 0.2400 -0.5100 0.0001 0.09129 8.000 1000.0 0.6
CAD/CHF 0.74917 0.00007 0.1300 -0.3300 0.0001 0.09272 40.000 1000.0 0.8
CAD/JPY 94.824 0.00700 0.0300 -0.1300 0.0100 0.07325 8.000 1000.0 0.8
CHF/JPY 126.575 0.00600 -0.3200 0.1200 0.0100 0.07325 55.000 1000.0 0.8
EUR/AUD 1.48693 0.00011 -0.8700 0.4100 0.0001 0.06726 10.000 1000.0 0.8
EUR/CAD 1.43979 0.00012 -0.2600 0.1000 0.0001 0.06946 10.000 1000.0 0.8
EUR/CHF 1.07860 0.00006 0.0900 -0.2600 0.0001 0.09272 75.000 1000.0 0.8
EUR/GBP 0.70724 0.00005 -0.2400 0.1100 0.0001 0.14140 10.000 1000.0 0.8
EUR/JPY 136.347 0.01100 -0.3600 -0.0300 0.0100 0.11565 18.000 1000.0 0.6
EUR/NOK 9.0214 0.00190 -0.5600 0.1600 0.0001 0.01109 15.000 1000.0 0.8
EUR/NZD 1.66552 0.00025 -1.3000 0.6000 0.0001 0.06005 10.000 1000.0 0.8
EUR/SEK 9.5982 0.00200 0.0100 -0.1500 0.0001 0.01042 15.000 1000.0 0.8
EUR/TRY 3.0579 0.00075 -5.3700 1.2400 0.0001 0.03271 40.000 1000.0 0.8
EUR/USD 1.13846 0.00004 -0.9300 0.3900 0.0001 0.13850 18.000 1000.0 0.6
GBP/AUD 2.1026 0.00018 -0.9400 0.4400 0.0001 0.06726 16.000 1000.0 0.8
GBP/CAD 2.0359 0.00021 0.0300 -0.0900 0.0001 0.06946 16.000 1000.0 0.8
GBP/CHF 1.52516 0.00012 0.3100 -0.7000 0.0001 0.09272 80.000 1000.0 0.8
GBP/JPY 193.040 0.00900 0.1200 -0.2800 0.0100 0.07325 16.000 1000.0 0.6
GBP/NZD 2.3551 0.00044 -1.4800 0.6800 0.0001 0.06005 16.000 1000.0 0.8
GBP/USD 1.52531 0.00007 0.2100 -0.5700 0.0001 0.13850 24.000 1000.0 0.6
GER30 9994.00 1.00000 -0.1230 0.0000 1.0000 0.15708 11.000 0.1 0.0
NAS100 4185.00 2.0000 0.0477 -0.0900 1.0000 0.08710 2.000 0.1 0.0
NZD/CAD 0.86456 0.00015 0.2700 -0.6000 0.0001 0.06946 7.000 1000.0 0.8
NZD/CHF 0.64768 0.00011 0.4100 -0.9000 0.0001 0.09272 35.000 1000.0 0.8
NZD/JPY 81.976 0.01200 0.3400 -0.7400 0.0100 0.07325 7.000 1000.0 0.8
NZD/USD 0.65779 0.00007 0.3100 -0.6900 0.0001 0.09129 7.000 1000.0 0.8
SPX500 2032.40 0.50000 0.3265 -0.5419 0.1000 0.08710 8.000 1.0 0.0
Stock 100.000 0.00000 0.0000 0.0000 1.0000 1.00000 100.000 1.0 0.0
TRY/JPY 44.653 0.00900 0.4600 -1.7200 0.0100 0.07325 16.000 1000.0 0.8
UK100 6869.00 2.0000 -0.0883 0.0000 1.0000 0.13183 6.000 0.1 0.0
US30 17520.00 4.0000 0.1271 -0.2948 1.0000 0.08710 6.000 0.1 0.0
USD/CAD 1.30213 0.00006 -0.4800 0.0900 0.0001 0.10572 16.000 1000.0 0.8
USD/CHF 0.95781 0.00010 0.7200 -1.8000 0.0001 0.14284 80.000 1000.0 0.6
USD/CNH 6.2158 0.00012 -1.4600 0.3000 0.0001 0.01469 50.000 1000.0 0.8
USD/HKD 7.7527 0.00014 -0.0400 -0.0400 0.0001 0.01178 50.000 1000.0 0.8
USD/JPY 119.763 0.00400 0.1500 -0.8100 0.0100 0.11565 16.000 1000.0 0.6
USD/MXN 16.2248 0.00142 -1.0700 0.2500 0.0001 0.00563 40.000 1000.0 0.8
USD/NOK 8.2347 0.00083 -0.3300 0.0900 0.0001 0.01109 15.000 1000.0 0.8
USD/SEK 8.7617 0.00130 0.0600 -0.2400 0.0001 0.01042 15.000 1000.0 0.8
USD/TRY 2.7906 0.00036 -4.6700 1.1700 0.0001 0.03271 40.000 1000.0 0.8
USD/ZAR 12.7298 0.00298 -2.1500 0.9600 0.0001 0.00717 40.000 1000.0 0.8
USOil 48.080 0.05000 0.0000 0.0000 0.0100 0.13719 24.000 10.0 0.0
XAG/USD 17.2350 0.04600 -0.0009 0.0000 0.0100 0.43547 5.000 50.0 0.0
XAU/USD 1260.82 0.47000 -0.0124 0.0000 0.0100 0.00871 11.000 1.0 0.0
ZAR/JPY 9.7920 0.00300 0.0700 -0.2100 0.0100 0.07325 4.000 1000.0 0.8

Re: One Night Stand System [Re: Sphin] #455230
10/14/15 08:44
10/14/15 08:44
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
OK I have set this version of the script up on a new demo account. Hopefully it begins functioning properly again.

https://www.myfxbook.com/members/Sheffield/ons-20/1395003

Re: One Night Stand System [Re: RTG] #455787
10/30/15 02:12
10/30/15 02:12
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Screen cap of this mornings setups attached.

Attached Files ONS screenshot 30-10-2015.jpg
Re: One Night Stand System [Re: RTG] #455790
10/30/15 03:43
10/30/15 03: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
It looks like its not receiving information from the broker. Normally you should at least see price information printed in the Zorro window. eg

[Bar Number, Date and Time] Price

Is the instance of MT4 that Sphon's version is connected to working correctly? Maybe try connecting it to the instance that the original version is connected to and see if you get any different result. Its strange, because it obviously loaded prices from the server.

Re: One Night Stand System [Re: boatman] #455836
10/31/15 12:05
10/31/15 12:05
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181


Beats me.

Its running on FXCM's API not MT4 if that helps.

Re: One Night Stand System [Re: RTG] #455837
10/31/15 12:39
10/31/15 12:39
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
What is the problem, is it the fact that the 'optimized' version does not start to open trades like the other one? In the new version more filters are active (rising and falling of the SMAs is assumed additionally) and the periods of the SMAs are different. So it does less trades and they are surely not snchronized with the other version. If you set +LOGFILE to test runs you will see that there are indeed Fridays where the strategy does not open trades, it does not happen often but it happens.

Re: One Night Stand System [Re: Sphin] #455847
11/01/15 00:20
11/01/15 00:20
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Hello.

To illustrate from the backtest log file, here is what should of happened on Friday the 23/10.

[2802: Fri 23.10.15 00:00] 44.920-46.120 +122512 +0 144/92
(USD/CHF::S) Short 100@0.9476 Entry stop

To me that says a short entry stop level was set at 0.9476. That is to say a pending trade was setup and would have displayed on the console as an entry stop. I didn't see such a pending trade setup on the zorro console on that day.

If you see the attached log file of the backtest, you can see that on just about every Friday, the entry stop levels are set by script. Infact there isn't a single Friday where there isn't at least one stop level entry set. This doesn't appear to be happening at all when the script is running live.

Here is part of the log file from July 20 to October 30. The full log file is attached.

[2733: Mon 20.07.15 00:00] 50.160-51.360 +125415 +14 140/85

Monday 20.07.15 Profit +13.80 ----
[USD/CHF::L3324] Sell 100@0.9622: +313$ at 00:00
[USD/JPY::L3325] Sell 458@124.14: -299$ at 00:00

[2734: Tue 21.07.15 00:00] 50.190-51.610 +125429 +0 140/85
[2735: Wed 22.07.15 00:00] 50.110-51.440 +125429 +0 140/85
[2736: Thu 23.07.15 00:00] 49.060-50.630 +125429 +0 140/85
[2737: Fri 24.07.15 00:00] 48.240-49.650 +125429 +0 140/85
(USD/CHF::L) Long 100@0.9651 Entry stop
(USD/JPY::L) Long 458@124.49 Entry stop
(USD/CAD::L) Long 0@1.3054 Entry stop
(USOil::S) Short 73@48.23 Entry stop
(USD/CAD::L) Entry stop 1.3054 hit at 00:00
(USD/CAD::L) Skipped: Lots/Margin = 0
(USOil::S) Entry stop 48.23 hit at 00:00
[USOil::S3826] Short 73@48.23 Risk 2866$ at 00:00

[2738: Mon 27.07.15 00:00] 47.740-49.050 +125429 +33 141/85

Monday 27.07.15 Profit +32.68 ----
(USD/CHF::L) Missed entry 0.9651 at exit command
(USD/JPY::L) Missed entry 124.49 at exit command
[USOil::S3826] Cover 73@48.14: +32.68 at 00:00

[2739: Tue 28.07.15 00:00] 46.950-48.240 +125461 +0 141/85
[2740: Wed 29.07.15 00:00] 46.710-48.460 +125461 +0 141/85
[2741: Thu 30.07.15 00:00] 47.410-49.540 +125461 +0 141/85
[2742: Fri 31.07.15 00:00] 48.360-49.390 +125461 +0 141/85
(USD/CHF::L) Long 100@0.9721 Entry stop
(USD/JPY::L) Long 458@124.59 Entry stop
(USOil::S) Short 73@46.70 Entry stop
(USOil::S) Entry stop 46.70 hit at 00:00
[USOil::S4327] Short 73@46.70 Risk 2866$ at 00:00

[2743: Mon 03.08.15 00:00] 46.380-48.640 +125461 -176 141/86

Monday 03.08.15 Loss -176$ ----
(USD/CHF::L) Missed entry 0.9721 at exit command
(USD/JPY::L) Missed entry 124.59 at exit command
[USOil::S4327] Cover 73@46.83: -176$ at 00:00

[2744: Tue 04.08.15 00:00] 45.110-46.960 +125285 +0 141/86
[2745: Wed 05.08.15 00:00] 45.430-46.250 +125285 +0 141/86
[2746: Thu 06.08.15 00:00] 44.860-46.710 +125285 +0 141/86
[2747: Fri 07.08.15 00:00] 44.230-45.290 +125285 +0 141/86
(USD/CHF::L) Long 100@0.9849 Entry stop
(USD/JPY::L) Long 458@125.02 Entry stop
(EUR/USD::S) Short 292@1.0847 Entry stop
(USD/CAD::L) Long 0@1.3215 Entry stop
(USOil::S) Short 73@44.22 Entry stop
(USD/CHF::L) Entry stop 0.9849 hit at 00:00
[USD/CHF::L4828] Long 100@0.9849 Risk 2672$ at 00:00
(USD/JPY::L) Entry stop 125.02 hit at 00:00
[USD/JPY::L4829] Long 458@125.02 Risk 6492$ at 00:00
(USOil::S) Entry stop 44.22 hit at 00:00
[USOil::S4830] Short 73@44.22 Risk 2866$ at 00:00

[2748: Mon 10.08.15 00:00] 43.400-45.160 +125285 -1933 142/88

Monday 10.08.15 Loss -1933$ ----
[USD/CHF::L4828] Sell 100@0.9840: -116$ at 00:00
[USD/JPY::L4829] Sell 458@124.34: -2352$ at 00:00
(EUR/USD::S) Missed entry 1.0847 at exit command
(USD/CAD::L) Missed entry 1.3215 at exit command
[USOil::S4830] Cover 73@43.60: +535$ at 00:00

[2749: Tue 11.08.15 00:00] 43.560-45.040 +123352 +0 142/88
[2750: Wed 12.08.15 00:00] 42.730-45.360 +123352 +0 142/88
[2751: Thu 13.08.15 00:00] 42.830-43.890 +123352 +0 142/88
[2752: Fri 14.08.15 00:00] 41.730-43.740 +123352 +0 142/88
(USD/CHF::L) Long 100@0.9904 Entry stop
(USD/JPY::L) Long 458@125.29 Entry stop
(GBP/USD::S) Short 142@1.5439 Entry stop
(USOil::S) Short 73@41.72 Entry stop

[2753: Mon 17.08.15 00:00] 41.890-42.990 +123352 +0 142/88
(USD/CHF::L) Missed entry 0.9904 at exit command
(USD/JPY::L) Missed entry 125.29 at exit command
(GBP/USD::S) Missed entry 1.5439 at exit command
(USOil::S) Missed entry 41.72 at exit command
[2754: Tue 18.08.15 00:00] 41.660-42.710 +123352 +0 142/88
[2755: Wed 19.08.15 00:00] 41.460-42.910 +123352 +0 142/88
[2756: Thu 20.08.15 00:00] 40.840-43.190 +123352 +0 142/88
[2757: Fri 21.08.15 00:00] 40.540-41.840 +123352 +0 142/88
(USD/CAD::L) Long 0@1.3185 Entry stop
(USOil::S) Short 73@40.53 Entry stop
(USD/CAD::L) Entry stop 1.3185 hit at 00:00
(USD/CAD::L) Skipped: Lots/Margin = 0
(USOil::S) Entry stop 40.53 hit at 00:00
[USOil::S5831] Short 73@40.53 Risk 2866$ at 00:00

[2758: Mon 24.08.15 00:00] 39.890-41.410 +123352 +366 143/88

Monday 24.08.15 Profit +366$ ----
[USOil::S5831] Cover 73@40.08: +366$ at 00:00

[2759: Tue 25.08.15 00:00] 37.780-40.170 +123719 +0 143/88
[2760: Wed 26.08.15 00:00] 38.220-39.910 +123719 +0 143/88
[2761: Thu 27.08.15 00:00] 38.550-39.880 +123719 +0 143/88
[2762: Fri 28.08.15 00:00] 39.100-42.880 +123719 +0 143/88
(USD/JPY::S) Short 0@116.15 Entry stop
(EUR/USD::L) Long 75@1.1720 Entry stop
(USD/CAD::L) Long 0@1.3355 Entry stop
(USOil::S) Short 73@37.77 Entry stop

[2763: Mon 31.08.15 00:00] 41.810-45.920 +123719 +0 143/88
(USD/JPY::S) Missed entry 116.15 at exit command
(EUR/USD::L) Missed entry 1.1720 at exit command
(USD/CAD::L) Missed entry 1.3355 at exit command
(USOil::S) Missed entry 37.77 at exit command
[2764: Tue 01.09.15 00:00] 43.630-49.350 +123719 +0 143/88
[2765: Wed 02.09.15 00:00] 43.900-48.890 +123719 +0 143/88
[2766: Thu 03.09.15 00:00] 43.240-46.790 +123719 +0 143/88
[2767: Fri 04.09.15 00:00] 45.690-48.440 +123719 +0 143/88
(USD/JPY::S) Short 0@116.15 Entry stop

[2768: Mon 07.09.15 00:00] 45.600-47.240 +123719 +0 143/88
(USD/JPY::S) Missed entry 116.15 at exit command
[2769: Tue 08.09.15 00:00] 44.180-45.950 +123719 +0 143/88
[2770: Wed 09.09.15 00:00] 44.210-46.430 +123719 +0 143/88
[2771: Thu 10.09.15 00:00] 44.080-46.280 +123719 +0 143/88
[2772: Fri 11.09.15 00:00] 43.400-46.070 +123719 +0 143/88
(USD/CHF::L) Long 100@0.9825 Entry stop
(GBP/USD::S) Short 142@1.5435 Entry stop
(GBP/USD::S) Entry stop 1.5435 hit at 00:00
[GBP/USD::S7332] Short 142@1.5435 Risk 7287$ at 00:00

[2773: Mon 14.09.15 00:00] 44.190-45.900 +123719 -222 143/89

Monday 14.09.15 Loss -222$ ----
(USD/CHF::L) Missed entry 0.9825 at exit command
[GBP/USD::S7332] Cover 142@1.5446: -222$ at 00:00

[2774: Tue 15.09.15 00:00] 43.620-44.940 +123497 +0 143/89
[2775: Wed 16.09.15 00:00] 43.950-45.270 +123497 +0 143/89
[2776: Thu 17.09.15 00:00] 44.840-47.590 +123497 +0 143/89
[2777: Fri 18.09.15 00:00] 46.360-47.740 +123497 +0 143/89
(EUR/USD::L) Long 75@1.1443 Entry stop
(EUR/USD::L) Entry stop 1.1443 hit at 00:00
[EUR/USD::L7833] Long 75@1.1443 Risk 1705$ at 00:00

[2778: Mon 21.09.15 00:00] 44.270-47.050 +123497 -1033 143/90

Monday 21.09.15 Loss -1033$ ----
[EUR/USD::L7833] Sell 75@1.1285: -1033$ at 00:00

[2779: Tue 22.09.15 00:00] 44.800-46.760 +122464 +0 143/90
[2780: Wed 23.09.15 00:00] 45.400-46.690 +122464 +0 143/90
[2781: Thu 24.09.15 00:00] 44.430-47.180 +122464 +0 143/90
[2782: Fri 25.09.15 00:00] 43.740-45.200 +122464 +0 143/90
(USD/CHF::L) Long 100@0.9805 Entry stop
(USD/JPY::S) Short 0@119.05 Entry stop
(GBP/USD::S) Short 142@1.5200 Entry stop
(EUR/JPY::S) Short 238@133.15 Entry stop
(USD/CAD::L) Long 0@1.3418 Entry stop
(USOil::S) Short 73@43.61 Entry stop
(USD/CHF::L) Entry stop 0.9805 hit at 00:00
[USD/CHF::L8334] Long 100@0.9805 Risk 2672$ at 00:00
(GBP/USD::S) Entry stop 1.5200 hit at 00:00
[GBP/USD::S8335] Short 142@1.5200 Risk 7287$ at 00:00

[2783: Mon 28.09.15 00:00] 44.920-46.390 +122464 -178 143/92

Monday 28.09.15 Loss -178$ ----
[USD/CHF::L8334] Sell 100@0.9795: -124$ at 00:00
(USD/JPY::S) Missed entry 119.05 at exit command
[GBP/USD::S8335] Cover 142@1.5202: -53.91 at 00:00
(EUR/JPY::S) Missed entry 133.15 at exit command
(USD/CAD::L) Missed entry 1.3418 at exit command
(USOil::S) Missed entry 43.61 at exit command

[2784: Tue 29.09.15 00:00] 44.330-45.510 +122286 +0 143/92
[2785: Wed 30.09.15 00:00] 44.380-45.730 +122286 +0 143/92
[2786: Thu 01.10.15 00:00] 44.710-45.880 +122286 +0 143/92
[2787: Fri 02.10.15 00:00] 44.660-47.110 +122286 +0 143/92
(USD/CHF::L) Long 100@0.9845 Entry stop
(USD/JPY::S) Short 0@119.05 Entry stop
(GBP/USD::S) Short 142@1.5107 Entry stop
(EUR/JPY::S) Short 238@133.15 Entry stop
(USD/JPY::S) Entry stop 119.05 hit at 00:00
(USD/JPY::S) Skipped: Lots/Margin = 0

[2788: Mon 05.10.15 00:00] 44.010-45.830 +122286 +0 143/92
(USD/CHF::L) Missed entry 0.9845 at exit command
(GBP/USD::S) Missed entry 1.5107 at exit command
(EUR/JPY::S) Missed entry 133.15 at exit command
[2789: Tue 06.10.15 00:00] 45.490-46.950 +122286 +0 143/92
[2790: Wed 07.10.15 00:00] 45.760-49.100 +122286 +0 143/92
[2791: Thu 08.10.15 00:00] 47.730-49.730 +122286 +0 143/92
[2792: Fri 09.10.15 00:00] 47.800-50.070 +122286 +0 143/92
(USD/JPY::S) Short 0@118.67 Entry stop
(EUR/USD::L) Long 75@1.1329 Entry stop
(EUR/USD::L) Entry stop 1.1329 hit at 00:00
[EUR/USD::L9336] Long 75@1.1329 Risk 1705$ at 00:00

[2793: Mon 12.10.15 00:00] 49.200-50.950 +122286 +226 144/92

Monday 12.10.15 Profit +226$ ----
(USD/JPY::S) Missed entry 118.67 at exit command
[EUR/USD::L9336] Sell 75@1.1365: +226$ at 00:00

[2794: Tue 13.10.15 00:00] 47.060-50.160 +122512 +0 144/92
[2795: Wed 14.10.15 00:00] 46.480-48.460 +122512 +0 144/92
[2796: Thu 15.10.15 00:00] 45.970-46.980 +122512 +0 144/92
[2797: Fri 16.10.15 00:00] 45.260-47.040 +122512 +0 144/92
(USD/CHF::S) Short 100@0.9476 Entry stop
(USD/JPY::S) Short 0@118.06 Entry stop
(EUR/USD::L) Long 75@1.1496 Entry stop
(USD/CAD::S) Short 0@1.2831 Entry stop

[2798: Mon 19.10.15 00:00] 46.190-47.520 +122512 +0 144/92
(USD/CHF::S) Missed entry 0.9476 at exit command
(USD/JPY::S) Missed entry 118.06 at exit command
(EUR/USD::L) Missed entry 1.1496 at exit command
(USD/CAD::S) Missed entry 1.2831 at exit command
[2799: Tue 20.10.15 00:00] 45.860-47.360 +122512 +0 144/92
[2800: Wed 21.10.15 00:00] 45.750-46.950 +122512 +0 144/92
[2801: Thu 22.10.15 00:00] 44.890-46.100 +122512 +0 144/92
[2802: Fri 23.10.15 00:00] 44.920-46.120 +122512 +0 144/92
(USD/CHF::S) Short 100@0.9476 Entry stop

[2803: Mon 26.10.15 00:00] 44.240-45.770 +122512 +0 144/92
(USD/CHF::S) Missed entry 0.9476 at exit command
[2804: Tue 27.10.15 00:00] 43.670-44.960 +122512 +0 144/92
[2805: Wed 28.10.15 00:00] 42.620-43.910 +122512 +0 144/92
[2806: Thu 29.10.15 00:00] 43.100-46.240 +122512 +0 144/92
[2807: Fri 30.10.15 00:00] 45.190-46.810 +122512


Attached Files
Last edited by RTG; 11/01/15 00:26.
Re: One Night Stand System [Re: RTG] #455848
11/01/15 03:18
11/01/15 03:18
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Because of your tipp I also compared backtest log and live log and found similar results.

From the backtest log:
Code:
[204: Fri 16.10.15 00:00]  -117 +0 1/3
(USD/CHF::S) Short 2@0.9476 Entry stop
(USD/JPY::S) Short 0@118.06 Entry stop
(EUR/USD::L) Long 10@1.1496 Entry stop
(USD/CAD::S) Short 0@1.2831 Entry stop
Read OneNightStand_4.par

[205: Mon 19.10.15 00:00]  -117 +0 1/3
(USD/CHF::S) Missed entry 0.9476 at exit command
(USD/JPY::S) Missed entry 118.06 at exit command
(EUR/USD::L) Missed entry 1.1496 at exit command
(USD/CAD::S) Missed entry 1.2831 at exit command
[206: Tue 20.10.15 00:00]  -117 +0 1/3
[207: Wed 21.10.15 00:00]  -117 +0 1/3
[208: Thu 22.10.15 00:00]  -117 +0 1/3
[209: Fri 23.10.15 00:00]  -117 +0 1/3
(USD/CHF::S) Short 2@0.9476 Entry stop
(GBP/USD::L) Long 0@1.5519 Entry stop

[210: Mon 26.10.15 00:00]  -117 +0 1/3
(USD/CHF::S) Missed entry 0.9476 at exit command
(GBP/USD::L) Missed entry 1.5519 at exit command
[211: Tue 27.10.15 00:00]  -117 +0 1/3
[212: Wed 28.10.15 00:00]  -117 +0 1/3
[213: Thu 29.10.15 00:00]  -117 +0 1/3
[214: Fri 30.10.15 00:00]  -117 +0 1/3



From live log:
Code:
[194: Fri 16.10.15 00:00]  1.14672
Weekend at 16.10. 20:00...........
Weekend ends at 18.10. 23:00
[195: Mon 19.10.15 00:00]  1.13671
[196: Tue 20.10.15 00:00]  1.13581
[197: Wed 21.10.15 00:00]  1.13289
[198: Thu 22.10.15 00:00]  1.13542
[199: Fri 23.10.15 00:00]  1.13463
Weekend at 23.10. 20:00...........
Weekend ends at 25.10. 23:00
[200: Mon 26.10.15 00:00]  1.10826
Read OneNightStand.fac
Read OneNightStand.par
[201: Tue 27.10.15 00:00]  1.10190
[202: Wed 28.10.15 00:00]  1.10583
[203: Thu 29.10.15 00:00]  1.10334
[204: Fri 30.10.15 00:00]  1.09242
Weekend at 30.10. 20:00...........



Strange. Does anyone have an idea? laugh

I thought first it might have been caused by the missing +LOGFILE in my live trading instance but the manual states that this flag is always set in Trade mode.

Re: One Night Stand System [Re: Sphin] #455854
11/01/15 12:09
11/01/15 12:09
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
What do you make of Boatman's observation that it doesn't look like zorro is receiving price information from the broker during live trading?

Re: One Night Stand System [Re: RTG] #455856
11/01/15 12:38
11/01/15 12:38
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Regarding my live log it seems that Zorro is receiving price information during live trading, I don't know what else should be printed behind the date:

[204: Fri 30.10.15 00:00] 1.09242 <- I tink this is a price information

But the main aspect is surely that beside this Zorro instance there is another one live trading a Z7 on the same VPS and this is working as expected, so I cannot think of one instance is receiving price information while the other one does not. Both are connected to the same FXCM demo account via API.

Re: One Night Stand System [Re: Sphin] #455877
11/02/15 10:58
11/02/15 10:58
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
You can see if Zorro receives price information in the log and also in the server window. A little asterisk there indicates that a price quote was received for the currently selected asset.

Re: One Night Stand System [Re: jcl] #455902
11/02/15 18:27
11/02/15 18:27
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
There is really an asterik blinking in the server field - then I don't know why Zorro does not like to trade the system ...

Re: One Night Stand System [Re: Sphin] #455918
11/03/15 01:13
11/03/15 01:13
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
My only other thought is that some kind of look ahead bias is making trades impossible.

Re: One Night Stand System [Re: RTG] #455925
11/03/15 10:29
11/03/15 10:29
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
I guess it has something to do with my calculation of margin. In live trading I set capital to '1.000' and those trades as in backtest log are senseless anyway:

(USD/CAD::S) Short 0@1.2831 Entry stop

Does it really try to open a trade with 0 lots? laugh

Do you trade it with a capital of 50.000?

Re: One Night Stand System [Re: Sphin] #455946
11/03/15 23:24
11/03/15 23:24
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
The demo account with FXCM is $50k AUD.

Re: One Night Stand System [Re: RTG] #455953
11/04/15 10:16
11/04/15 10:16
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Okay, but I meant what do you use as 'Capital' within the strategy e.g.:
Code:
Capital = 50000;

(Zorro does not care about how much money you have in your account)

Quote:
My only other thought is that some kind of look ahead bias is making trades impossible.

Do you mean peeking into the future? Sure in general, but where in this simple code should this happen?

Re: One Night Stand System [Re: Sphin] #456023
11/06/15 02:17
11/06/15 02:17
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
An update.

It setup trades today. See attached screenshot.

Attached Files ONS Sphin 5-11-2015.jpg
Re: One Night Stand System [Re: RTG] #456024
11/06/15 07:00
11/06/15 07:00
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Mine does not. Do you also use 1.36.5 or any other version? Yours tries to open a trade with 0 lots (EUR/JPY:S) like I saw in my backtest log. Do you know what that mean? OptimalF for EUR/JPY:S is 0.999, this can't be the reason.

Re: One Night Stand System [Re: Sphin] #456027
11/06/15 13:11
11/06/15 13:11
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
No Zorro version can open trades with 0 lots. When you attempt to enter a trade with 0 lots, as your script apparently did, you will see a warning in the message window and the trade is not opened.

Setting a margin of 0 lots is of course a reason when a script never opens trades.

Re: One Night Stand System [Re: jcl] #456037
11/06/15 16:46
11/06/15 16:46
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
I thought that Zorro won't open a trade with 0 lots, therefore the formula for the margin needs to be surely reworked. I first used 0.5 as a factor like in the manual but that led to margin calls. With a very restrictive 0.1 it looked reasonable in the backtest, but mixed with a low OptimalF there might be not enough left for one lot, esp. when reducing Capital to 1.000.
But beside of this "pre-alpha trial of optimization" there is one fact I really wonder: why there are trades (with more than 0 lots of course) set up only in backtest and not in live trading? I will try to find it out ...

Re: One Night Stand System [Re: Sphin] #456044
11/06/15 19:29
11/06/15 19:29
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
BTW: One reason for Zorro's try to open trades with 0 lots is simply that the OptimalF for this asset/algo is .000. I guess this is quite normal and the corresponding entry in the log is "Skipped: Lots/Margin = 0" that also appears e.g. in the log of Workshop6_2. There one does not find a "Long 0@xxx Entry stop" because trades are always entered at market.

Re: One Night Stand System [Re: Sphin] #456048
11/07/15 01:13
11/07/15 01:13
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
I am running version 1.32.

Two trades entered on Friday and as you say, the 0 lot trade skipped. Sreen shot attached.

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

Joined: Dec 2013
Posts: 568
Fuerth, DE
Mine does not do anything concerning trades. Although you should have the same values (but you never know): Could you please take a look into your Data/ONS.fac (or whatever your script is named) and post the OptimalF of EUR/JPY:S? In my .fac it is .999 and this would not explain why lots are set to 0.

Re: One Night Stand System [Re: Sphin] #456053
11/07/15 11:16
11/07/15 11:16
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
My .fac file

EUR/USD .656 2.85 32/17 38.2
EUR/USD:L .999 3.68 9/6 12.7
EUR/USD:S .561 2.60 23/11 25.5
GBP/USD .424 1.76 29/18 21.3
GBP/USD:L .006 1.01 12/10 0.1
GBP/USD:S .585 2.71 17/8 21.2
USD/CAD .000 0.63 17/21 -8.0
USD/CAD:L .000 0.72 14/14 -4.5
USD/CAD:S .000 0.41 3/7 -3.4
USD/CHF .999 2.05 24/23 21.5
USD/CHF:L .999 1.64 15/11 9.4
USD/CHF:S .999 3.07 9/12 12.1
USD/JPY .854 2.82 27/19 26.9
USD/JPY:L .999 4.41 23/11 30.7
USD/JPY:S .000 0.33 4/8 -3.8

EUR/JPY isn't there. I looked at the parameter files too.

USD/CHF 10.8 39.9 180=> 1.242
USD/JPY 10.8 70.3 150=> 2.983
GBP/USD 6.07 39.6 250=> 1.537
EUR/USD 6.08 70.4 260=> 2.323
EUR/JPY 10 40 100=> 0.000
USD/CAD 17.3 70.5 220=> 0.859

Last edited by RTG; 11/07/15 11:20.
Re: One Night Stand System [Re: RTG] #456055
11/07/15 15:29
11/07/15 15:29
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
If EUR/JPY is not in your .fac I guess Zorro can't do anything else but to skip trades with this asset when using OptimalF as a factor to create margins. If the asset/algo is not found its OptimalF will be regarded as 0 I think.
Next question is why EUR/JPY is missing, don't you have the historical prices (EURJPY_X.bar files in your history folder)?

Here is my .fac, interesting to see slightly differences in the OptimalFs, apparently we use different historical prices:
Code:
EUR/JPY             .999  6.12   32/12    43.0
EUR/JPY:L           .999  8.29   20/5     25.6
EUR/JPY:S           .999  4.55   12/7     17.4
EUR/USD             .651  2.82   32/17    22.4
EUR/USD:L           .999  3.64    9/6      7.4
EUR/USD:S           .555  2.58   23/11    14.9
GBP/USD             .414  1.73   28/19    12.2
GBP/USD:L           .000  0.99   11/11    -0.1
GBP/USD:S           .579  2.67   17/8     12.4
USD/CAD             .000  0.55   17/22    -5.9
USD/CAD:L           .000  0.59   14/15    -3.9
USD/CAD:S           .000  0.42    3/7     -2.0
USD/CHF             .999  1.99   26/21    11.6
USD/CHF:L           .999  1.80   18/9      6.8
USD/CHF:S           .999  2.49    8/12     4.8
USD/JPY             .875  2.87   28/20    16.6
USD/JPY:L           .999  4.44   24/12    18.9
USD/JPY:S           .000  0.33    4/8     -2.3



Ah ... I just saw the content of your .par file:

Code:
EUR/JPY 10 40 100=> 0.000


EUR/JPY could not be optimized too, seems that you really miss its history.

Last edited by Sphin; 11/07/15 18:44.
Re: One Night Stand System [Re: Sphin] #456057
11/07/15 21:13
11/07/15 21:13
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Yeah you are right. The version on the VPS is not running enough EUR/JPY data.

I backtested on my local virtual box version and got similar results to yourself.

Walk-Forward Test ONS Sphin 14-10-2015 portfolio

Simulated account AssetsFix.dta
Bar period 24 hours (avg 2026 min)
Simulation period 22.06.2005-31.10.2015 (2688 bars)
Test period 19.07.2011-31.10.2015 (1113 bars)
Lookback period 120 bars (24 weeks)
WFO test cycles 4 x 278 bars (57 weeks)
Training cycles 5 x 1575 bars (326 weeks)
Monte Carlo cycles 200
Assumed slippage 10.0 sec
Capital invested 50000$

Gross win/loss 180413$ / -57901$ (+5054p)
Average profit 28593$/year, 2383$/month, 110$/day
Max drawdown -9368$ 8% (MAE -9368$ 8%)
Total down time 61% (TAE 6%)
Max down time 21 weeks from Mar 2014
Max open margin 20616$
Max open risk 31837$
Trade volume 50690254$ (11830425$/year)
Transaction costs -3343$ spr, 0.00$ slp, 0.00$ rol, -2159$ com
Capital required 28455$

Number of trades 236 (56/year, 2/week, 1/day)
Percent winning 61%
Max win/loss 11199$ / -3467$
Avg trade profit 519$ 21.4p (+51.7p / -26.0p)
Avg trade slippage 0.00$ 0.0p (+0.0p / -0.0p)
Avg trade bars 1 (+1 / -1)
Max trade bars 1 (24 hours)
Time in market 21%
Max open trades 5
Max loss streak 8 (uncorrelated 6)

Annual growth rate 34%
Profit factor 3.12 (PRR 2.59)
Sharpe ratio 1.86
Kelly criterion 6.05
R2 coefficient 0.947
Ulcer index 2.4%
Prediction error 47%

Confidence level AR DDMax Capital

10% 115% 5163$ 24936$
20% 107% 7366$ 26780$
30% 102% 8706$ 27901$
40% 102% 8706$ 27901$
50% 100% 9368$ 28455$
60% 100% 9517$ 28579$
70% 98% 10130$ 29092$
80% 96% 10899$ 29736$
90% 93% 12278$ 30890$
95% 88% 14373$ 32643$
100% 70% 24392$ 41026$

Portfolio analysis OptF ProF Win/Loss Wgt% Cycles

EUR/JPY avg .879 4.39 27/11 36.1 //X/
EUR/USD avg .366 2.49 33/19 17.3 X/XX
GBP/USD avg .325 2.56 29/20 9.3 \/X/
USD/CAD avg .000 ---- 0/0 0.0 ....
USD/CHF avg .999 1.47 22/23 2.2 ///X
USD/JPY avg .457 4.39 23/12 29.7 //\/
USOil avg .174 1.96 10/7 5.3 /\//

EUR/JPY .999 4.39 27/11 36.1 //X/
EUR/JPY:L .999 6.48 18/6 28.7 ////
EUR/JPY:S .760 2.36 9/5 7.4 /.\/
EUR/USD .411 2.49 33/19 17.3 X/XX
EUR/USD:L .149 1.28 9/8 0.5 \/\\
EUR/USD:S .584 2.70 24/11 16.8 ////
GBP/USD .456 2.56 29/20 9.3 \/X/
GBP/USD:L .027 1.02 12/10 0.0 \/\/
GBP/USD:S .624 2.64 17/10 9.3 \///
USD/CHF .999 1.47 22/23 2.2 ///X
USD/CHF:L .999 1.43 15/11 1.4 ////
USD/CHF:S .999 1.57 7/12 0.8 ///\
USD/JPY .570 4.39 23/12 29.7 //\/
USD/JPY:L .915 4.39 23/12 29.7 //\/
USD/JPY:S .000 ---- 0/0 0.0 ....
USOil .300 1.96 10/7 5.3 /\//
USOil:L .000 ---- 0/0 0.0 ....
USOil:S .348 1.96 10/7 5.3 /\//

Re: One Night Stand System [Re: RTG] #456090
11/09/15 02:07
11/09/15 02:07
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Both the original and the new version of the script took trades this week.

The two versions were running side by side on Zorro 1.32.

I had Zorro 1.34 running the new version of the script and this did not take any trades or 'setup' any trades.

I wlll run the new version of the script on Zorro 1.32 and 1.34 on the same demo account.

Re: One Night Stand System [Re: RTG] #456094
11/09/15 09:31
11/09/15 09:31
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Same idea! laugh I just started the new version on 1.32, 1.36 and 1.38 yesterday. Awaiting Friday for results ...

Re: One Night Stand System [Re: Sphin] #456169
11/13/15 01:05
11/13/15 01:05
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Today my Zorro 1.32 has setup, Zorro 1.34 has not. Both are using the same script.

Re: One Night Stand System [Re: RTG] #456177
11/13/15 10:35
11/13/15 10:35
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Neither 1.32, nor 1.36, nor 1.38 did setup any trades. What assets are your trades of 1.32 trading?

Re: One Night Stand System [Re: Sphin] #456179
11/13/15 14:23
11/13/15 14:23
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
"USD/CHF","USD/JPY","GBP/USD","EUR/USD","EUR/JPY","USD/CAD", "USOil"

Re: One Night Stand System [Re: RTG] #456182
11/13/15 15:03
11/13/15 15:03
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
May I offer some advice? Waiting until a system trades at a certain day is certainly a time-consuming task. I would in such a situation modify the system so that it trades any day, not just Friday, and print out all relevant signals or variables at any bar. Otherwise you know that it does not trade, but still do not know why. Just a suggestion to solve the problem quickly.

Re: One Night Stand System [Re: jcl] #456193
11/13/15 19:18
11/13/15 19:18
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
@RTG: crazy ...

@jcl: Thanks for your hint! I thought the code is too simple but ...

Is there a chance to print a bool variable directly or typecasted with print? My tries always end in a "Error 111: Crash in script".

I tried a workaround:

Code:
if (rising(SMAShort)) 
	string SMAShortD = "rising";
else if (falling(SMAShort))
	string SMAShortD = "falling";


then SMAShortD is either (null) or "falling". If I turn it upside down:

Code:
if (falling(SMAShort)) 
	string SMAShortD = "falling";
else if (rising(SMAShort))
	string SMAShortD = "rising";


then SMAShortD is either (null) or "rising". I really like to know what I'm doing wrong.

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

Joined: Jun 2013
Posts: 1,609
Hi Sphin,

Quick answers:

printf a bool with %i.

C strings are trickier than other languages & you probably need a paradigm shift. laugh

HTH.

Re: One Night Stand System [Re: jcl] #456199
11/14/15 01:32
11/14/15 01:32
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Originally Posted By: jcl
May I offer some advice? Waiting until a system trades at a certain day is certainly a time-consuming task. I would in such a situation modify the system so that it trades any day, not just Friday, and print out all relevant signals or variables at any bar. Otherwise you know that it does not trade, but still do not know why. Just a suggestion to solve the problem quickly.


I tried some of those ideas.

I tried changing the bar period (all the way down to 1 minute) and day of week to any day in an attempt to get it working. IIRC that method worked in getting zorro to open trades.

Going from shorter bar periods to daily bars coincided with the script not opening any trades on zorro 1.34. When we checked the trade logs in the backtest and compared to live testing, there were trades that should have opening and pending trades that also should have been established. Since the script was function on Zorro 1.32 prior and the only thing that had changed was the new Zorro, I am testing side by side the same script on 1.32 and 1.34.

You can see in the attached screen caps that Zorro 1.32 setup the pending trades and took the USD/CHF this Friday whilst Zorro 1.34 didn't.

Attached Files ONS Sphin 13-11-2015 Zorro 1.32.jpgONS Sphin 13-11-2015 Zorro 1.34.jpg
Re: One Night Stand System [Re: RTG] #456212
11/15/15 10:04
11/15/15 10:04
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
Maybe, your script has a bug which makes it trade just randomly? This could explain while it behaves different on different sessions and versions.

I think with printing out and comparing the trade signals between different sessions you can find the problem quick, or could have already found it.

Re: One Night Stand System [Re: Petra] #456218
11/15/15 13:28
11/15/15 13:28
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
@DdlV: Thanks, %i does it!

@Petra:
Quote:
Maybe, your script has a bug which makes it trade just randomly?
This won't explain IMO why it trades always in backtest and never in real trading.

@RTG: There are still several points of failure, the conditions could not become true, BuyStop, SellStop and/or the margins could not have been calculated or at last, Zorro refused to open trades. I added some lines of debug code that should reveal where to investigate further. If the script should trade each day, omit the "dow() == 5 &&" from the conditions, then the trade will be immediately closes afterwards (if it's not Friday) but this is not important for our purpose.

Attached Files
ONS_Sphin_DEBUG.txt (377 downloads)
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,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
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.

Re: One Night Stand System [Re: Sphin] #456471
11/24/15 09:59
11/24/15 09:59
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
I do not know the code in such detail, but would not expect that you can open a trade on the last bar. By default, trades open at the Open of the next bar. With no next bar, I don't think that a trade will open.

Also I think your problem is now clear: if the day is important for your trade, it's not good to enter trades exactly at midnight or just at the start of the weekend. The PC time is never this precise. If the server time is a microsecond slower than your PC time, you might get a tick with a 23:59:59.9999 time stamp, while your PC clock has already the next day at 00:00:00.0001. This is different to the backtest when tick time and PC time are always in sync. So better check the whole time and not only the day. Or set the bar offset so that your daily bars do not change exactly at midnight.

I will also mention this potential trap in the manual.

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

Joined: Dec 2013
Posts: 568
Fuerth, DE
Oops - big misunderstanding. It seemed to me that the time in the field "Server" is the UTC of the broker's server and this is the one and only time authority that says 00:00 and therewith rings in the beginning of a new day etc. I didn't think of local time having any effect to time events during trading. But okay, if so a BarOffest of 5 minutes should solve the problem. Thanks!

Re: One Night Stand System [Re: Sphin] #456535
11/27/15 14:31
11/27/15 14:31
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
I had 3 pending trades setup and 2 execute today.

Re: One Night Stand System [Re: RTG] #456547
11/27/15 21:59
11/27/15 21:59
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
I had also pending trades and strange errors when Zorro tried to execute two of them, three had been executed. I reported the execution problems in Beta Test Area concerning 1.40 because I'm not quite sure if they are related to the new version I'm already using.

You realized the solution of our problem that Zorro did not setup trades? It must have been a time sync problem and can be avoided if "BarOffest = 5" e.g. is added to the run function, so the daily bars are shifted 5 minutes after midnight and therewith surely after the change of the day.

I menawhile changed the assets in my asset loop slightly concerning to their performance over the time that is available. Oversampling might be still another possibility as jcl stated in his actual entry in his blog, but I didn't try it so far. So my assets are actualy for the ONS:

"AUD/JPY","AUD/USD","CHF/JPY","EUR/JPY","EUR/USD","GBP/USD","NZD/CHF","NZD/JPY","USD/CHF","USD/JPY","USOil"





Re: One Night Stand System [Re: Sphin] #456548
11/27/15 22:43
11/27/15 22:43
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Is the BarOffset required for Zorro versions after 1.32?

Re: One Night Stand System [Re: RTG] #456549
11/27/15 22:58
11/27/15 22:58
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
I think it does not depend on the Zorro version, in my case 1.32 didn't trade too without it.

Re: One Night Stand System [Re: Sphin] #456585
11/30/15 00:08
11/30/15 00:08
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Mine exited correctly this morning.


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

Joined: Dec 2013
Posts: 568
Fuerth, DE
I guess you got a perfect time sync! So nice BarOffset might be, it involves a new fact that isn't. While it is negligible if the entry stops are set 5 minutes earlier or later, closing positions that try to exploit a weekend gap only 5 minutes after the market has started again after weekend might have an impact on the result that is unfortunately confirmed by the backtest. As from the manual BarOffset must not change during the script run I tried to find another solution. I did some experiments with TMFs that I expected to be able to watch the market but those tries were completely running down the drain because of strange effects I can't explain (yet). So my only workaorund actually is setting BarOffset = 1 hoping this delay is sufficient to get the change of day for the entry clearly. But I'm working on ... laugh

Re: One Night Stand System [Re: Sphin] #456587
11/30/15 00:58
11/30/15 00:58
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
No BarOffset set (other than what maybe set by default) on that version of the script which executed those trades.

Re: One Night Stand System [Re: RTG] #456592
11/30/15 11:35
11/30/15 11:35
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
If midnight is really the best for that system, leave BarOffset at 0. Just check if the current hour is 23 or 0 before comparing the week day. This is anyway the proper solution when you don't want to delay the trades through BarOffset.

Re: One Night Stand System [Re: jcl] #456636
12/02/15 00:16
12/02/15 00:16
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
IIRC optimising the start time suggested that UTC (i.e. no offset) start time was the most robust, so I will leave it like that on the Zorro 1.32 version.

Incidentally I backtested the original unoptimised script and in 2015 so far it has performed really well. Considering this would be more 'out of sample' data it adds evidence for the hypothesis that is a good system for decent returns whilst keeping capital deployed for regular but short time periods.

BackTest ONS Portfolio portfolio

Simulated account AssetsFix.dta
Bar period 24 hours (avg 2028 min)
Test period 02.01.2015-02.12.2015 (238 bars)
Lookback period 40 bars (8 weeks)
Monte Carlo cycles 200
Assumed slippage 10.0 sec
Capital invested 50000$

Gross win/loss 40797$ / -12491$ (+2436p)
Average profit 30955$/year, 2580$/month, 119$/day
Max drawdown -2461$ 9% (MAE -2461$ 9%)
Total down time 59% (TAE 8%)
Max down time 5 weeks from Apr 2015
Max open margin 7676$
Max open risk 7301$
Trade volume 9002053$ (9844311$/year)
Transaction costs -724$ spr, 0.00$ slp, 0.00$ rol, -325$ com
Capital required 12133$

Number of trades 81 (89/year, 2/week, 1/day)
Percent winning 62%
Max win/loss 6338$ / -2011$
Avg trade profit 349$ 30.1p (+70.2p / -34.7p)
Avg trade slippage 0.00$ 0.0p (+0.0p / -0.0p)
Avg trade bars 1 (+1 / -1)
Max trade bars 1 (24 hours)
Time in market 34%
Max open trades 5
Max loss streak 4 (uncorrelated 5)

Annual growth rate 63%
Profit factor 3.27 (PRR 2.38)
Sharpe ratio 2.43
Kelly criterion 9.55
R2 coefficient 0.851
Ulcer index 4.1%
Prediction error 64%

Confidence level AR DDMax Capital

10% 281% 1834$ 10997$
20% 281% 1834$ 10997$
30% 281% 1834$ 10997$
40% 277% 1935$ 11180$
50% 268% 2133$ 11539$
60% 261% 2318$ 11875$
70% 239% 2904$ 12937$
80% 228% 3252$ 13567$
90% 215% 3711$ 14397$
95% 207% 4011$ 14942$
100% 163% 6273$ 19038$

Portfolio analysis OptF ProF Win/Loss Wgt%

EUR/JPY avg .1000 1.03 3/3 0.1
EUR/USD avg .1000 2.62 11/3 17.1
GBP/USD avg .1000 3.75 5/3 5.9
GER30 avg .1000 10.10 9/4 72.2
USD/CAD avg .1000 0.98 6/5 -0.1
USD/CHF avg .1000 4.19 5/5 2.1
USD/JPY avg .1000 0.68 4/5 -3.5
USOil avg .1000 5.30 7/3 6.2

EUR/JPY .1000 1.03 3/3 0.1
EUR/JPY:L .1000 0.00 0/1 -1.2
EUR/JPY:S .1000 1.42 3/2 1.3
EUR/USD .1000 2.62 11/3 17.1
EUR/USD:L .1000 0.52 2/3 -5.1
EUR/USD:S .1000 ++++ 9/0 22.3
GBP/USD .1000 3.75 5/3 5.9
GBP/USD:L .1000 0.00 0/1 -1.7
GBP/USD:S .1000 17.81 5/2 7.6
GER30 .1000 10.10 9/4 72.2
GER30:L .1000 7.58 7/3 47.8
GER30:S .1000 37.41 2/1 24.4
USD/CAD .1000 0.98 6/5 -0.1
USD/CAD:L .1000 1.64 6/4 2.3
USD/CAD:S .1000 0.00 0/1 -2.4
USD/CHF .1000 4.19 5/5 2.1
USD/CHF:L .1000 6.95 5/4 2.4
USD/CHF:S .1000 0.00 0/1 -0.3
USD/JPY .1000 0.68 4/5 -3.5
USD/JPY:L .1000 3.08 4/2 5.1
USD/JPY:S .1000 0.00 0/3 -8.7
USOil .1000 5.30 7/3 6.2
USOil:L .1000 1.52 1/1 0.2
USOil:S .1000 6.59 6/2 6.0

Re: One Night Stand System [Re: RTG] #456641
12/02/15 14:48
12/02/15 14:48
Joined: Feb 2015
Posts: 652
Milano, Italy
M
MatPed Offline
User
MatPed  Offline
User
M

Joined: Feb 2015
Posts: 652
Milano, Italy
nice job RTG!

Re: One Night Stand System [Re: MatPed] #456662
12/02/15 22:39
12/02/15 22:39
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Thanks but Sphin has coded and debugged most of it along with JCL. I initially wanted to backtest a strategy from a pdf I had.

Re: One Night Stand System [Re: RTG] #456665
12/02/15 23:07
12/02/15 23:07
Joined: Feb 2015
Posts: 652
Milano, Italy
M
MatPed Offline
User
MatPed  Offline
User
M

Joined: Feb 2015
Posts: 652
Milano, Italy
ok, so nice teamwork! I'd like to see the final version of the code. It would be helpful

Ciao

Last edited by MatPed; 12/02/15 23:09.
Re: One Night Stand System [Re: MatPed] #456685
12/03/15 23:59
12/03/15 23:59
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Only a litle team but at least a team. I guess there is no final code in the meaning of the one and only version. I played with optimizing periods for the different SMAs just like restricting the buy/sell conditions and varying the assets but comparing the different versions over a period of 3-4 years the results are at least similar. The optimized versions may have performed with less DD and lower margins & risks partially on the expense of the result, but the 'raw version' had especially in 2015 a strong performance and is surely less biased than the revised ones.

Re: One Night Stand System [Re: Sphin] #456686
12/04/15 01:06
12/04/15 01:06
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Incidentally I can confirm that setting the BarOffset has got the script to work on my Zorro 1.34.

Re: One Night Stand System [Re: RTG] #456722
12/07/15 00:57
12/07/15 00:57
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Sphin, did you have a profitable exit this morning on USOil?

Re: One Night Stand System [Re: RTG] #456723
12/07/15 01:12
12/07/15 01:12
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Yes I had:

[USOil::S8281] Cover 5@39.58: +11.49 at 00:01

Re: One Night Stand System [Re: Sphin] #456736
12/07/15 14:16
12/07/15 14:16
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
It would have been good to stay on this down the current price of 38.60.

Re: One Night Stand System [Re: RTG] #456773
12/09/15 00:49
12/09/15 00:49
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
I just realised the Margin formula for the optimised version was producing a CAGR of about 40%.

Margin = 0.1 * OptimalFLong * Capital;

Changing it to a compounding version produced a CAGR of 95%. I changed both short and long versions to include compounding equity.

Margin = 0.1 * OptimalFLong * (Capital + WinTotal-LossTotal);

Now is optimalF already doing the compounding as it were as I noticed that the lot sizes go up with equity increases over time? Is introducing the additional WinTotal - LossTotal a form of over optimisation?

Last edited by RTG; 12/09/15 00:57.
Re: One Night Stand System [Re: RTG] #456785
12/09/15 18:43
12/09/15 18:43
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
I fear capital won't stand increasing margins this way over time. If I reinvested profit in the strategy I would use the formula of workshop 6 to build the margin:

Margin = 0.1 * OptimalF(Long/Short) * Capital * sqrt(1 + ProfitClosed/Capital);

Re: One Night Stand System [Re: Sphin] #456792
12/10/15 04:02
12/10/15 04:02
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Of course, totally forgot about that.

Re: One Night Stand System [Re: RTG] #456816
12/11/15 00:40
12/11/15 00:40
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Quote:
If midnight is really the best for that system, leave BarOffset at 0. Just check if the current hour is 23 or 0 before comparing the week day

Yes, I think this is really a suitable approach to avoid BarOffset.

Code:
[195: Mon 07.12.15 00:00] 1.08709
DOW: 1 - Time: 0:0:0.00050
[196: Tue 08.12.15 00:00] 1.08814
DOW: 2 - Time: 0:0:0.00050
[197: Wed 09.12.15 00:00] 1.08341
DOW: 2 - Time: 23:59:59.00050
[198: Thu 10.12.15 00:00] 1.08926
DOW: 4 - Time: 0:0:0.00050
[199: Fri 11.12.15 00:00] 1.10149
DOW: 4 - Time: 23:59:59.00050


Re: One Night Stand System [Re: Sphin] #456827
12/11/15 14:41
12/11/15 14:41
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Did you get fills today on USOil?

Re: One Night Stand System [Re: RTG] #456834
12/11/15 16:38
12/11/15 16:38
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Yes, Short 5@36.37.

Last edited by Sphin; 12/11/15 16:39.
Re: One Night Stand System [Re: Sphin] #456874
12/14/15 00:46
12/14/15 00:46
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
And your exit?

I had outsized positions on this account because I had 3 versions of the script running on it at once.
https://www.myfxbook.com/members/Sheffield/ons-20/1420677

Re: One Night Stand System [Re: RTG] #456885
12/14/15 18:39
12/14/15 18:39
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
[USOil::S8703] Cover 5@35.59: +32.76 at 00:01

Oil is performing quite well in ONS up to now. I'm just about to make a version that also avoids BarOffest. But I must check in live trading if this solution is really reliable. Trading several versions parallel is IMO not so crazy as it sounds, you therewith do some kind of 'profit averaging'.

But there is another thought: since I take care I see that Zorro gets prices and says "Weekend ends at XXX 23:00" Sunday night one hour before Monday. Is this already a 'regular' trading hour? Does it make sense to close 'weekend gap trades' already Sunday 23:00 instead of Monday 00:00? But is this hour from Sunday 23:00 to Monday 00:00 covered (and accessible) anywhere using BarPeriod = 1440? I think it isn't because even if I set Weekend = 0 I don't see Sunday Bars. There is only one Bar Saturday 00:00 and the next one is on Monday 00:00.

Re: One Night Stand System [Re: Sphin] #456902
12/15/15 10:49
12/15/15 10:49
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
23:00 is an arbitrary value. You can end the weekend already at 22:00, or later after midnight - it depends on what is best for your system.

Re: One Night Stand System [Re: jcl] #456996
12/18/15 10:12
12/18/15 10:12
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Grmpf ... apperently I need some C-tutoring again. To determine the right day I'm using

Code:
if ((dow() == 5 && hour() == 0) || (dow() == 4 && hour() == 23)) {



The sense is "if either dow is 5 and hour is 0 or if dow is 4 and hour is 23". Is the setting of the brackets logically okay? I read that there are differences in using comparisms in C compared to other program languages, so I'm not quite sure.

Re: One Night Stand System [Re: Sphin] #457039
12/21/15 07:39
12/21/15 07:39
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Well I just found out something very interesting and relevant to this strategy.

I noticed that today's USOil price based on the WTI Futures at Nymex was trading significantly higher than the Nymex price. So it is because of the rollover of contracts from December to January. That is fine but the position I have is taking a massive loss because FXCM's demo accounts allow for trading after the expiration date (due to an oversight at FXCM it seems). I have posted a transcript of a chat with an FXCM representative.

With FXCM
FXCM - Craig: Welcome to FXCM's Live Chat Support. Please give me a moment to review your first question.
FXCM - Craig: In order to assist you I will need to first verify your account
FXCM - Craig: Thanks, please give me a moment to look into this
FXCM - Craig: Our USoil product expired
FXCM - Craig: on Friday
FXCM - Craig: the current contract is the Febuaray one
FXCM - Craig: the NYMEX price you are looking at
Me I thought that maybe the case
FXCM - Craig: is still from January
Me: Thankfully I have only traded that in a demo account
FXCM - Craig: https://www.forextrading.com.au/markets/cfds/oil/
FXCM - Craig: If you look at the above link
FXCM - Craig: you can see our expiration dates
FXCM - Craig: today is the first day of the Feb contract
Me: OK I guess the next question would relate to this
Me: Oil has a monthly expiration (please see the tables below). Clients that hold an open position on the 'FXCM Expiration' will be closed at our bid/offer at: USOil: 22:00 p.m. GMT UKOil: 22:15 p.m. GMT NGAS: 22:00 p.m. GMT Which means the client will realise any floating P/L at the time it is closed.
Me: Shouldn't the positions have been closed according to that guideline?
FXCM - Craig: They were closed
FXCM - Craig: on Friday
FXCM - Craig: at the end of trading
FXCM - Craig: anyone holding a position
FXCM - Craig: would have entered again this morning
FXCM - Craig: Are you saying your demo position was not closed?
Me: yes
FXCM - Craig: please allow me a moment
FXCM - Craig: I see you opened the position at 10:15 on Friday
FXCM - Craig: after the cut off time
Me Its a script which trades the positions and will trade up until close of business UTC time
FXCM - Craig: Had this been a live account
FXCM - Craig: the trades would not have gone through
Me oh
FXCM - Craig: but it appears that the demo allowed trading after the cut off time
FXCM - Craig: there was no live pricing at that time
FXCM - Craig: I will bring up the issue with our demo tech team
Me: Is there a way to get the trades cancelled even though it is a demo account?
FXCM - Craig: unfortunately no, demo accounts can not be altered
Me: Damn. I am using it as a kind of proof of concept for some fellow traders.
Me: Can I safely say that these trades would have not occurred it was a live account?
FXCM - Craig: definately
FXCM - Craig: the first trades on the current contract
FXCM - Craig: would only have opened up this morning
FXCM - Craig: The best I can do
FXCM - Craig: is write you an email confirming a tech error on the demo
FXCM - Craig: or open up a new demo account
Me: OK could you send through an email?
FXCM - Craig: I will have it out to you in a few minutes
ME: Thank you
FXCM - Craig: No problem, we apologize for the inconvenience
Me: OK

Re: One Night Stand System [Re: RTG] #457040
12/21/15 07:46
12/21/15 07:46
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
And the email from FXCM.

Thank you for your interest in FXCM.

In continuation from our conversation. While not yet fully confirmed there appears to be an issue on our demo server and trades on US OIL taken after 22:00 GMT on Friday the 18th should not have executed.

Our tech team will review the error and attempt to rectify this issue by the next expiration date.

This issue did not effect any live servers. We apologies for any inconvenience

Best regards,

Re: One Night Stand System [Re: Sphin] #457044
12/21/15 11:19
12/21/15 11:19
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Originally Posted By: Sphin
Grmpf ... apperently I need some C-tutoring again. To determine the right day I'm using

Code:
if ((dow() == 5 && hour() == 0) || (dow() == 4 && hour() == 23)) {



The sense is "if either dow is 5 and hour is 0 or if dow is 4 and hour is 23". Is the setting of the brackets logically okay? I read that there are differences in using comparisms in C compared to other program languages, so I'm not quite sure.


The brackets are fine as far as I see. Another way to check the time interval around thursday midnight is:

if(between(tow(),42359,50001)) ...

Re: One Night Stand System [Re: jcl] #457053
12/21/15 23:19
12/21/15 23:19
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
RTG, cool managed with FXCM! I had never recognized or taken care of this point.

Thanks jcl, I'll try your proposal too. My construction did not work so far, although I also could not see an error.

Re: One Night Stand System [Re: Sphin] #457267
01/11/16 01:55
01/11/16 01:55
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Well back to the strategy, did yours take trades in the past few weeks?

Re: One Night Stand System [Re: RTG] #457280
01/11/16 15:31
01/11/16 15:31
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Only this weekend:

[AUD/JPY::S0925] Cover 6@81.26: +33.26 at 00:00
[GBP/USD::S8480] Cover 4@1.4522: +3.58 at 00:00

The week before was 1st January and the week before this was Christmas.

Re: One Night Stand System [Re: Sphin] #457378
01/15/16 23:48
01/15/16 23:48
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Did yours open positions last night?

Mine did but they were stopped out later on.

Re: One Night Stand System [Re: RTG] #457380
01/16/16 01:35
01/16/16 01:35
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Seems like a party this weekend:

[NZD/JPY::S2609] Short 11@75.48 Risk 113$ at 07:08
[AUD/USD::S7479] Short 2@0.6909 Risk 33$ at 08:27
[USOil::S9377] Short 5@29.95 Risk 140$ at 08:55
[NZD/CHF::S9585] Short 3@0.6429 Risk 39$ at 08:58
[AUD/JPY::S9692] Short 6@80.91 Risk 85$ at 08:59
[GBP/USD::S9939] Short 4@1.4350 Risk 45$ at 09:00

Re: One Night Stand System [Re: Sphin] #457382
01/16/16 02:56
01/16/16 02:56
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Yours is behaving differently to mine. Did you add additional assets?

[GBP/USD::S7491] -224$ s1.4599 c1.4362 e1.4350
[USOil::S7442] -678$ s32.96 c29.97 e29.96
[GBP/JPY::S7458] +46$ s171.44 c168.19 e168.83

Which script (version) are you running? Do you train it often?


Last edited by RTG; 01/16/16 03:00.
Re: One Night Stand System [Re: RTG] #457388
01/16/16 10:56
01/16/16 10:56
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
It's the version from #455223 of this thread here, but I do some experiments with other assets, so my actual asset loop is:

while(asset(loop("AUD/JPY","AUD/USD","CHF/JPY","EUR/JPY","EUR/USD","GBP/USD","NZD/CHF","NZD/JPY","USD/CHF","USD/JPY","USOil")))

IMO training often doen't make much sense using daily bars. Maybe again after one year or something.
I still use BarOffset=1 because I did some mistakes on my own the last weeks so I cannot confirm yet that the other conditions work, but they should. One problem was that if timestamp of the decisive bar is on Thursday I had to incclude this day (dow()!=4) in the exit condition, otherwise Zorro tries to setup the trade and gives up immediately afterwards with "Missed entry". No problem of Zorro but of mine.

Re: One Night Stand System [Re: Sphin] #457410
01/17/16 11:53
01/17/16 11:53
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
So what is the profit/loss since you have started running it?

My live demo has suffered from several technical failures (the first was the bar offset problem and the second was that huge oil loss from incorrect contract allocation by FXCM). Both of these problems have steered me away from trading it for real.

I also have a problem with the Oil contract size being different from what the broker has. For instance on Friday it went short 780 contracts instead of 78. I can change this in assetsfix but this file is downloaded from the broker when it connects, effectively overriding my changes?

On a topic more closely related to the strategy, I was listening to a trading podcast where the subject was seasonality it equity markets. The speaker claimed that are a lot of automatic purchases of US equities within the last 4 days of the trading month and between the first 3 trading days of the next month. Consequently he claimed that there was an edge in buying in the last 4 days of the month and selling within the next 3 days of the next month.

Naturally I thought to test this idea with Zorro on the SPX500. This is long only obviously. My version simply buys on the 18th trading day of the month and sells on the 3rd day of the next month. I was thinking to add this to the ONS system.

-----------------------------------------------------
//Jay Kaeppel Last 4, first 3 trading days of the S&P500

#include <profile.c>

function run(){
// UpdateDays = -1;
set(PARAMETERS+FACTORS);
Verbose = 14;
// Detrend = TRADES;
// Capital = 2000;
// Margin = OptimalFLong * Capital * sqrt(1 + max(0,WinTotal-LossTotal)/Capital);
BarPeriod = 1440;
StartDate = 2005;
// NumWFOCycles = 5;
asset("SPX500");
var OptimalStop = optimize(50,50,500,50) * PIP;

if(tdm(0) == 18) //optimize(1,1,23,1))
enterLong(0,0,OptimalStop, 0); // stop loss
if(tdm(0) == 3) //optimize(1,1,23,1))
exitLong();

plotMonthProfit();

}

Re: One Night Stand System [Re: RTG] #457422
01/18/16 00:40
01/18/16 00:40
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Concerning the new algorithm: from when is the podcast you found? I tried your approach with SPX500 and US30 and the first thing I saw was the poor performance in 2015 compared with the years before. Did you see this too? It might be random of course or the behaviour has changed. But I won't include this in ONS anyway because the assets are completely different, so another loop would be necessary and as far as I know this is not yet possible in one script.

My ONS also suffered from the FXCM-Oil-Problem that caused a loss of 60, and so the total profit is actual +177 since 27.11.2015, where +119 are just from this weekend:

Weekend ends at 17.01. 23:00
[Mon 18.01.16 00:01] 49568 +0 +119 /////\
[AUD/JPY::S9692] Cover 6@80.24: +31.23 at 00:00
[AUD/USD::S7479] Cover 2@0.6858: +9.45 at 00:00
[GBP/USD::S9939] Cover 4@1.4271: +29.09 at 00:00
[NZD/CHF::S9585] Cover 3@0.6455: -7.38 at 00:00
[NZD/JPY::S2609] Cover 11@75.38: +7.92 at 00:00
[USOil::S9377] Cover 5@28.86: +48.54 at 00:00

Problems with Oil position sizes I did not have so far, AssetsFix is not used in trade mode as far as I know but Assets.csv, that is downloaded on each connect to the broker.

Re: One Night Stand System [Re: Sphin] #457423
01/18/16 01:40
01/18/16 01:40
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Podcast link

http://bettersystemtrader.com/034-jay-kaeppel/

2015 was pretty poor. So that edge maybe gone.

to include in the script I would create another function and call it after the trade ons function.

For you to have the same oil problem as me, you must be running a demo account. I hope so because otherwise the fxcm representative was incorrect about this issue only affecting demo accounts.

Re: One Night Stand System [Re: RTG] #457589
01/23/16 00:32
01/23/16 00:32
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Sure, it is still a demo account. This week I started an ONS in parallel on a demo account of a Market Maker Broker (via MT4) for comparism reasons. Although the prices (I saw) were nearly equal (FXCM and XM) today the XM version set up a long trade in USD/CHF (that was entered at noon) while the FXCM version did not. LookBack is set to 80 and no errors occured in Zorro, so I think this wasn't a problem. There must be a difference in calculation of the SMAs between FXCM and XM. I'll make the script print some information for evaluating this in future. This is a ridiculous example only, but "success of a strategy depends on the broker" is really an interesting view. laugh
My FXCM version set up 10 trades but no entry price was hit and no trade was entered.

Re: One Night Stand System [Re: Sphin] #457777
01/30/16 03:35
01/30/16 03:35
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Three setups but no entries this week for mine.


(CHF/JPY::S) Short 27@115.35 Entry stop
(GBP/USD::S) Short 95@1.4079 Entry stop
(NZD/JPY::S) Short 199@73.65 Entry stop

Re: One Night Stand System [Re: RTG] #457781
01/30/16 14:28
01/30/16 14:28
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
My "classic" version set up 2 of your 3 trades and also none was entered:

(CHF/JPY::S) Short 18@115.35 Entry stop
(NZD/JPY::S) Short 111@73.65 Entry stop

I don't know why GBP/USD was not set up, I guess the values in our .par file might be different.

My alternative versions on FXCM and XM behaved in parallel (the values below are from FXCM):

(CAD/JPY::S) Short 4@78.94 Entry stop
(CHF/JPY::S) Short 1@115.34 Entry stop
(EUR/GBP::L) Long 3@0.7757 Entry stop
(EUR/USD::L) Long 2@1.0986 Entry stop
(USD/CHF::L) Long 1@1.0200 Entry stop

Interestingly GBP/USD wasn't set up just as NZD/JPY because:

42359 - GBP/USD: SMAShort:1.42744 (0|1), SMALong: 1.47032 (1|0)
42359 - NZD/JPY: SMAShort:76.68233 (0|1), SMALong: 79.66663 (1|0)

((1|0) = falling, (0|1) = rising)

I trained the alterative versions without WFO using the whole price information from 2002 to 2015 (resp. 2009 to 2015) for optimizing the parameters. Although there is of course no sense to use those parameters to predict the performance because of merciless overfitting, I believe the averages of the parameters from the whole time can result in useful settings for the trading in future and especially for the assets of which I only have prices from 2009 to 2015 I think this period is already quite narrow for optimizing on daily bars, so I don't want to cut it smaller using WFOs. If my thoughts really make sense time will tell.

The alternative versions entered one trade only (again FXCM):

(USD/CHF::L) Entry stop 1.0200 hit at 03:42

that is +/- 0 actually.

Re: One Night Stand System [Re: Sphin] #458043
02/14/16 02:31
02/14/16 02:31
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Setups this week on the extended asset list. No trades taken.

[Fri 12.02.16 00:05] 21256 -494 +0
(AUD/JPY::S) Short 108@77.59 Entry stop
(AUD/USD::S) Short 37@0.6973 Entry stop
(CHF/JPY::S) Short 27@114.47 Entry stop
(EUR/JPY::S) Short 122@125.78 Entry stop
(EUR/USD::L) Long 32@1.1378 Entry stop
(NZD/CHF::S) Short 40@0.6373 Entry stop
(NZD/JPY::S) Short 199@73.22 Entry stop
(USD/CHF::S) Short 27@0.9661 Entry stop
(USD/JPY::S) Short 0@110.97 Entry stop
(USOil::S) Short 91@26.07 Entry stop
Weekend at 12.02. 20:00.....................................

Re: One Night Stand System [Re: RTG] #458054
02/14/16 20:23
02/14/16 20:23
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Right, none of the ONS variants took a trade this weekend.

Re: One Night Stand System [Re: Sphin] #458122
02/19/16 22:43
02/19/16 22:43
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
This week's setups and entry.


(AUD/JPY::S) Short 103@77.59 Entry stop
(CHF/JPY::S) Short 26@113.89 Entry stop
(EUR/USD::L) Long 30@1.1378 Entry stop
(NZD/JPY::S) Short 191@73.22 Entry stop
(USD/JPY::S) Short 0@110.97 Entry stop
(CHF/JPY::S) Entry stop 113.89 hit at 00:54
[CHF/JPY::S2061] Short 26@113.88
Weekend at 19.02. 20:00

Re: One Night Stand System [Re: RTG] #458152
02/22/16 00:52
02/22/16 00:52
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Right, and it worked this way:

[CHF/JPY::S0260] Cover 18@113.63: +35.66 at 00:00

Re: One Night Stand System [Re: Sphin] #458159
02/22/16 19:18
02/22/16 19:18
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Regarding the trade history here there is one heavy trade of mine missing:

[Mon 08.02.16 00:01] 49182 +119 -210 \'
[EUR/USD::L4389] Sell 22@1.1144: -210$ at 00:00

For the sake of completeness and not to give the impression this system would produce only winners. This was really a heavy loss, don't you have such a trade too?

Re: One Night Stand System [Re: Sphin] #458165
02/22/16 22:17
02/22/16 22:17
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Yes mine had the same one.

Re: One Night Stand System [Re: RTG] #458194
02/24/16 23:35
02/24/16 23:35
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
I ran the backtest to compare the live trading. The CHF/JPY trade was the same but there was an extra trade in the backtest on the EUR/JPY.

19.02.16 00:05] 30.300-32.000 +102330 +0 266/163
(CHF/JPY::S) Entry stop 113.89 hit at 00:05
[CHF/JPY::S6430] Short 40@113.89 at 00:05
(EUR/JPY::S) Entry stop 125.59 hit at 00:05
[EUR/JPY::S6431] Short 177@125.59 at 00:05

[2864: Mon 22.02.16 00:05] 29.080-32.040 +102330 +839 268/163

Monday 22.02.16 Profit +839$ ----
[CHF/JPY::S6430] Cover 40@113.61: +74.92 at 00:05
[EUR/JPY::S6431] Cover 177@125.20: +764$ at 00:05

Re: One Night Stand System [Re: RTG] #458204
02/25/16 22:11
02/25/16 22:11
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
I have the same EUR/JPY trade only in backtest, in live trading an EUR/JPY trade was no even set up. Very strange.

Re: One Night Stand System [Re: Sphin] #458225
02/28/16 01:03
02/28/16 01:03
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
That was odd and it was a decent winning trade we missed out on.

This week's trade.

(GBP/USD::S) Entry stop 1.3878 hit at 15:53
[GBP/USD::S9824] Short 91@1.3877
Weekend at 26.02. 20:00.........................................

Last edited by RTG; 02/28/16 01:04.
Re: One Night Stand System [Re: RTG] #458239
02/29/16 00:59
02/29/16 00:59
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
I can't retrace from my logs why Zorro didn't set up the EUR/JPY trade, I did not log additional information so far but I will consider this in future.

The trade of this weekend:

GBP/USD::S5298] Cover 42@1.3861: +54.59 at 00:00

Re: One Night Stand System [Re: Sphin] #458240
02/29/16 02:13
02/29/16 02:13
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Similar result. The 5 minute bar offset in this case led to a different fill price to yours.


Monday 29.02.16 Profit +163$ ----
[GBP/USD::S9824] Cover 91@1.3863: +160$ at 00:04

Re: One Night Stand System [Re: RTG] #458253
02/29/16 23:40
02/29/16 23:40
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
You can avoid the BarOffset modifying the trading function:
Code:
function tradeOneNightStand() {
	
  vars Price = series(price());

  vars SMAShort = series(SMA(Price, optimize(10,5,20)));
  vars SMALong = series(SMA(Price, optimize(40,30,80,5)));

  Stop = optimize(100,100,500,10) * PIP;
  
  var BuyStop = HH(10) + 1*PIP;
  var SellStop = LL(10) - 1*PIP;

 if(between(tow(),42355,50005)) {

	if (SMAShort[0] > SMALong[0] && rising(SMAShort) && rising(SMALong) && NumOpenLong == 0 && NumPendingLong == 0) {
			Margin = 0.1 * OptimalFLong * Capital * sqrt(1 + ProfitClosed/Capital);
			enterLong(0,BuyStop);
  	}
  	else if (SMAShort[0] < SMALong[0] && falling(SMAShort) && falling(SMALong) && NumOpenShort == 0 && NumPendingShort == 0) {
			Margin = 0.1 * OptimalFShort * Capital * sqrt(1 + ProfitClosed/Capital);
			enterShort(0,SellStop);			
  	}	
 }

 if (dow() != 4 && dow() != 5 && dow() != 6) {
	exitLong();
	exitShort();
 }
}



Including dow() != 4 is important, otherwise Zorro closes the trades immediately after setting them up. This code works also in live trading! laugh

Re: One Night Stand System [Re: Sphin] #458326
03/04/16 14:00
03/04/16 14:00
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Today's setups (and skipped trade).

[Fri 04.03.16 00:05]
(AUD/USD::L) Long 0@0.7375 Entry stop
(CHF/JPY::S) Short 26@112.29 Entry stop
(EUR/JPY::S) Short 123@122.08 Entry stop
(AUD/USD::L) Entry stop 0.7375 hit at 03:30
(AUD/USD::L) Skipped: Lots/Margin = 0

Re: One Night Stand System [Re: RTG] #458333
03/05/16 00:32
03/05/16 00:32
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Yes, but the entries were too far away for entering trades.

Re: One Night Stand System [Re: Sphin] #458335
03/05/16 02:03
03/05/16 02:03
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
AUD/USD would be in profit (+58 PIPs).

Come to think of it, I read in another thread that the AUD/USD history file on the download page was corrupted. OptimalFLong is negative in my case anyway hence the 0 lots entry.


Last edited by RTG; 03/05/16 02:12.
Re: One Night Stand System [Re: RTG] #458336
03/05/16 09:10
03/05/16 09:10
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Wow, this thread has over 16000 views. Is anyone other myself and Spin using this strategy?

Re: One Night Stand System [Re: RTG] #458339
03/05/16 13:44
03/05/16 13:44
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
If OptimalF for AUD/USD:L is 0 then only AUD/USD:S is traded, otherwise this Asset doesn't make sense at all in the Asset set. I based my decision to include an asset or not simply on the idea that there are assets for which the ONS works while for others it does not, and this idea is based on the historical prices. E.g. in my candidats' setup for trading the ONS real I only use assets with a single PF not lower than 1.5 in any simulation and an average PF of ~2.0 or above (BTW: Interestingly >50% are pairs against the JPY that seems to have a 'special iking' for the ONS). This is surely somewhat subjective and weighted by past but the opposite was to trade every available pair with a fixed lot amount and this could also be more successful in the end, who knows?
There are really a lot of views for this thread, how comes? I sometimes think about if ONS is a strategy or rather gambling, but at least it's a cool alternative to the weekend's lottery! laugh

Re: One Night Stand System [Re: RTG] #458343
03/05/16 17:48
03/05/16 17:48
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Originally Posted By: RTG
Wow, this thread has over 16000 views. Is anyone other myself and Spin using this strategy?

I've linked to it from a recent post on Financial Hacker - hope that is ok with you.

Re: One Night Stand System [Re: jcl] #458353
03/06/16 12:50
03/06/16 12:50
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Cool.

Ive run a long only version of the mean reversion script on the S&P500 which backtests well.

Re: One Night Stand System [Re: RTG] #458463
03/11/16 14:24
03/11/16 14:24
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
USOil was entered into however 870 contracts were bought at 38.50 instead of 87. I had changed the .dta file to account for this but I assume the .dta carrying the margin value is overwritten every time a broker connection is made. So the incorrect margin value must have been reset.

That aside, I am struggling to work out why the position was closed out immediately. There is no stop set in the script Im running.

Edit: It was closed out due to margin call. The position size is 10x larger than what it should be.

The mystery solved.

When Zorro is connected to a broker, it loads the current spread and rollover values from the broker's server. When not connected, the spread and rollover values are loaded from the History\AssetsFix.dta file or from the parameter file given by AssetList.

So I need to set the margin for oil in the script.


[USOil::L1830] -696$ s0.00000 c38.49 e38.50


[197: Thu 10.03.16 00:05] 112.605
[198: Fri 11.03.16 00:05] 113.290
(AUD/USD::L) Long 0@0.7529 Entry stop
(CHF/JPY::S) Short 26@111.90 Entry stop
(EUR/JPY::S) Short 123@122.08 Entry stop
(USOil::L) Long 87@38.50 Entry stop
(USOil::L) Entry stop 38.50 hit at 03:32
[USOil::L1830] Long 87@38.50

[USOil::L1830] -696$ s0.00000 c38.49 e38.50


Last edited by RTG; 03/11/16 15:00.
Re: One Night Stand System [Re: RTG] #458466
03/11/16 16:21
03/11/16 16:21
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Mine only set up (CHF/JPY::S). In the other assets the directions of the SMAs were not the same. How did you train your strategy (WFO, StartDate, EndDate)?

Re: One Night Stand System [Re: Sphin] #458471
03/12/16 00:12
03/12/16 00:12
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
StartDate = 2005;
// EndDate = 20160226;
NumWFOCycles = 5;

Re: One Night Stand System [Re: RTG] #458517
03/16/16 17:53
03/16/16 17:53
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
I snyced mine but it didn't set up a trade in Oil last Friday, not even in backtest. Was it successful? What are your USOil parameters? Mine are

USOil 13.1 70.3 300=> 3.295

Re: One Night Stand System [Re: Sphin] #458520
03/17/16 00:59
03/17/16 00:59
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Well my position was closed almost immediately due to a margin call. This was due to the position size being 100x larger than intended and not having enough equity to maintain it.

I have stopped and retrained mine since that trade. I had manually set the fast SMA to 7 and the slow one to 45.

Re: One Night Stand System [Re: RTG] #458537
03/18/16 14:27
03/18/16 14:27
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Lookback period (120 bars).
[197: Fri 18.03.16 00:05] 85.541
(AUD/JPY::L) Long 210@86.42 Entry stop
(AUD/USD::L) Long 0@0.7660 Entry stop
(EUR/USD::L) Long 8@1.1344 Entry stop
(USD/CHF::S) Short 26@0.9650 Entry stop
(USD/JPY::S) Short 0@110.66 Entry stop
(USOil::L) Long 1@40.58 Entry stop
(AUD/USD::L) Entry stop 0.7660 hit at 01:07
(AUD/USD::L) Skipped: Lots/Margin = 0
(USOil::L) Entry stop 40.58 hit at 10:39
[USOil::L7578] Long 1@40.58

Re: One Night Stand System [Re: RTG] #458565
03/21/16 01:30
03/21/16 01:30
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
[USOil::L7578] Sell 1@40.75: +36.88 at 01:28

Re: One Night Stand System [Re: RTG] #458593
03/21/16 18:45
03/21/16 18:45
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
[Mon 21.03.16 00:00]
[GBP/USD::L7214] Sell 2@1.4463: -8.05 at 23:59
[USOil::L3202] Sell 2@40.85: +4.08 at 23:59

Anywhere there was/is a time difference, maybe to my local time.

Re: One Night Stand System [Re: Sphin] #458685
03/25/16 07:46
03/25/16 07:46
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Read ONS Sphin + Last 4.par
Lookback period (120 bars).
[197: Fri 25.03.16 00:05] 39.725
(AUD/JPY::L) Long 102@86.42 Entry stop
(AUD/USD::L) Long 0@0.7682 Entry stop
(EUR/USD::L) Long 0@1.1344 Entry stop
(NZD/CHF::S) Short 38@0.6496 Entry stop
(NZD/JPY::S) Short 88@74.44 Entry stop
(USD/CHF::S) Short 0@0.9650 Entry stop
(USD/JPY::S) Short 0@110.66 Entry stop
(USOil::L) Long 1@41.95 Entry stop
Copied to Clipboard!

Re: One Night Stand System [Re: RTG] #458867
04/04/16 00:55
04/04/16 00:55
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
No trades taken this week.

(AUD/JPY::L) Long 102@86.72 Entry stop
(AUD/USD::L) Long 0@0.7724 Entry stop
(EUR/USD::L) Long 0@1.1413 Entry stop
(USD/CHF::S) Short 0@0.9571 Entry stop
(EUR/USD::L) Entry stop 1.1413 hit at 11:00
(EUR/USD::L) Skipped: Lots/Margin = 0
(USD/CHF::S) Entry stop 0.9571 hit at 12:18
(USD/CHF::S) Skipped: Lots/Margin = 0
Weekend at 01.04. 20:00...................................
Weekend ends at 03.04. 23:00

Re: One Night Stand System [Re: RTG] #458886
04/04/16 16:54
04/04/16 16:54
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
[EUR/USD::L2347] Sell 125@1.1396: -2.19 at 23:59
[USD/CHF::S1303] Cover 57@0.9589: -1.02 at 23:59

I had no 0s for OptimalF concerning these algos, but you had the better choice.

Re: One Night Stand System [Re: Sphin] #458937
04/08/16 01:06
04/08/16 01:06
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181

[207: Fri 08.04.16 00:05] 0.76092
(EUR/USD::L) Long 0@1.1455 Entry stop
(GBP/USD::S) Short 100@1.4005 Entry stop
(NZD/CHF::S) Short 42@0.6461 Entry stop
(NZD/JPY::S) Short 96@72.89 Entry stop
(USD/CHF::S) Short 0@0.9521 Entry stop
(USD/JPY::S) Short 0@107.67 Entry stop

Re: One Night Stand System [Re: RTG] #459038
04/15/16 02:25
04/15/16 02:25
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
(AUD/USD::L) Long 0@0.7738 Entry stop
(EUR/USD::L) Long 0@1.1466 Entry stop
(NZD/CHF::S) Short 42@0.6461 Entry stop
(NZD/JPY::S) Short 96@72.89 Entry stop
(USD/JPY::S) Short 0@107.63 Entry stop
(USOil::L) Long 1@42.45 Entry stop

No trades taken this week.

Last edited by RTG; 04/16/16 04:10.
Re: One Night Stand System [Re: RTG] #459058
04/18/16 17:52
04/18/16 17:52
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
(EUR/USD::L) Long 3@1.1466 Entry stop
(USOil::L) Long 2@42.45 Entry stop

Also no trades were entered.

AUD/USD:L and USD/JPY:S would have set up also trades if their OptimalFs were not 0 just like yours. Because I use a "if (OptimalF != 0)" condition before enter command trades with 0 lots are not longer set up.

Re: One Night Stand System [Re: Sphin] #459109
04/22/16 14:37
04/22/16 14:37
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Setups for this week.

[217: Fri 22.04.16 00:05] 44.030
(AUD/USD::L) Long 0@0.7836 Entry stop
(CHF/JPY::S) Short 0@111.50 Entry stop
(EUR/JPY::S) Short 44@121.71 Entry stop
(EUR/USD::L) Long 0@1.1466 Entry stop
(NZD/CHF::L) Long 0@0.6804 Entry stop
(USOil::L) Long 2@44.51 Entry stop

Re: One Night Stand System [Re: RTG] #459219
04/28/16 00:53
04/28/16 00:53
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
I added the monthly seasonal algorithm which trades the S&P500 index to this portfolio. This one buys towards the end of t month and sells about one week later. The first trade of which was taken on Tuesday.

[219: Tue 26.04.16 00:05] 43.395
[SPX500::L5918] Long 15@2089 Risk 593$

Re: One Night Stand System [Re: RTG] #459223
04/29/16 03:31
04/29/16 03:31
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Setups and skipped trades so far for Friday

AUD/JPY Long 102@86.40 Entry stop
CHF/JPY Short 0@111.50 Entry stop
EUR/JPY Short 44@121.71 Entry Stop
(GBP/USD::L) Long 0@1.4641 Entry stop
(NZD/CHF::L) Long 0@0.6804 Entry stop
(USD/JPY::S) Short 0@107.78 Entry stop
(USOil::L) Long 2@46.17 Entry stop
(USD/JPY::S) Entry stop 107.78 hit at 00:55
(USD/JPY::S) Skipped: Lots/Margin = 0
(CHF/JPY::S) Entry stop 111.50 hit at 01:30
(CHF/JPY::S) Skipped: Lots/Margin = 0
(GBP/USD::L) Entry stop 1.4641 hit at 01:43
(GBP/USD::L) Skipped: Lots/Margin = 0

Re: One Night Stand System [Re: RTG] #459257
05/02/16 05:06
05/02/16 05:06
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Stopped out on the S&P500 and losses on two other positions.


[SPX500::L5918] Stop 15@2059: -605$ at 15:02
(EUR/JPY::S) Entry stop 121.71 hit at 19:53
[EUR/JPY::S4912] Short 44@121.70
Weekend at 29.04. 20:00...................................
Weekend ends at 01.05. 23:00

[Mon 02.05.16 00:05] 19954 -605 -280 \\''

Monday 02.05.16 Loss -707$ ----
[EUR/JPY::S4912] Cover 44@121.92: -127$ at 00:04
[USOil::L2134] Sell 2@45.68: -150$ at 00:04

Re: One Night Stand System [Re: RTG] #459313
05/06/16 21:51
05/06/16 21:51
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
[Fri 06.05.16 00:05] 19955 -881 +0
(AUD/JPY::S) Short 42@79.49 Entry stop
(CHF/JPY::S) Short 0@110.64 Entry stop
(EUR/JPY::S) Short 42@121.59 Entry stop
(EUR/USD::L) Long 0@1.1618 Entry stop
(NZD/JPY::S) Short 92@73.34 Entry stop
(USD/CHF::S) Short 0@0.9444 Entry stop
(USD/JPY::S) Short 0@105.54 Entry stop
(USOil::L) Long 2@46.81 Entry stop
(CHF/JPY::S) Entry stop 110.64 hit at 01:40
(CHF/JPY::S) Skipped: Lots/Margin = 0
(AUD/JPY::S) Entry stop 79.49 hit at 01:41
BrokerBuy AUD/JPY: 269 ms
[AUD/JPY::S2568] Short 42@79.48 at 01:41
(NZD/JPY::S) Entry stop 73.34 hit at 06:32
BrokerBuy NZD/JPY: 591 ms
[NZD/JPY::S3750] Short 92@73.34 at 06:32
(EUR/JPY::S) Entry stop 121.59 hit at 12:44
BrokerBuy EUR/JPY: 255 ms
[EUR/JPY::S5600] Short 42@121.59 at 12:44
Weekend at 06.05. 20:00

The JPY positions were in profit by a lot on but gave back a lot by close of trade Friday. This is making me think of adding a trade profit limit or trailing stop.

Re: One Night Stand System [Re: RTG] #459314
05/07/16 01:09
05/07/16 01:09
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
This might be an interessting variation but the idea of this strategy was originally to trade gaps over the weekend so if trades were stopped before I think it could hardly fulfill its purpose.

Re: One Night Stand System [Re: Sphin] #459820
06/07/16 19:14
06/07/16 19:14
Joined: May 2016
Posts: 180
Prague
pcz Offline
Member
pcz  Offline
Member

Joined: May 2016
Posts: 180
Prague
Simple question: did you try backtesting with TICKS as suggested by jcl? If so, how did it compare to previous results?

Re: One Night Stand System [Re: pcz] #459825
06/07/16 22:05
06/07/16 22:05
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
I used TICKS default so I don't have other results. Maybe RTG?

Re: One Night Stand System [Re: Sphin] #459826
06/08/16 00:50
06/08/16 00:50
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Yes I use TICKS too.

Re: One Night Stand System [Re: RTG] #459831
06/08/16 09:28
06/08/16 09:28
Joined: May 2016
Posts: 180
Prague
pcz Offline
Member
pcz  Offline
Member

Joined: May 2016
Posts: 180
Prague
Thank you. I asked because my results with ticks were very different but that was probably due to my implementation.

Have you also tried implementing First Strike system? It's something that has been promoted by the same guy - Joel Rensink AKA TheRealThing. It's supposed to be complementary to ONS as it trades from monday to friday. In this link, there's also .pdf with the rules for download: http://systemtradersuccess.com/first-strike-trading-system/

Re: One Night Stand System [Re: pcz] #459878
06/09/16 19:05
06/09/16 19:05
Joined: May 2016
Posts: 180
Prague
pcz Offline
Member
pcz  Offline
Member

Joined: May 2016
Posts: 180
Prague
Also - I don't know what your running implementation of ONS is. I'm working with something similar to what Sphin posted. I would love to see what you are using if it is different.

BUT - what I wanted to say is that I get significantly better results if I lag the HH and LL functions by 1. I tested it on 14 pairs (from 2011 to 2015). On average I get 7% higher AR when testing with no money management set. I did the whole test on M1 data and tried it with TICKS only for two pairs. Those tests confirmed the previous results. I hope I haven't overlooked anything important.

Re: One Night Stand System [Re: pcz] #459880
06/09/16 20:53
06/09/16 20:53
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
I did not change the trading algo so far, I play around with money management/OptF and different assets.
What did you do with HH and LL? Sorry, I didn't understand.

Re: One Night Stand System [Re: Sphin] #459882
06/09/16 22:00
06/09/16 22:00
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
1stStrike's idea sounds really complementary to ONS and also very simple. I hope I understood it right so here is a quick & dirty proposal. I tried with the assets I have history data from 2002 to 2015. Assuming both orders should be cancled if one of them is not fulfilled on Mondays, otherwise Entrytime must be set accordingly.
Code:
int WatchTrades() {
	
	if((TradeIsShort && NumOpenLong != 0) || // OCO kill pending short
	   (TradeIsLong && NumOpenShort != 0) || // OCO kill pending long
	   (between(tow(),52000,52005)))	 // Friday 4:00 pm EST
	   return 1;
	else	
	   return 0;
}

void Trade1stStrike() {
	
	if(dow() == 1) {

		Entry = 50*PIP;
		Stop = 60* PIP;
		// EntryTime = 5;
	
		enterShort(WatchTrades);
		enterLong(WatchTrades);
	}
}


function run() {

 set(LOGFILE+TICKS);
 BarPeriod = 1440;
 BarOffset = 300; // EST 01:00 + 4:00 = UTC 5:00
 StartDate = 2002;
 EndDate = 2015;
 
 while(asset(loop("AUD/JPY","AUD/USD","EUR/AUD","EUR/CHF","EUR/GBP","EUR/JPY","EUR/USD","GBP/AUD","GBP/USD","NZD/USD","USD/CHF","USD/JPY")))
   Trade1stStrike();

}



Ironically GBP/USD is the worst performer.:)

Code:
Portfolio analysis  OptF  ProF  Win/Loss  Wgt%

AUD/JPY avg         .052  1.17  136/323   19.3  
AUD/USD avg         .062  1.28  129/290   34.5  
EUR/AUD avg         .034  0.98   85/400   -2.8  
EUR/CHF avg         .203  1.08   70/165    5.5  
EUR/GBP avg         .040  1.15   62/118   11.4  
EUR/JPY avg         .086  1.22  148/420   32.5  
EUR/USD avg         .032  1.10  134/369   16.2  
GBP/AUD avg         .000  0.97  115/549   -6.4  
GBP/USD avg         .000  0.82  116/462  -36.8  
NZD/USD avg         .012  1.04  103/278    4.5  
USD/CHF avg         .112  1.07  122/332   10.4  
USD/JPY avg         .053  1.12  119/283   11.6


Maybe there will be some approaches to improve it.

Re: One Night Stand System [Re: Sphin] #459891
06/10/16 09:11
06/10/16 09:11
Joined: May 2016
Posts: 180
Prague
pcz Offline
Member
pcz  Offline
Member

Joined: May 2016
Posts: 180
Prague
Originally Posted By: Sphin
I did not change the trading algo so far, I play around with money management/OptF and different assets.
What did you do with HH and LL? Sorry, I didn't understand.


What I meant is this: HH(10, 1) - 10 is time period and 1 is offset. You can try if it gives you better results too.

Regarding the First Strike - doesn't look as good as ONS. There's also modified version that uses previous week's range to determine entry and stop levels. Probably makes more sense than fixed values. Here's the pdf: http://www.forexfactory.com/attachment.php?attachmentid=693540&d=1304670051.

Re: One Night Stand System [Re: pcz] #459955
06/13/16 02:45
06/13/16 02:45
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Have you run both scripts together (ONS and FirstStrike) in a backtest?

Re: One Night Stand System [Re: RTG] #460140
06/17/16 10:15
06/17/16 10:15
Joined: May 2016
Posts: 180
Prague
pcz Offline
Member
pcz  Offline
Member

Joined: May 2016
Posts: 180
Prague
Originally Posted By: RTG
Have you run both scripts together (ONS and FirstStrike) in a backtest?


Tried it only for EUR/USD. With my params ONS gives AR 34% and FS 18% when tested separately. When tested together AR is the same as for ONS but PF and Sharpe are lower. The resulting equity curve looks more similar to FS equity curve probably also because FS has more than twice as many trades.

Re: One Night Stand System [Re: pcz] #460298
06/24/16 03:49
06/24/16 03:49
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Wow crazy day so far with Brexit. It turns out take profit targets hurt this system today/


[SPX500::L0778] Stop 13@2073: -547$ at 01:06
(USD/JPY::S) Entry stop 103.55 hit at 01:09
(USD/JPY::S) Skipped: Lots/Margin = 0
(CHF/JPY::S) Entry stop 107.14 hit at 02:26
[CHF/JPY::S3059] Short 25@107.10 p
(EUR/JPY::S) Entry stop 115.50 hit at 02:26
[EUR/JPY::S3062] Short 28@115.49 p
[EUR/JPY::S3062] Target 28@113.96: +544$ at 02:41
[CHF/JPY::S3059] Target 25@105.58: +478$ at 02:42
(AUD/JPY::S) Entry stop 75.59 hit at 02:43
[AUD/JPY::S3672] Short 61@75.56 p
[AUD/JPY::S3672] Target 61@74.04: +1150$ at 02:43

Re: One Night Stand System [Re: RTG] #460299
06/24/16 04:04
06/24/16 04:04
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Will be interesting to see how the alternate versions without take profit perform on this event. Are you still running a live demo Sphin?

Re: One Night Stand System [Re: RTG] #460317
06/24/16 21:39
06/24/16 21:39
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Yes, I do. But I cannot point a myfxbook account to them because there are not only ONS's running on one FXCM demo account. My results so far are not as huge as yours because I run 2 ONS with silghtly different assets and trainings but with only low capital each, so lots are very restricted.

1st:
[CHF/JPY::S3134] Short 1@107.10 Risk 14$ at 02:25
[EUR/JPY::S3147] Short 1@115.46 Risk 22$ at 02:25
[USD/JPY::S3629] Short 1@103.13 Risk 14$ at 02:41
[CAD/JPY::S3666] Short 2@79.29 Risk 43$ at 02:41
Result so far: + 41 ////

2nd:
[CHF/JPY::S3133] Short 1@107.10 Risk 14$ at 02:25
[EUR/JPY::S3145] Short 2@115.50 Risk 33$ at 02:25
Result so far: + 44 //

Final Results:

1st:
[CAD/JPY::S3666] Cover 2@78.48: +13.80 at 23:59
[CHF/JPY::S3134] Cover 1@105.06: +17.65 at 23:59
[EUR/JPY::S3147] Cover 1@112.84: +23.07 at 23:59
[USD/JPY::S3629] Cover 1@102.21: +7.94 at 23:59
Total: +62

2nd:
[CHF/JPY::S3133] Cover 1@105.06: +17.20 at 23:59
[EUR/JPY::S3145] Cover 2@112.84: +47.15 at 23:59
Total: +64

ONS has stated its 'financial crisis robustness'. laugh

Last edited by Sphin; 06/27/16 14:55. Reason: Final results
Re: One Night Stand System [Re: Sphin] #460463
07/02/16 04:37
07/02/16 04:37
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
This week's setups. No entries

(AUD/JPY::S) Short 68@72.54 Entry stop
(CHF/JPY::S) Short 27@101.97 Entry stop
(EUR/JPY::S) Short 30@109.58 Entry stop
(EUR/USD::S) Short 95@1.0913 Entry stop
(GBP/USD::S) Short 92@1.3122 Entry stop
(NZD/CHF::L) Long 0@0.7024 Entry stop
(NZD/JPY::S) Short 82@69.84 Entry stop
(USD/JPY::S) Short 0@99.04 Entry stop
Weekend at 01.07. 20:00.........

Re: One Night Stand System [Re: RTG] #460667
07/09/16 00:27
07/09/16 00:27
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
This week's setups. I noted the NZD/CHF trade was skipped. I decided to take a manual position 10 @ 0.7091

[Fri 08.07.16 00:05] 21378 +1764 +0
(AUD/JPY::S) Short 68@72.54 Entry stop
(CHF/JPY::S) Short 27@101.97 Entry stop
(EUR/JPY::S) Short 32@109.58 Entry stop
(EUR/USD::S) Short 101@1.0913 Entry stop
(GBP/USD::S) Short 106@1.2799 Entry stop
(NZD/CHF::L) Long 0@0.7087 Entry stop
(NZD/JPY::S) Short 82@69.84 Entry stop
(USD/JPY::S) Short 0@99.04 Entry stop
(NZD/CHF::L) Entry stop 0.7087 hit at 00:12
(NZD/CHF::L) Skipped: Lots/Margin = 0
Weekend at 08.07. 20:00..

Re: One Night Stand System [Re: pcz] #460831
07/16/16 12:28
07/16/16 12:28
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Have you tried adding the SMA trend condition to the entry?

It improves the system a lot.

Re: One Night Stand System [Re: RTG] #460832
07/16/16 12:50
07/16/16 12:50
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Quote:
Have you tried adding the SMA trend condition to the entry?

I think I missed something, what trend condition do you mean?

Re: One Night Stand System [Re: Sphin] #460834
07/16/16 15:27
07/16/16 15:27
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
The one from this link

http://systemtradersuccess.com/first-strike-trading-system/

Basically if price is above or below the 200 day moving average.

Re: One Night Stand System [Re: RTG] #460837
07/16/16 17:33
07/16/16 17:33
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Okay, let's determine the conditions:

- Buy on Mondays EST 01:00 if price > SMA220
- Sell on Mondays EST 01:00 if price < SMA220

with Entry = 50 and Stop = 60 in PIP. Close trades on Friday 4:00 pm EST. This way?
If these conditions are right where (concerning which assets) did you find improvements?
If trades are not entered on Mondays what should happen to the pending ones? Should they be cancled (EntrTime = 1, default) or should they reside pending until ... Friday?

Re: One Night Stand System [Re: Sphin] #460847
07/17/16 00:44
07/17/16 00:44
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
vars Price = series(price());
vars SMA220 = series(SMA(Price, 220));
if(dow() == 1) {
Entry = 50*PIP;
// EntryTime = 5;

if(Price < SMA220)
enterShort(WatchTrades);
if(Price > SMA220)
enterLong(WatchTrades);

Re: One Night Stand System [Re: RTG] #460848
07/17/16 00:48
07/17/16 00:48
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Correction - that should be using "crossOver" and "crossUnder" functions.

Re: One Night Stand System [Re: RTG] #460853
07/17/16 10:30
07/17/16 10:30
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Did you try this already? Using cross* means that the price must really cross the SMA within the bar or in other words, the price must be higher/lower than the SMA before the bar and lower/higher afterwards.
Trading this limitation e.g. with all 28 available currencies from 2009 to 2015 reduces the number of trades from ~3.000 to ~100 (or between 0 and 10 per asset). I can hardly believe that this could be a representative approach.

Re: One Night Stand System [Re: Sphin] #460854
07/17/16 11:14
07/17/16 11:14
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Yeah I don't know what I was thinking there. It should just be that price[0] is greater/lower than the SMA.

Ok so without the crossover and just the SMA220 I get the following. I thought it was a good test until I realised that it didn't take an long trades using this code.

BackTest First Strike portfolio

Simulated account AssetsFix.dta
Bar period 24 hours (avg 2180 min)
Test period 03.01.2006-16.07.2016 (2526 bars)
Lookback period 220 bars (45 weeks)
Monte Carlo cycles 200
Assumed slippage 10.0 sec
Capital invested 1000$

Gross win/loss 19984$ / -16179$ (+21500p)
Average profit 361$/year, 30$/month, 1.39$/day
Max drawdown -703$ 18% (MAE -768$ 20%)
Total down time 92% (TAE 75%)
Max down time 138 weeks from Jan 2006
Max open margin 471$
Max open risk 161$
Trade volume 4435744$ (421148$/year)
Transaction costs -213$ spr, -19$ slp, -272$ rol, -100$ com
Capital required 846$

Number of trades 2277 (217/year, 5/week, 1/day)
Percent winning 26%
Max win/loss 390$ / -40$
Avg trade profit 1.67$ 9.4p (+188.5p / -54.5p)
Avg trade slippage -0.01$ -0.0p (+0.7p / -0.3p)
Avg trade bars 1 (+3 / -1)
Max trade bars 16 (23 days)
Time in market 156%
Max open trades 10
Max loss streak 25 (uncorrelated 27)

Annual growth rate 16%
Profit factor 1.24 (PRR 1.16)
Sharpe ratio 0.66
Kelly criterion 1.20
R2 coefficient 0.388
Ulcer index 8.3%
Prediction error 32%

Confidence level AR DDMax Capital

10% 48% 536$ 757$
20% 46% 585$ 783$
30% 45% 638$ 812$
40% 43% 683$ 835$
50% 42% 747$ 869$
60% 40% 823$ 910$
70% 39% 865$ 933$
80% 37% 932$ 968$
90% 34% 1086$ 1051$
95% 31% 1281$ 1155$
100% 21% 2288$ 1692$

Portfolio analysis OptF ProF Win/Loss Wgt%

AUD/JPY avg .1000 1.27 55/147 13.8
AUD/USD avg .1000 1.34 59/123 13.7
EUR/AUD avg .1000 1.23 57/181 9.5
EUR/CHF avg .1000 1.24 35/70 3.6
EUR/GBP avg .1000 1.21 30/46 3.6
EUR/JPY avg .1000 1.74 59/189 31.5
EUR/USD avg .1000 1.22 49/152 10.1
GBP/AUD avg .1000 0.97 53/232 -1.3
GBP/USD avg .1000 1.04 50/202 1.7
NZD/USD avg .1000 1.16 46/106 6.5
USD/CHF avg .1000 0.94 51/113 -1.0
USD/JPY avg .1000 1.30 55/117 8.3

AUD/JPY .1000 1.27 55/147 13.8
AUD/JPY:L .1000 ---- 0/0 0.0
AUD/JPY:S .1000 1.27 55/147 13.8
AUD/USD .1000 1.34 59/123 13.7
AUD/USD:L .1000 ---- 0/0 0.0
AUD/USD:S .1000 1.34 59/123 13.7
EUR/AUD .1000 1.23 57/181 9.5
EUR/AUD:L .1000 ---- 0/0 0.0
EUR/AUD:S .1000 1.23 57/181 9.5
EUR/CHF .1000 1.24 35/70 3.6
EUR/CHF:L .1000 ---- 0/0 0.0
EUR/CHF:S .1000 1.24 35/70 3.6
EUR/GBP .1000 1.21 30/46 3.6
EUR/GBP:L .1000 ---- 0/0 0.0
EUR/GBP:S .1000 1.21 30/46 3.6
EUR/JPY .1000 1.74 59/189 31.5
EUR/JPY:L .1000 ---- 0/0 0.0
EUR/JPY:S .1000 1.74 59/189 31.5
EUR/USD .1000 1.22 49/152 10.1
EUR/USD:L .1000 ---- 0/0 0.0
EUR/USD:S .1000 1.22 49/152 10.1
GBP/AUD .1000 0.97 53/232 -1.3
GBP/AUD:L .1000 ---- 0/0 0.0
GBP/AUD:S .1000 0.97 53/232 -1.3
GBP/USD .1000 1.04 50/202 1.7
GBP/USD:L .1000 ---- 0/0 0.0
GBP/USD:S .1000 1.04 50/202 1.7
NZD/USD .1000 1.16 46/106 6.5
NZD/USD:L .1000 ---- 0/0 0.0
NZD/USD:S .1000 1.16 46/106 6.5
USD/CHF .1000 0.94 51/113 -1.0
USD/CHF:L .1000 ---- 0/0 0.0
USD/CHF:S .1000 0.94 51/113 -1.0
USD/JPY .1000 1.30 55/117 8.3
USD/JPY:L .1000 ---- 0/0 0.0
USD/JPY:S .1000 1.30 55/117 8.3

Re: One Night Stand System [Re: RTG] #460873
07/18/16 17:01
07/18/16 17:01
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
What did you code? If you do it exactly as you described:
Code:
if(dow() == 1) {

		Entry = 50*PIP;
		Stop = 60* PIP;
		//	EntryTime = 5;
				
		if (Price[0] < SMA220[0])
			enterShort(WatchTrades);
		
		if (Price[0] > SMA220[0])
			enterLong(WatchTrades);
	}


you surely get also long trades. The OCO conditions in WatchTrades are unnecessary in this variant, but this only BTW.

There are in deed some assets with profit but personally I don't like strategies that have such a low relation of win/loss trades and produce profit in the past only because their win trades produced more win than their loss trades lost. I think this can easily turn in future.

Re: One Night Stand System [Re: Sphin] #460955
07/21/16 14:20
07/21/16 14:20
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
What about trying some of the built in Ehlers filters for finding a better moving average?

Re: One Night Stand System [Re: RTG] #460985
07/22/16 03:50
07/22/16 03:50
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
ONS setups for this week.

(EUR/USD::S) Short 103@1.0979 Entry stop
(GBP/USD::S) Short 108@1.2851 Entry stop
(NZD/JPY::L) Long 139@76.86 Entry stop
(USOil::S) Short 1@44.44 Entry stop

Re: One Night Stand System [Re: RTG] #461028
07/22/16 23:20
07/22/16 23:20
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
If I knew how to handle Ehlers filter I would write profitable strategies. laugh But wasn't Ehlers the guy with the cycles? You can use him also to find out the best MA?

I don't know if another MA is needed - the result is improved if you use an individual period length per asset. Here I choose optimize(200,10,300,10) for a SMA (and used EntryTime=5) from 2009 to 2015:

Code:
Asset	SMA	PF	W/L
EUR/CHF	220	2,13	47/74
EUR/AUD	90	1,51	84/141
EUR/JPY	110	1,48	86/151
AUD/JPY	80	1,46	87/120
USD/JPY	280	1,46	86/106
EUR/USD	30	1,45	80/137
AUD/CHF	30	1,34	82/121
USD/CHF	50	1,3	84/114
CHF/JPY	80	1,29	81/135
XAGUSD	30	1,29	55/80
GBP/JPY	120	1,21	79/164
EUR/NZD	240	1,18	60/188
XAUUSD	281	1,17	6/240
NZD/JPY	30	1,14	79/118
USD/CAD	230	1,12	73/115
GER30	160	1,11	47/180
NAS100	240	1,11	52/58
AUD/USD	280	1,09	77/127
EUR/CAD	40	1,09	72/158
CAD/CHF	190	1,07	75/121
CAD/JPY	100	1,06	71/131
US30	270	1,06	56/181
GBP/CHF	250	1,05	73/156
NZD/CHF	280	1,05	71/105
AUD/CAD	280	1,03	77/112
SPX500	260	1,01	51/211
AUD/NZD	80	0,97	81/128
GBP/NZD	130	0,97	46/214
EUR/GBP	40	0,94	65/84
GBP/AUD	50	0,93	64/188
GBP/USD	100	0,88	68/169
NZD/USD	170	0,88	80/138
USOil 	110	0,8	35/191
NZD/CAD	100	0,79	77/120
GBP/CAD	29	0,76	48/185
UK100	230	0,47	38/135


The EUR/CHF result might be slightly biased by the cap and the relation of W/L @XAUUSD looks strange: only 6 wins out of 246 trades and it was profitable at all! The reason for this was that the Stop in PIPs seems not to work with XAUUSD, if the trade wasn't profitable from the very beginning it has been stopped out immediately.

Re: One Night Stand System [Re: Sphin] #461037
07/23/16 05:19
07/23/16 05:19
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Two fills on my demo account for the ONS.

(USOil::S) Entry stop 44.44 hit at 07:05
[USOil::S6977] Short 1@44.44
(EUR/USD::S) Entry stop 1.0979 hit at 14:59
[EUR/USD::S9128] Short 103@1.0978 p
Weekend at 22.07. 20:00..........

Re: One Night Stand System [Re: RTG] #461088
07/25/16 01:27
07/25/16 01:27
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
[Mon 25.07.16 00:05] 21548 +1764 +57 //''

Monday 25.07.16 Profit +1683$ ----
[EUR/USD::S9128] Cover 103@1.0972: +44.09 at 00:04
[USOil::S6977] Cover 1@44.30: +13.38 at 00:04

Re: One Night Stand System [Re: RTG] #463469
12/05/16 22:46
12/05/16 22:46
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline
User
Sphin  Offline
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Really long time ago when the last entries were made here, I still watch ONS running with more or less ... loss in total. This weekend was a disaster, first time a stop was hit, in EUR/JPY - okay trading EUR long seemed to be a bad idea in general referring to the Italian referendum. But I faced another problem:

Code:
[151: Fri 02.12.16 00:00]  0.84636
(EUR/USD::S) Short 200@1.0516 Entry stop
Weekend at 02.12. 20:00....................
Weekend ends at 04.12. 23:00
(EUR/USD::S) Entry stop 1.0516 hit at 23:22.
[EUR/USD::S8842] Short 200@1.0516 Risk 40$  at 23:21..



Because my EntryTime is default (1) I was astonished that the trade was still valid on Sunday night when the market continued, such trades are not intended. But I fear with default setting for Weekend (means 2) all prices that arrive until Monday 00:00 are counted to the Friday bar? If so setting Weekend to 1 expires trades on Friday (on a bar period of 1440)?

Re: One Night Stand System [Re: Sphin] #463479
12/06/16 15:51
12/06/16 15:51
Joined: Feb 2014
Posts: 181
R
RTG Offline OP
Member
RTG  Offline OP
Member
R

Joined: Feb 2014
Posts: 181
Mine took that hit too. I need to recover my hard drive to get the myfxbook account updated.

Re: One Night Stand System [Re: RTG] #482213
01/12/21 18:35
01/12/21 18:35
Joined: Sep 2020
Posts: 5
Derby, UK
aliswee Offline
Newbie
aliswee  Offline
Newbie

Joined: Sep 2020
Posts: 5
Derby, UK
Has anyone else tried to use this system. I have used the code and date ranges used here up to about 2016 but have found the results to be terrible?!

Re: One Night Stand System [Re: aliswee] #484883
12/25/21 13:19
12/25/21 13:19
Joined: Dec 2021
Posts: 13
S
Sage Offline
Newbie
Sage  Offline
Newbie
S

Joined: Dec 2021
Posts: 13
To my amazement also! I backtested it with the code on here; 2010 - 2015 and ONS does not seem profitable. Even JCL has it on his blog "Financial Hacker" that ONS is profitable.
I would be pleased to know if the mistake is from me

Re: One Night Stand System [Re: Sage] #484930
12/31/21 13:55
12/31/21 13:55
Joined: Dec 2021
Posts: 3
S
seerwright Offline
Guest
seerwright  Offline
Guest
S

Joined: Dec 2021
Posts: 3
I'm just now stumbling across this and plan to test it out. Reading through the thread there are a number of refinements that happened. I'm guessing previous posters spent many hours refining and probably didn't publish final scripts.

Re: One Night Stand System [Re: RTG] #484937
01/01/22 17:14
01/01/22 17:14
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
I found a working version in our antique scripts depot:

Code
function tradeOneNightStand() 
{
	vars SMA10 = series(SMA(seriesC(),10));
	vars SMA40 = series(SMA(seriesC(),40));
	
	Stop = 150 * PIP;
	Trail = 150 * PIP;
	TrailLock = 50;
	EntryTime = 24;
	
	int Days = LookBack; 
	var BuyStop = HH(Days) + 1*PIP;
	var SellStop = LL(Days) - 1*PIP;
	
	if (dow() == FRIDAY && NumOpenLong == 0 && NumPendingLong == 0 && SMA10[0] > SMA40[0]) 
		enterLong(0,BuyStop);
	else if (dow() == FRIDAY && NumOpenShort == 0 && NumPendingShort == 0 && SMA10[0] < SMA40[0])
		enterShort(0,SellStop);			
	
	if (dow() < FRIDAY) {
		exitLong();
		exitShort();
	}
}


function run() 
{
	
	BarPeriod = 60; 
	LookBack = 13*24;
	StartDate = 2010;
	EndDate = 2015;
	while(asset(loop("USD/JPY", "GBP/USD", "EUR/USD"))) 
		tradeOneNightStand();
	}
}


Looks still experimental. Dont ask me how the parameters like 150*PIP or 13*24 came about.

Page 1 of 20 1 2 3 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