Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,498 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
My first script - JK's One Night Stand #427812
08/14/13 05:45
08/14/13 05:45
Joined: Aug 2013
Posts: 124
D
DMB Offline OP
Member
DMB  Offline OP
Member
D

Joined: Aug 2013
Posts: 124
Hi all

This is my first attempt at programming with Lite C and Zorro. I would appreciate some help with the code.

I am coding Joe Krutsinger's One Night Stand system. This system is pretty easy to find with a google search. The idea is to enter on Friday and hold over the weekend, seeking the weekend risk premium. The rules are:

- 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.

Below is my current attempt:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function run()
{

BarPeriod = 1440;

if ((dow( ) == FRIDAY) and (SMA(priceClose,10) > SMA(priceClose,40)))
{
Entry = HH(10) + 1*PIP;
enterLong();
}
else if ((dow( ) == FRIDAY) and (SMA(priceClose,10) < SMA(priceClose,40)))
{
Entry = LL(10) - 1*PIP;
enterShort();
}

if(dow() == MONDAY && lhour(ET) >= 8 /* && minute() >= 30 */ ) {
exitLong();
exitShort();
}

PlotWidth = 800;
PlotHeight1 = 320;

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I have not taken into account holidays. I am yet to decide what to do about this. Attached is an example equity curve from an internet source. It trades around ten times a year.



Here are the problems I am having:

1. For some reason I am only getting short entries in the test. The code for the long entry appears to be the same as the short entry, except for the '>' and the enterLong() command. So this seems very odd. Below are extracts from the result report. Notice the discrepancy between the total number of trades and the number of long and short trades.

Test period 05.04.2008-11.06.2013
Number of trades 47 (10/year, 1/week, 1/day)

Portfolio analysis OptF ProF Win/Loss
GBP/USD:L .000 ---- 0/0
GBP/USD:S .070 1.20 22/25

2. I am trying to exit the trade at about 8:30am NY time since these is a good approximation of the Monday open. I may adjust this later, but for now, the code above fails to execute the exit order. Thus there is something wrong with my if statement conditions. It exits when I omit 'minute() >= 30;', But I am not sure yet if that case exits at 8am NYT.

3. Thoughts on how to check that the code is conceptually correct when the output graph is too small to read. Do people set the test period to a small time so that the resolution is better in the output graph? I guess the rules are simple enough to manually check a hand full trades from the output file. Which reminds me....what is the code for outputting trades to a .csv file?

Thanks in advance.

Attached Files
ONS example.jpg (8 downloads)
Re: My first script - JK's One Night Stand [Re: DMB] #427819
08/14/13 08:01
08/14/13 08:01
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
1) You need a series for the SMA, so your entry conditions are wrong.

vars Close = series(priceClose());
if(SMA(Close....

2) You're using daily bars, but want to exit the trade within 30 minutes. You need 30 minutes bars for that. Use then also a certain time for Friday to make sure that only one trade is opened.

3) set LOGFILE for this.

Re: My first script - JK's One Night Stand [Re: jcl] #427832
08/14/13 12:18
08/14/13 12:18
Joined: May 2013
Posts: 245
S
swingtraderkk Offline
Member
swingtraderkk  Offline
Member
S

Joined: May 2013
Posts: 245
@jcl, have I handled the offsets and timeframes correctly so that the daily price series are for ET market close, the SMA's thursday nights, and the hh & ll the correct 10 ET daily highs and lows? Does this now automatically handle ET daylight savings?

@DMB what instruments is this supposed to work on?
I've assumed that the open & close are US regualr sessions, cna you confirm if this is the case. It does not look profitable to me.



Code:
function run()
{

BarPeriod = 30;

FrameOffset = timeOffset(ET,0,0,0); // calculate daily bars with ET close

TimeFrame = 48; // Calculate daily bars 

vars dailycl 		= series(priceClose());
vars sma10			= series(SMA(dailycl,10));
vars sma40			= series(SMA(dailycl,40));

var  longentry 	= HH(10) + (1*PIP);
var  shortentry	= LL(10) - (1*PIP);

TimeFrame = 1; // back to 30 min bars

TimeWait = 15; // Remove pending orders at end of market day

if (ldow(ET) == FRIDAY)

{
	if (sma10[0] > sma40[0])
	{
		if ((lhour(ET,0) == 9) and (minute(0) == 30))
		{
			enterLong(1,longentry);
		}
	}
	
	if (sma10[0] < sma40[0])
	{
		if ((lhour(ET,0) == 9) and (minute(0) == 30))
		{
			enterShort(1,shortentry);
		}
	}
	
}	



if (ldow(ET) == MONDAY) 
{ 
	if ((lhour(ET,0) == 9) and (minute(0) == 30))
	{
		exitLong();
		exitShort();
	}
}

PlotWidth = 4000;
PlotHeight1 = 700;

}


