Price of entry with OrderDelay

Posted By: Zheka

Price of entry with OrderDelay - 10/14/21 12:17

1) Using OrderDelay in Test, I have noticed that prices are different from those at the "timestamped" moments.

Say, with OrderDelay=59.9 and using M1 ticks, the timestamp of a trade is the first tick of a new bar (say, 8:01).

But the 'fill price' is different from that of a Close of 8:01 tick, or that of a 8:00 tick, and not by a spread or anything easily explainable.

So, Zorro must be doing some interpolation (though Slippage is set to 0).

Theoretically, such interpolations should make no material difference on a large sample of trades, BUT this is not what I am seeing.

On a sample of 23K+ trades across 11 currency pairs, entry prices with OrderDelay=59.9 are - on average - 0.4-0.6 pips BETTER than those at exact bar boundaries and even more so than at the next M1 tick.
This effect is quite similar for each pair.

So, how exactly does Zorro arrive at fill prices in the Test in this scenario and what would be the way to match it in Live?


2) Setting OrderDelay<60, leads to interpolations of prices somewhat closer to at exact bar boundaries; setting OrderDelay= 60-119.9 - closer to at the second M1 tick.

What would be the way to ensure that the fill price in Test is exactly at the 'close' of an M1 tick?

Not being able to do it is very inconvenient when reconciling Live vs Test for monitoring quality of execution.
Posted By: Zheka

Re: Price of entry with OrderDelay - 10/16/21 00:03

To support the above, this script
Code
int tmf() {
	
	if (TradeIsPending)
   	watch("#time=",tod(0), priceOpen(0), priceHigh(0), priceLow(0),priceClose(0));
	
	return 0;
}

function run() {
	NumYears=1;
	
	set(LOGFILE, TICKS);

	Verbose=3;
	
	Slippage=0;
	RollLong=RollShort=Spread=Commission=0;
	
	LifeTime=5;
	
	Entry=-3*PIP;
	
	OrderDelay=59.9; //119.9, 120.0
	
	if (NumOpenLong==0)
	 if (priceClose(0)>priceClose(20) ) 
		enterLong(tmf); 
}

produces this output at different OrderDelay:

[165: Wed 21-01-13 00:00c] -2.74 0 1/3 1.22061/1.22104\1.22025/1.22094 -0.0
Enter Long EUR/USD Entry -0.00030000 Delay 59.9 at 00:00:00
(EUR/USD::L) Long 1@1.22064 Entry limit
time= 0 1.22061 1.22104 1.22025 1.22094
time= 1 1.22094 1.22102 1.22094 .22102
[EUR/USD::L16602] Long 1@1.22094 x at 00:01:00

[151: Tue 21-01-12 10:00] 1.21527/1.21797\1.21509/1.21624 -0.0
Enter Long EUR/USD Entry -0.00030000 Delay 60.0 at 10:00:00
(EUR/USD::L) Long 1@1.21594 Entry limit
time= 1000 1.21527 1.21797 1.21509 1.21624
time= 1001 1.21624 1.21636 1.21614 1.21629
[EUR/USD::L15202] Long 1@1.21619 x at 10:01:00

[213: Fri 21-01-15 00:00c] -10.75 0 1/7 1.21532/1.21595\1.21507/1.21513 -0.00003
Enter Long EUR/USD Entry -0.00030000 Delay 118.9 at 00:00:00
(EUR/USD::L) Long 1@1.21483 Entry limit
time= 0 1.21532 1.21595 1.21507 1.21513
time= 1 1.21513 1.21518 1.21512 1.21515
time= 2 1.21513 1.21522 1.21512 1.21522
[EUR/USD::L21403] Long 1@1.21510 x at 00:02:00

[448: Fri 21-01-29 01:00c] -14.80 0 14/15 1.21216/1.21226\1.21043/1.21079 -0.0
Enter Long EUR/USD Entry -0.00030000 Delay 118.9 at 01:00:00
(EUR/USD::L) Long 1@1.21049 Entry limit
time= 100 1.21216 1.21226 1.21043 1.21079
time= 101 1.21079 1.21087 1.21070 1.21081
time= 102 1.21079 1.21091 1.21070 1.21081
[EUR/USD::L44905] Long 1@1.21075 x at 01:02:00

[1236: Wed 21-03-17 18:00c] 1.19022/1.19109\1.18983/1.19106 -0.0
Enter Long EUR/USD Entry -0.00030000 Delay 118.9 at 18:00:00
(EUR/USD::L) Long 1@1.19076 Entry limit
time= 1800 1.19022 1.19109 1.18983 1.19106
time= 1801 1.19106 1.19457 1.19106 1.19418
time= 1802 1.19106 1.19625 1.19106 1.19598
[EUR/USD::L23713] Long 1@ 1.19403 x at 18:02:00

