Cancelling/Closing At End Of Day
Author: kcbars
Creation Date: 9/13/2016 3:08 PM
profile picture

kcbars

#1
Hello. I ran a strategy live for the first time today (via Fidelity). It uses about 80 symbols and 1 minute time frame and only runs during the first half hour. It buys/shorts at market, then a limit sell/cover is generated, then it is supposed to close out at market at 10:01. Everything worked fine until the cancel of the limit order and close out of the 10 or so trades it entered. I think what happened is it cancelled the limit orders, then tried to sell at market too quickly. There was some sort of message in the order screen, but when I hit update it disappeared. But regardless, the end of day orders didn't happen so I made them manually. So I guess my question is - could I put in a statement like "if time < 1000, sell at limit..." so when 1000 came it would cancel the limit order, then sell at market at 1001? Thanks for the help. Kevin.
profile picture

Eugene

#2
QUOTE:
could I put in a statement like "if time < 1000, sell at limit..." so when 1000 came it would cancel the limit order, then sell at market at 1001?

Please try GetTime from Community Components:

Intraday Support Functions
Building blocks of Intraday trading strategies > Function to easily determine and compare time of day
profile picture

kcbars

#3
Thanks for the reply. I'm already using time functions in the report, but I'm just curious if I use it for the sell limit order if it will work like I think it will...if the limit order will be cancelled once the time goes past the range specified.
profile picture

Eugene

#4
A time condition doesn't cancel an order; it rather won't re-send the order once the time goes past the range specified.
profile picture

Cone

#5
QUOTE:
the end of day orders didn't happen so I made them manually
By "end of day" do you mean, "Market on Close" (MOC)?

If so, Wealth-Lab does not support MOC orders. The best you can do to automate a "near MOC" order is to trigger market orders 1 minute before the close (usually 1559, but 1259 on short days). If you wait for 1600 to trigger [market] orders, it will already be too late to be accepted during regular market hours.
profile picture

kcbars

#6
No, in this case I mean 1000. So I guess what I need to know is if there is a way to cancel the limit orders one minute before the end of day market orders.
profile picture

Cone

#7
There's nothing built in that would allow you to automatically cancel EOD orders at a specific time of day. You'd probably have to resort to AutoIT (or something of the sort) to cancel orders from the Orders window.

The most straightforward way to place or cancel orders at a specific time of day is to program a strategy to do it using an intraday chart interval. If you need to cancel 1 minute before the close, then you'd need to use 1 minute bars.

The "intraday strategy" could be very simple - you could program the strategy to simply import a file of EOD alerts and place or cancel the orders when required.
profile picture

kcbars

#8
Thanks very much. I'm only using a one minute time frame. Really all I need to do is make sure the limit orders are not cancelled right before the sell at market orders, but maybe a bar earlier. This may be a dumb question, but I can't remember if the limit orders are cancelled then resent at every bar? If that's the case, couldn't I just stop the limit orders a bit earlier so they don't get re-sent on the last bar before the "end of day" market sell?
profile picture

Cone

#9
There should not be a reason that you cannot cancel the limit orders on the same bar that you enter the market orders. If everything were working properly, the system should wait to place the market orders after receiving a cancel status of the limit orders. However, I vaguely recall someone reporting a similar problem several months ago, though I can't find that report at this time.

QUOTE:
if the limit orders are cancelled then resent at every bar?
Orders by default are sent with "Day" TIF. Consequently, unless the limit price changes, it's not required to "resend" the order. However, to keep the order live, the script needs to continue to Alert....

QUOTE:
couldn't I just stop the limit orders a bit earlier
Precisely correct. Just discontinue the limit order at 1558 and send the market orders at 1559.

profile picture

kcbars

#10
Once again, thank you very much. I will make the change and see what happens.
profile picture

kcbars

#11
Hello again. This may be the subject of a new thread, but I will continue here. The above works as intended, however, I don't believe the auto-place function is working correctly. I'm using strategy monitor, and the strategy is supposed to place a buy market order, then a limit sell on the next bar. The strategy sends the buy market order to Fidelity, and Fidelity places the order, but the subsequent orders will not happen until I hit the "update" button in the order screen and change the status to "filled". Once I do this, the next limit sell order will be placed. At the end of the session, it seems to work correctly - the limit orders were cancelled automatically, and the sell orders occurred. So it seems at least some of the orders are not being automatically updated in Wealth-Lab, even though auto-place is on? Is there something I can check, maybe? Thanks.
profile picture

Cone

#12
The update button shouldn't have to be used, but if an order status change doesn't appear when you expect one, "Update" will attempt to retrieve the status of live orders. In the case that you describe, it seems that orders were placed, active, and perhaps filled, but the status wasn't update in a timely manner. In my experience, AT Pro always shows the orders and their status, so it's not a bad idea to have that running to get a better idea of precisely what's happening.

In other cases, we have the infamous and seemingly unresolvable stuck "Submitted" status bug. If you place an order that remains "Submitted" for more than 10 seconds, it's likely that that order was completely lost - not received by the Fidelity back end. In this case you need to take over manually - I'd recommend using AT Pro. (We've been looking for a smoking gun for years on this bug, but Fidelity developers cannot duplicate it.)
profile picture

Eugene

#13
profile picture

kcbars

#14
Yes, I do always keep AP Pro open at the same time as wealth-lab is running. That's how I know the orders are being filled on Fidelity's end, but are not updating in Wealth-lab. This is different than the stuck submitted issue - in that case nothing happens on Fidelity's end. In this case, the only way for things to work properly is for me to manually hit update every minute (for a one minute strategy), so the order status gets changed in Wealth-Lab. So basically, it makes it unusable for what I'm trying to do, I think. Thanks.
profile picture

Cone

#15
Sorry that you're getting that experience. If you're using 6.9.15 (or 6.9.16), try downgrading to 6.9.12. I think you should have better success with the previous version, though at times you may have to wait up to 30 seconds for order status to be updated.
profile picture

kcbars

#16
I'm using 6.9.12 - anything beyond that and I only get the "stuck submitted" problem. Perhaps I should go back to something earlier? I'm certain the order status won't be updated until I hit the button on 6.9.12. Thanks.
profile picture

Cone

#17
You could go back to 6.8, but I can't see a reason why it would be any different than 6.9.12.
profile picture

kcbars

#18
Yea, I can't imagine it would be different. But big picture, I'm beginning to wonder about the platform in general, at least for intraday trading. Between the order status issue, and the stuck submitted problems, I'm wondering if it will ever be possible to use the product with Fidelity, really? Or if they or you are working to resolve either issue? One would think since Fidelity owns the product (I think), they would want it to work correctly? Or maybe I'm the only one having this issue? Thanks.
profile picture

kazuna

#19
You are not alone. I'm tracking several issues that Fidelity has been notified months or even years ago.

I get stuck submitted orders when I let WLP running for several hours without placing any orders. I worked it around by rolling back to 6.9.12. Placing dummy orders as described in the order thread may work it around as well but I hesitate to try it out for now.

I get stuck submitted orders when I place orders back to back very quickly (say within 4 seconds). I worked it around by waiting for at least 5 seconds between any orders. But I'm suffering a slippage in order execution because of delaying orders.

I get order status not updating for "Filled" and "Fill Price" field on Orders window, especially the orders placed first in the morning right after the market opened. I get order confirmation via the text message immediately after placing the orders but WLP just changes the status from Active to Filled without updating those fields. So I cannot rely on WLP for this confirmation.

Often times these issues cost me a lot more than I pay the trade fee to Fidelity. So be careful.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).