Gamestudio Links
Zorro Links
Newest Posts
WFO Training with parallel cores Zorro64
by Martin_HH. 02/23/26 10:49
ZorroGPT
by TipmyPip. 02/21/26 19:15
Camera always moves upwards?
by clonman. 02/21/26 09:29
Zorro version 3.0 prerelease!
by TipmyPip. 02/20/26 13:22
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/19/26 13:22
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
3 registered members (MonsterX, Martin_HH, TipmyPip), 6,282 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
alx, ApprenticeInMuc, PatrickH90, USER0328, Sfrdragon
19199 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Short trade not entered? #428517
08/29/13 04:45
08/29/13 04:45
Joined: Jun 2013
Posts: 1,609
D
DdlV Offline OP
Serious User
DdlV  Offline OP
Serious User
D

Joined: Jun 2013
Posts: 1,609
Hi. Probably another late-night blindness, but can someone tell me why the Short trade isn't entered in this simple script?

Code:
function tmf() {
	for(open_trades) {
	}
	return 0;
}

function run() {
	set(HEDGING);
	set(LOGFILE);
	set(PARAMETERS);
	set(PLOTNOW);
	set(PLOTPRICE);
	set(TICKS);
	
	BarPeriod	= 240;
	StartDate	= 20130101;
	EndDate		= 20130331;
	
	if(NumOpenTotal==0) {
		enterLong(tmf);
		enterShort(tmf);
	}
}



If I comment out the empty for(open_trades) loop in the TMF, the Short trade is entered...

Thanks.

Re: Short trade not entered? [Re: DdlV] #428528
08/29/13 10:34
08/29/13 10:34
Joined: Jul 2000
Posts: 28,074
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,074
Frankfurt
Originally Posted By: manual
Trade management functions run at every tick and are bound to their trade, which implies some restrictions. Data series can not be created in a TMF, and indicators creating data series can not be called. A TMF should only handle its own trade: it must not contain trade enumeration loops or access other trades, but it can open new trades with enterLong/Short (Zorro 1.16 and above). The current candle is incomplete, so its range and height is normally smaller than the other candles; the last full candle has the index 1. The price functions can be called, but their open, high, or low prices do not reflect a full candle, but are in relation to the bar begin. Use TradePriceOpen or TradePriceClose for getting the current price of the asset.


Trade enumeration loops and TMFs both change the ThisTrade pointer, so they are mutually exclusive - combining them makes not much sense anyway.

Re: Short trade not entered? [Re: jcl] #428542
08/29/13 13:02
08/29/13 13:02
Joined: Jun 2013
Posts: 1,609
D
DdlV Offline OP
Serious User
DdlV  Offline OP
Serious User
D

Joined: Jun 2013
Posts: 1,609
Thanks jcl. Missed that... Can it be a compiler error?

If I want to handle a trade based on how other trades are doing as well, these are the 2 choices, correct?

1) Do it at the Bar/run level, not in a TMF.
2) Do my own pointer management, if in a TMF.

Thanks.

Re: Short trade not entered? [Re: DdlV] #428544
08/29/13 13:24
08/29/13 13:24
Joined: Jul 2000
Posts: 28,074
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,074
Frankfurt
You have only option 1. Handling other trades in a TMF will not work at all, no matter how you code it. A TMF is for managing its own trade only, and does not know about other trades. It is an isolated process.

Re: Short trade not entered? [Re: jcl] #428548
08/29/13 14:07
08/29/13 14:07
Joined: May 2013
Posts: 245
S
swingtraderkk Offline
Member
swingtraderkk  Offline
Member
S

Joined: May 2013
Posts: 245
jcl,

I think this is possible, but I'm not sure:

Can the tmf edit a global variable?

Can other tmfs access and react to the value of that global variable?

if this is true this could be a workaround to the tick level event management, but we would need to know the order in which trade tmfs are processed.

Re: Short trade not entered? [Re: swingtraderkk] #428551
08/29/13 14:20
08/29/13 14:20
Joined: Jul 2000
Posts: 28,074
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,074
Frankfurt
Yes, TMFs can edit global variables, but they can not access other trades. This is not due to some programming issue, but because they run at a different time. When a TMF of trade 1 looks into trades 2 and 3, trade 2 may be still at the begin of the bar and trade 3 is already at end of the bar. So they both have wrong values in comparison to trade 1.

Of course this happens only in the simulation, in real trading a TMF could theoretically access other trades. But doing that is certainly not a good idea because, aside from other reasons, you can't simulate it.

Re: Short trade not entered? [Re: jcl] #428558
08/29/13 16:54
08/29/13 16:54
Joined: May 2013
Posts: 245
S
swingtraderkk Offline
Member
swingtraderkk  Offline
Member
S

Joined: May 2013
Posts: 245
What I was proposing was say a series of flags e.g. an OCO order using global variables longhit & shorthit.

A tmf is run for each trade each tick, so the tmf for the long could set longhit to true. At the next tick (or even on the same tick, the short tmf could check if longhit = true and exit the pending order.

Does this make sense? Would it work?

Re: Short trade not entered? [Re: swingtraderkk] #428560
08/29/13 17:00
08/29/13 17:00
Joined: Jul 2000
Posts: 28,074
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,074
Frankfurt
No, it would not work. Dependent on the order of trades, longhit would either never be true, or always.

Accessing other trades in a TMF has not been implemented, as it would require a less efficient software structure and make test and training much slower.

Re: Short trade not entered? [Re: jcl] #428615
08/30/13 16:02
08/30/13 16:02
Joined: Nov 2012
Posts: 126
B
blaub4r Offline
Member
blaub4r  Offline
Member
B

Joined: Nov 2012
Posts: 126
Originally Posted By: jcl
Originally Posted By: manual
Trade management functions run at every tick and are bound to their trade, which implies some restrictions. Data series can not be created in a TMF, and indicators creating data series can not be called. A TMF should only handle its own trade: it must not contain trade enumeration loops or access other trades, but it can open new trades with enterLong/Short (Zorro 1.16 and above). The current candle is incomplete, so its range and height is normally smaller than the other candles; the last full candle has the index 1. The price functions can be called, but their open, high, or low prices do not reflect a full candle, but are in relation to the bar begin. Use TradePriceOpen or TradePriceClose for getting the current price of the asset.



Zorro 1.16? Is this a typo or is 1.16 currently in beta test?

Re: Short trade not entered? [Re: blaub4r] #428686
09/01/13 15:03
09/01/13 15:03
Joined: Sep 2003
Posts: 934
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 934
According to this page: http://manual.zorro-trader.com/new.htm 1.16 is in development, so trades can probably not be entered in a TMF with 1.14, but this will work with 1.16.


Moderated by  Petra 

Gamestudio download | 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