[347: Fri 21-01-22 17:00c] -11.27 0 10/11 1.21727/1.21824\1.21711/1.21782 -0.0
Enter Long EUR/USD Entry -0.00030000 Delay 120.0 at 17:00:00
(EUR/USD::L) Long 1@1.21752 Entry limit
time= 1700 1.21727 1.21824 1.21711 1.21782
time= 1701 1.21782 1.21799 1.21782 1.21787
time= 1702 1.21782 1.21799 1.21778 1.21782
time= 1703 1.21782 1.21799 1.21773 1.21785
[EUR/USD::L34804] Long 1@1.21778 x at 17:03:00

[646: Wed 21-02-10 13:00] -13.81 0 21/26 1.21249/1.21250\1.21138/1.21173 -0.0
Enter Long EUR/USD Entry -0.00030000 Delay 120.0 at 13:00:00
(EUR/USD::L) Long 1@1.21143 Entry limit
time= 1300 1.21249 1.21250 1.21138 1.21173
time= 1301 1.21173 1.21189 1.21151 1.21158
time= 1302 1.21173 1.21189 1.21150 1.21169
time= 1303 1.21173 1.21189 1.21150 1.21173
[EUR/USD::L64707] Long 1@ 1.21162 x at 13:03:00


'Slippage' also works in some interesting ways:

//------------------if Slippage is not 0.--------------
[260: Tue 21-01-19 02:00] -14.97 +1.33 2/9 (1.20939)
time= 201 1.20939 1.20941 1.20936 1.20938
[EUR/USD::L25503] Expired 1@1.20942:[ +1.36 at 02:01:00 <---exit price is bigger than high of the tick??

[261: Tue 21-01-19 03:00] -13.61 0 2/9 (1.20953)
(EUR/USD::L) Long 1@1.20923 Entry limit
time= 300 1.20939 1.20987 1.20914 1.20953
time= 301 1.20953 1.20956 1.20931 1.20932
time= 302 1.20953 1.20956 1.20930 1.20935
[EUR/USD::L26203] Long 1@1.20928 x at 03:02:00 <---entry price is smaller than the lowest low of the first 2 ticks?

Posted By: Zheka

Re: Price of entry with OrderDelay - 10/18/21 16:51

Formatting does not seem to work:-( I cannot color-highlight or underline relevant prices...
Posted By: Grant

Re: Price of entry with OrderDelay - 10/18/21 17:31

Unfortunately the color tab only works outside a code-tag
Posted By: Zheka

Re: Price of entry with OrderDelay - 10/18/21 23:50

Thank you! I modified the post above.
Posted By: Zheka

Re: Price of entry with OrderDelay - 11/29/21 11:31

@jcl,

Can you pls provide a feedback on the issue?
Posted By: Petra

Re: Price of entry with OrderDelay - 11/29/21 13:50

I'm not jcl, but anyway: https://manual.zorro-project.com/fill.htm
Posted By: Zheka

Re: Price of entry with OrderDelay - 11/29/21 18:09

So, the applicable rule is:
Quote
Long OrderDelay. max of Entry and tick mid price.
It is obvious however in the first 2 of my examples that this rule isnt' followed:
Quote
[165: Wed 21-01-13 00:00c] -2.74 0 1/3 1.22061/1.22104\1.22025/1.22094 -0.0
Enter Long EUR/USD Entry -0.00030000 Delay 59.9 at 00:00:00
(EUR/USD::L) Long 1@1.22064 Entry limit
time= 0 1.22061 1.22104 1.22025 1.22094
time= 1 1.22094 1.22102 1.22094 .22102
[EUR/USD::L16602] Long 1@1.22094 x at 00:01:00

[151: Tue 21-01-12 10:00] 1.21527/1.21797\1.21509/1.21624 -0.0
Enter Long EUR/USD Entry -0.00030000 Delay 60.0 at 10:00:00
(EUR/USD::L) Long 1@1.21594 Entry limit
time= 1000 1.21527 1.21797 1.21509 1.21624
time= 1001 1.21624 1.21636 1.21614 1.21629
[EUR/USD::L15202] Long 1@1.21619 x at 10:01:00
However you calculate the mid-price - (O+H+L+C)/4 or (H+L+C)/3 or (H+L)/2 - the fill price is overly optimistic.
Posted By: Petra

Re: Price of entry with OrderDelay - 11/30/21 09:20

Well I am not sure about the purpose of your code but would normally assume that the entry price is determined by the entry tick, not the last pending tick, and priceHigh is normally the high of a candle, not of a tick. You can see the highs and lows of the historical ticks with the History script.

https://manual.zorro-project.com/price.htm
Posted By: Zheka

Re: Price of entry with OrderDelay - 11/30/21 09:56

The script is several messages above; its a script to demo this specific behavior: fill price logic for OrderDelay+Entry.

Please clarify "entry price is determined by the entry tick, not the last pending tick"...What's the "entry tick" and what's the "last pending tick"?

PriceHigh/Low/Close of course cover a candle-so-far, and but are equal to those of a "historical" tick for the very first tick of a bar - which is the tick timestamped "..01" - that I refer to in 2 examples above.
© 2024 lite-C Forums