[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why does this stop order not execute at the correct price?



PureBytes Links

Trading Reference Links

I've set up some sample code and am running it on an intraday 1-minute chart (MSFT). (TS2000i).

I enter a position with a sell order, and set a stop for an exit using ExitShort.  The problem is that the stop is executed at a different price and I can't figure out why.  I've listed the code and the results below.

Any suggestions on what I'm missing?  It feels like I'm missing something simple.

***CODE:

print("Time: ",time," Date: ", Date);
if date=1010727 and time=1600 then
begin
	print("bar=",barnumber:0:0, " O=",O:0:2, " H=",H:0:2, " L=",L:0:2, " C=",C:0:2);
	sell next bar at market;
	print("entering next bar at ",open of next bar:0:2);
	ExitShort at 66.28 stop;
	print("setting 66.28 stop at next bar");
end;
if date=1010731 and (time=931 or time=932 or time=933) then
begin
	ExitShort at 66.28 stop;
	print("bar=",barnumber:0:0, " O=",O:0:2, " H=",H:0:2, " L=",L:0:2, " C=",C:0:2);
	print("setting 66.28 stop at next bar");
end;

***DEBUG RESULTS:
Time:    1559.00 Date: 1010727.00
Time:    1600.00 Date: 1010727.00
bar=626 O=65.47 H=65.50 L=65.47 C=65.47
entering next bar at 66.03
setting 66.28 stop at next bar at
Time:     931.00 Date: 1010731.00
bar=627 O=66.03 H=66.17 L=66.01 C=66.17
setting 66.28 stop at next bar at
Time:     932.00 Date: 1010731.00
bar=628 O=66.18 H=66.38 L=66.00 C=66.25
setting 66.28 stop at next bar at
Time:     933.00 Date: 1010731.00
bar=629 O=66.16 H=66.16 L=66.16 C=66.16
setting 66.28 stop at next bar at
Time:     934.00 Date: 1010731.00
Time:     935.00 Date: 1010731.00

***PERFORMANCE REPORTS EXECUTED TRADES:
1	7/31/2001	09:31	Sell	1	66.03	Sell		
	7/31/2001	09:32	SExit	1	66.38	SX#2	(.35)	(.35)