Gamestudio Links
Zorro Links
Newest Posts
Zorro version 3.0 prerelease!
by jcl. 02/12/26 14:05
MarginCost discrepancy?
by jcl. 02/12/26 14:02
Hedge on FXCM, 4 or 5?
by qin. 02/11/26 14:12
CMC MT4 CFD vs FX Active - what's better?
by mayarik. 02/11/26 11:00
print a "still alive" log
by qin. 02/10/26 12:16
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (TipmyPip), 7,787 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
ApprenticeInMuc, PatrickH90, USER0328, Sfrdragon, mayarik
19198 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
limit order filled at the next day's opening price is 0.01 less #489071
01/06/26 09:24
01/06/26 09:24
Joined: Jan 2023
Posts: 48
Q
qin Offline OP
Newbie
qin  Offline OP
Newbie
Q

Joined: Jan 2023
Posts: 48
I tested limit orders using the following code. I set Fill=3, meaning the order is filled at the opening price of the next day. I used historical AAPL EOD data. I placed the order on 2025-1-16 with a limit price of Entry = -232.00. I expected the order to be filled at the opening price of 231.86 the next day (17th, as shown in the attached image), but it was actually filled at 231.85 on the 17th, which is 0.01 less than expected. I'm not sure why this is happening. I tested several other dates, and the result was consistently 0.01 less. Any idea?
Code
function run() 
{
	set(LOGFILE);
	StartDate = 20250101;
	EndDate = 20250212;
	LookBack = 5;
	Slippage=0;
	Fill = 3;
	Spread = 0;
	BarPeriod = 1440;
	assetList("AssetsSP30");
	asset("AAPL");
	vars Prices = series(priceC());
	Entry = - 232.00 ;	

	if(year()==2025 && month()==1 && day()==16){
		watch("date",year(), month(),day());
		enterLong();
	}		
}

Attached Files aapl.png
Re: limit order filled at the next day's opening price is 0.01 less [Re: qin] #489072
01/06/26 10:31
01/06/26 10:31
Joined: Jul 2000
Posts: 28,072
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,072
Frankfurt
Good question. The reason of the difference is simulating the most likely price move between triggering the trade and and filling the order. Since you have an entry limit, the price is supposed to move against the trade direction. This difference is rounded to the next point, which is 0.01 in case of stocks.

It is arguable whether this makes much sense, since the Slippage simulation should anyway cover it. It has historical reasons, we wanted to replicate the backtests of TradeStation. They are in this way adding or subtracting one point from the fill price. We will probably in a future version add a flag to enable or disable that effect.

Re: limit order filled at the next day's opening price is 0.01 less [Re: qin] #489073
01/06/26 14:35
01/06/26 14:35
Joined: Jan 2023
Posts: 48
Q
qin Offline OP
Newbie
qin  Offline OP
Newbie
Q

Joined: Jan 2023
Posts: 48
This revision is highly necessary, as otherwise the outcome would be too optimistic.

Re: limit order filled at the next day's opening price is 0.01 less [Re: qin] #489074
01/06/26 16:43
01/06/26 16:43
Joined: Jul 2000
Posts: 28,072
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,072
Frankfurt
In this case yes, in other cases it's pessimistic. But we'll add a flag for that.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1