Last edited by swingtraderkk; 08/14/13 12:20.
Re: My first script - JK's One Night Stand [Re: swingtraderkk] #427885
08/15/13 08:40
08/15/13 08:40
Joined: Aug 2013
Posts: 124
D
DMB Offline OP
Member
DMB  Offline OP
Member
D

Joined: Aug 2013
Posts: 124
Thanks for your help swingtraderkk / jcl. I am in the process of reviewing / testing / learning. Just thought I would answer your questions. I believe the system is supposed to work on the major currency pairs and crosses. I also believe Krutsinger released it in the 80's. It is quite possible that it does not work anymore. I was tried to test it on my former software a couple years ago, but getting an accurate exit was very difficult.

Also when I was testing it, I discovered that Krutsinger was not using tick level resolution. Rather daily bars with assumed intraday movement. Thus there was some error there despite the simplicity of the system. I never really got to the bottom of it. I thought I would try again given the flexibility of programming with lite C.

Next I will start reviewing all of my old attempts at mech trading with Larry Williams concepts. The code you have provided above has helped me understand better how to make systems for Zorro.

Last edited by DMB; 08/15/13 08:40.
Re: My first script - JK's One Night Stand [Re: DMB] #427893
08/15/13 10:38
08/15/13 10:38
Joined: May 2013
Posts: 245
S
swingtraderkk Offline
Member
swingtraderkk  Offline
Member
S

Joined: May 2013
Posts: 245
I'm not a programmer just another zorro learner a little bit further down the road.

Wait for jcl to confirm I'm correct.

It may be worth trying again then as I assumed it was S&P, DOW strategy. You also would need to adjust the entries & exits as it is written for ET market hours.

I'd put a stop in too, NFP Fridays can be a wild ride for the dollar.

Re: My first script - JK's One Night Stand [Re: swingtraderkk] #427971
08/16/13 02:16
08/16/13 02:16
Joined: Aug 2013
Posts: 124
D
DMB Offline OP
Member
DMB  Offline OP
Member
D

Joined: Aug 2013
Posts: 124
Stop is a good idea. The info I have says a stop is helpful but not essential. Personally, I would prefer that extra protection and I was planning on testing a stop anyway.

The website below talks about the ONS system, after a lot of other dribble. It looks like Joel Rensink has another very simple system called 'First Strike' (find with google) that I might code just for practice. I have some other info on ONS directly from Krutsinger, though I have never done a course with him or really followed any of his work. I am just happy to finally test it accurately. Ditto with all the other stuff I have tried but without WFO. Very interesting development tool.

http://www.infiniteyield.com

Re: My first script - JK's One Night Stand [Re: DMB] #427987
08/16/13 10:05
08/16/13 10:05
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
I do not know if that system has any merit, but the script, as far as I see, is correct.

Re: My first script - JK's One Night Stand [Re: jcl] #428078
08/17/13 15:17
08/17/13 15:17
Joined: Aug 2013
Posts: 124
D
DMB Offline OP
Member
DMB  Offline OP
Member
D

Joined: Aug 2013
Posts: 124
Googling revealed a little more information about Rensink and this system. It appears that the entries went live at 12:00am CST Friday morning and the exit executed at 12:00am CST Monday morning. He traded this system and the other system, First Strike (a Monday to Friday breakout system) on an account starting at $500 to prove it can be done. Four currencies and one cross. He blogged it but for some reason the blogs stops after 5 years and $34k.

Anyway, I think I have enough code from above to complete the script for both systems. So I will do that and make the final code and test results public on this thread.

Re: My first script - JK's One Night Stand [Re: DMB] #428164
08/19/13 11:21
08/19/13 11:21
Joined: May 2013
Posts: 245
S
swingtraderkk Offline
Member
swingtraderkk  Offline
Member
S

Joined: May 2013
Posts: 245
DMB,

Is 12:00 am midday or midnight?

Re: My first script - JK's One Night Stand [Re: swingtraderkk] #428167
08/19/13 12:28
08/19/13 12:28
Joined: Aug 2013
Posts: 124
D
DMB Offline OP
Member
DMB  Offline OP
Member
D

Joined: Aug 2013
Posts: 124
Midnight. Let's say 12:01am Friday morning for entry and 12:01am Monday morning for exit..

In the last couple years he only did one blog a year. I guess it was becoming a little cumbersome. Also at the rate of return he was getting, he would have reached his $150k target, so probably didn't bother blogging that he had done so, but maybe sent an email to the subscribers of the blog/newsletter.

Also, if you intend to look into the FirstStrike system, I think he changed the strategy at some point. It looks more like a typical Larry Williams' 'Open+/- % or range with First Profitable Open Exit' system. Basically what I was going to work on next anyway, but on a smaller time frame than weekly.

It's going to take me a few weeks, but I will report back on my system development.

Last edited by DMB; 08/19/13 12:31.
Page 1 of 2 1 2

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