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.
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;
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/1501:51.
Re: One Night Stand System
[Re: RTG]
#452812 06/26/1506:2606/26/1506:26
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.
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/1500:0506/29/1500:05
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/1523:4907/24/1523:49
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/1514:1308/24/1514:13
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/1507:5408/25/1507:54
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/1501:3209/25/1501:32
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.
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/1515:2510/06/1515:25
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/1523:3610/10/1523:36
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));
} } //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" 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/1523:4510/11/1523:45
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 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.
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/1500:2011/01/1500:20
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.
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/1512:0911/01/1512:09
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/1510:5811/02/1510:58
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/1518:2711/02/1518:27
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?
Do you trade it with a capital of 50.000?
Re: One Night Stand System
[Re: Sphin]
#455946 11/03/1523:2411/03/1523:24
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/1513:1111/06/1513:11
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/1516:4611/06/1516:46
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/1519:2911/06/1519:29
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/1501:1311/07/1501:13
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/1511:1611/07/1511:16
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:
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%
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/1519:1811/13/1519:18
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.
Re: One Night Stand System
[Re: RTG]
#456212 11/15/1510:0411/15/1510:04
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.
Re: One Night Stand System
[Re: Sphin]
#456231 11/15/1520:0511/15/1520:05
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! And sorry for the long post but most of it are extracts from log files.
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:
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/1522:4311/20/1522:43
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?
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/1500:5011/21/1500:50
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!
HTH.
Re: One Night Stand System
[Re: DdlV]
#456400 11/21/1511:3711/21/1511:37
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/1513:14.
Re: One Night Stand System
[Re: Sphin]
#456446 11/23/1511:1311/23/1511:13
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/1500:5911/24/1500:59
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:
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/1509:5911/24/1509:59
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/1518:5711/24/1518:57
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/1514:3111/27/1514:31
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:
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 ...
Re: One Night Stand System
[Re: Sphin]
#456587 11/30/1500:5811/30/1500:58
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/1500:1612/02/1500:16
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%
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/1501:0612/04/1501:06
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/1500:57.
Re: One Night Stand System
[Re: RTG]
#456785 12/09/1518:4312/09/1518:43
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:
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/1510:4912/15/1510:49
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/1507:3912/21/1507:39
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/1507:4612/21/1507:46
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/1511:1912/21/1511:19
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/1523:1912/21/1523:19
[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/1602:5601/16/1602:56
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/1611:5301/17/1611:53
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
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/1601:4001/18/1601:40
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/1600:3201/23/1600:32
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. 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/1603:3501/30/1603:35
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:
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/1602:3102/14/1602:31
(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/1600:5202/22/1600:52
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/1622:1702/22/1622:17
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
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/1602:1302/29/1602:13
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/1602:12.
Re: One Night Stand System
[Re: RTG]
#458336 03/05/1609:1003/05/1609:10
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!
Re: One Night Stand System
[Re: RTG]
#458343 03/05/1617:4803/05/1617:48
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/1615:00.
Re: One Night Stand System
[Re: RTG]
#458466 03/11/1616:2103/11/1616:21
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/1600:1203/12/1600:12
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/1614:2703/18/1614:27
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/1600:5504/04/1600:55
(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/1604:10.
Re: One Night Stand System
[Re: RTG]
#459058 04/18/1617:5204/18/1617:52
(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/1614:3704/22/1614:37
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/1603:3104/29/1603:31
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/1621:5105/06/1621:51
[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/1601:0905/07/1601:09
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/1619:1406/07/1619:14
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/1619:0506/09/1619:05
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/1620:5306/09/1620:53
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/1622:0006/09/1622:00
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.
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.
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/1603:4906/24/1603:49
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/1604:0406/24/1604:04
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'.
Last edited by Sphin; 06/27/1614:55. Reason: Final results
Re: One Night Stand System
[Re: Sphin]
#460463 07/02/1604:3707/02/1604:37
(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/1600:2707/09/1600:27
- 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/1600:4407/17/1600:44
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/1611:1407/17/1611:14
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%
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/1614:2007/21/1614:20
(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/1623:2007/22/1623:20
If I knew how to handle Ehlers filter I would write profitable strategies. 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:
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/1605:1907/23/1605:19
(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/1601:2707/25/1601:27
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/1615:5112/06/1615:51
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/2113:5512/31/2113:55
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/2217:1401/01/2217:14