Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Quad, aliswee), 835 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
v 2.42.4 First entry into TMF with OrderDelay #484335
10/10/21 12:37
10/10/21 12:37
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
Hi,

There is a change in behavior in 2.4x vs 2.37.3 in a situation when TMF is used and OrderDelay is set.
Code
int tmf() {
	watch("#time=",tod(0));
	return 0;
}

function run() {
	NumYears=1;
	
	set(LOGFILE, TICKS);
		
	LifeTime=5;
	
	Entry=-1*PIP;
	
	OrderDelay=59.99; // or 119.99
	
	if (NumOpenLong==0)
	 if (priceClose(0)>priceClose(20) ) enterLong(tmf); 	
}

in v 2.37.3, TMF is entered on the 1st tick of the next bar - as expected:
Quote
[[[103: Fri 21-01-08 07:00] (1.22641) <----with OrderDelay=119.99
(EUR/USD::L) Long 1@1.22631 Entry limit
(EUR/USD::L) Entry limit 1.22631 hit by 1.22619 at 07:01:00
time= 701
[EUR/USD::L10402] Long 1@1.22610 x at 07:01:00
time= 701
......
..........
[165: Wed 21-01-13 00:00] -3.45 0 1/3 (1.22094) <----with OrderDelay=59.99
(EUR/USD::L) Long 1@1.22084 Entry limit
[EUR/USD::L16602] Long 1@1.22103 x at 00:01:00
time= 1
time= 2

in 2.42.4 however, TMF is entered only on the next tick:
Quote
[103: Fri 21-01-08 07:00] (1.22641) <----with OrderDelay=59.99
(EUR/USD::L) Long 1@1.22631 Entry limit
[EUR/USD::L10402] Long 1@1.22610 x at 07:01:00
time= 702

[i][103: Fri 21-01-08 07:00] (1.22641) <----with OrderDelay=119.99
(EUR/USD::L) Long 1@1.22631 Entry limit
(EUR/USD::L) Entry limit 1.22631 hit at 1.22619 07:01:00
time= 701 <---- OK
[EUR/USD::L10402] Long 1@1.22610 x at 07:01:00
time= 702

...................
....................
[165: Wed 21-01-13 00:00] -3.45 0 1/3 (1.22094) <----with OrderDelay=59.99
(EUR/USD::L) Long 1@1.22084 Entry limit
[EUR/USD::L16602] Long 1@1.22103 x at 00:01:00
time= 2
time= 3[/i]

[165: Wed 21-01-13 00:00] -3.40 0 1/3 (1.22094) <----with OrderDelay=119.99
(EUR/USD::L) Long 1@1.22084 Entry limit
[EUR/USD::L16602] Long 1@1.22111 x at 00:02:00
time= 3
time= 4

I am relying on the time of tmf entry in my code to later adjust entry/stop/tp - so this is a "code breaking change'.
Can this behavior please be reverted?

Last edited by Zheka; 10/10/21 13:24.
Re: v 2.42.4 First entry into TMF with OrderDelay [Re: Zheka] #484343
10/11/21 11:58
10/11/21 11:58
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Ok, we'll look into that. Btw, the entry time is TradeDate.

Update: We looked into it and the time was correct. Entry was at 9:01, first tmf ran at 9:02 by the first tick after entry. I don't know why 2.37.3 had an earlier time, but that was a beta version and that time is random anyway. Ticks arrive in irregular intervals and tmfs are also triggered by other events. Thus, using the tmf time for calculating something seems to me no good idea. If you need the entry time, use TradeDate.

Re: v 2.42.4 First entry into TMF with OrderDelay [Re: Zheka] #484356
10/13/21 17:25
10/13/21 17:25
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
I am not using the time of tmf entry per se. I am using prices, spread,etc at the time of enterLong/Short to dynamically adjust TradeEntryLimit.

For this, I assume//rely on that a tmf is entered into at the time of enterLong/Short, at least at the next available tick.

The manual states that "Since a TMF runs at every tick, it has access to the most recent price quote" and in ALL prior versions this has been the case (I relied on this and 100% sure of this).

Now, this is what happens in 2.42.4 ( if you comment out OrderDelay):
Quote
[151: Tue 21-01-12 10:00] (1.21624)
(EUR/USD::L) Long 1@1.21604 Entry limit
(EUR/USD::L) Entry limit 1.21604 hit at 1.21599 10:08:00
time= 1008
[EUR/USD::L15202] Long 1@1.21615 x at 10:08:00
time= 1009
i.e. a TMF is not entered at all until the Entry limit is hit!

With this, adjustments to TradeEntryLimit while a TradeIsPending are impossible; one can now only manage Exits with the tmf, but not micro-manage Entries.

This could hardly be the intention.

Last edited by Zheka; 10/13/21 17:26.
Re: v 2.42.4 First entry into TMF with OrderDelay [Re: Zheka] #484358
10/14/21 09:42
10/14/21 09:42
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
I agree, if a trade is pending by EntryLimit, its TMF should run. If it is not so, it would be a bug. I'll tell the developers to look into that.

Update: TMFs indeed run only with open trades, not with pending trades. I would interpret the manual so that they also run with pending trades. It would make sense for managing the entry. This will be implemented in the next version.

Re: v 2.42.4 First entry into TMF with OrderDelay [Re: Zheka] #484361
10/15/21 08:23
10/15/21 08:23
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
Half of TMF functionality was explicitly for managing pending trades.

e.g.
- "TMFs are also executed at 4 special events in the lifetime of a trade: Right before entering or exiting due to Entry, Stop, or TakeProfit, and right after being closed" <--- in 2.4x TMF will NOT run "right before entering".

- return 1,2, 4, 16 - all assumed managing pending trades. I specifically rely on "return 4/ 2" to enter immediately under some circumstances.

-"TradeDate: The time in Windows Date format when a trade is to be entered (for trades with OrderDelay) " <-- this doesnt work in TMFs in v.2.4x
- "TradeBars: The number of bars since the trade was entered (for pending trades) " <- this doesnt work in TMFs in v 2.4x

etc..

ALL prior versions worked as expected/described in the manual, so this is definitely a regression (AKA bug) in v 2.4x., not a new functionality to be added.

My code heavily relies on this feature. I would really appreciate if this is fixed in the next beta.

Thank you.

Re: v 2.42.4 First entry into TMF with OrderDelay [Re: Zheka] #484362
10/15/21 10:11
10/15/21 10:11
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
I cannot confirm any of these problems so far. Can you post the code?

Just to avoid confusion: A TMF runs right before entering by an entry limit, but not on ticks when the trade is not open. This has nothing to do with the Zorro version. The manual suggests that it also runs on ticks when pending. This was not implemented, but will be now.


Re: v 2.42.4 First entry into TMF with OrderDelay [Re: Zheka] #484363
10/15/21 10:53
10/15/21 10:53
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
As for TMF running when TradeIsEntry, - I stand corrected, it actually does run as stated in v 2.4x.

But in general, " running on ticks when pending" was an integral part of working TMF functionality in versions prior to 2.4x.

I am kindly asking to fix this regression in the next beta, not a 'new version' (which I guess means 2.5...or so?).

I could continue using 2.37.3 for now, but there are 2 features in 2.42.4 that make life easier: LookBackResolution and waiting for the complete 1st bar to run in Live.


P.S.: it would be nice to also have a TradeEntryDate available somehow.

Last edited by Zheka; 10/15/21 10:58.
Re: v 2.42.4 First entry into TMF with OrderDelay [Re: Zheka] #484364
10/15/21 11:00
10/15/21 11:00
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
We will implement the tick triggering on pending, but I do not think that version 2.37.3 did it, at least there was no code for it.

As to the trade entry date and other problems that you mentioned, we cannot confirm them either - please post the script and we'll look into them.

Re: v 2.42.4 First entry into TMF with OrderDelay [Re: Zheka] #484365
10/15/21 11:31
10/15/21 11:31
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
Thank you.

In v2.37.3, this code:
Code
int tmf() {
	  watch("#time=",tod(0));
	return 0;
}

function run() {
	NumYears=1;
	
	set(LOGFILE);
	set(TICKS);
		
	LifeTime=5;
	
	Entry=-2*PIP;
	
	//OrderDelay=59.9;
	
	if (NumOpenLong==0)
	 if (priceClose(0)>priceClose(20) ) 
		enterLong(tmf); 	 
}
produces this output:
Code
[151: Tue 21-01-12 10:00] -6.15 0 0/2 (1.21624)
(EUR/USD::L) Long 1@1.21604 Entry limit
time= 1001 
time= 1002 
time= 1003 
time= 1004 
time= 1005 
time= 1006 
time= 1007 
(EUR/USD::L) Entry limit 1.21604 hit by 1.21599 at 10:08:00
time= 1008 
[EUR/USD::L15202] Long 1@1.21615 x at 10:08:00
time= 1008 

Re: v 2.42.4 First entry into TMF with OrderDelay [Re: Zheka] #484368
10/15/21 16:17
10/15/21 16:17
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
jcl,

in 2.42.5, TMFs are now called when a trade is pending, great.

However, there is something wonky going on when TMF returns 4.
Code
int tmf() {
	
      watch("#time=",tod(0));

if (TradeIsEntry) return 4;

	return 0;
}

function run() {
	NumYears=1;
	
	set(LOGFILE, TICKS);
			
	LifeTime=5;
	
	Entry=-3*PIP;
	
	if (NumOpenLong==0)
	 if (priceClose(0)>priceClose(20) ) 
		enterLong(tmf); 	 
}
produces some weird output:
Code
[104: Fri 21-01-08 08:00] 0000 0 0/0 (0.776700)
(AUD/USD::L) Long 1@0.776400 Entry limit
time= 800 
(AUD/USD::L) Missed entry 0.77753 after 1 bar       <---???
(AUD/USD::L) Entry limit 0.776400 hit at 0.776090 08:01:00
time= 801 

[105: Fri 21-01-08 09:00] 0000 0 0/0 (0.776450)
(AUD/USD::L) Long 1@0.776150 Entry limit
time= 900 
(AUD/USD::L) Missed entry 0.77640 after 1 bar    <---???
time= 901 
time= 902 
time= 903 
time= 904 
(AUD/USD::L) Entry limit 0.776150 hit at 0.776080 09:05:00
time= 905 

TMF now does not run once the trade is open!?

Last edited by Zheka; 10/15/21 16:18.
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