Gamestudio Links
Zorro Links
Newest Posts
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
1 registered members (AbrahamR), 717 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Short trades not being taken #428394
08/26/13 19:30
08/26/13 19:30
Joined: May 2013
Posts: 245
S
swingtraderkk Offline OP
Member
swingtraderkk  Offline OP
Member
S

Joined: May 2013
Posts: 245
OK spent way too long trying to bug hunt this issue. For some reason, long trades only are being taken my scripts.

Example script below:

Code:
function run()
{
	set(LOGFILE);
	BarOffset = timeOffset(ET,0,17,0);
	BarPeriod = 1440;
	StartDate = 2002;	
	
	vars cl	= series(priceClose());
	int threshold = 80;
	int exitbars  = 8;
	
	ExitTime = exitbars;
	Stop = 140*PIP;
	
	if (cl[0] > MaxVal(cl+1,threshold)) enterLong();
	if (cl[0] < MinVal(cl+1,threshold))	enterShort();
}


Re: Short trades not being taken [Re: swingtraderkk] #428401
08/26/13 20:59
08/26/13 20:59

A
acidburn
Unregistered
acidburn
Unregistered
A



Add LookBack = 100 (for example), then it works.

Although it is a bit strange that M{ax,in}Val functions don't complain about Lookback, but many others do. Probably that fact confused you.

Re: Short trades not being taken [Re: ] #428406
08/27/13 04:51
08/27/13 04:51
Joined: May 2013
Posts: 245
S
swingtraderkk Offline OP
Member
swingtraderkk  Offline OP
Member
S

Joined: May 2013
Posts: 245
Thanks acidburn!

This was driving me crazy!

Especially because MaxVal seemed to cope just fine without LookBack.

Another strange issue is why a LookBack of 80 doesn't work.

BTW does this code successfully use daily bars with a daily close of 5pm ET?

Re: Short trades not being taken [Re: swingtraderkk] #428416
08/27/13 08:24
08/27/13 08:24
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
No, for daily bars starting and closing at 17:00 ET, you need this:

BarOffset = (ET+17)*60;

And the short trade problem was indeed tricky, I had to look twice until I saw the reason. You're shifting the series by 1 and use 80 bars, so your lookback period must be 1+80 = 81 at least. The default is 80.

The too short lookback period caused the first value of the series to be wrong, therefore the short trade condition was never met. The computer can not detect this kind of error, so you get no error message.

Re: Short trades not being taken [Re: jcl] #428453
08/27/13 16:51
08/27/13 16:51
Joined: May 2013
Posts: 245
S
swingtraderkk Offline OP
Member
swingtraderkk  Offline OP
Member
S

Joined: May 2013
Posts: 245
Thanks jcl.

Much appreciated on both counts.


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