Hi guys,
My code includes a QUIT instruction to be executed if certain conditions are met. If this happens when there is already a pending order (e.g. a BUY STOP order), then the system quits, but the pending order remains active. How can I avoid this? That is, how can I cancel any pending orders in the code (not manually)? I haven’t found anything.
Thanks in advance
QUIT instruction should also close all pending orders, such as STOP and LIMIT ones. However, pending orders have an expiration time of 1 bar, so if your code doesn’t renew them, they will be cancelled by themselves.
QUIT instruction should also close all pending orders, such as STOP and LIMIT ones. However, pending orders have an expiration time of 1 bar, so if your code doesn’t renew them, they will be cancelled by themselves.
Just so I understand correctly what you have written – is it possible for a strategy to QUIT at the opening of a candle and also place orders on the market which will then be there till the close of the candle?
If so this would mean that there could possibly be open positions which are not being controlled by a strategy.
No, once QUIT is read by the code, all active orders at market and pending ones are closed/deleted.
Thanks for your answers. That’s the way I thought it should work – but apparently, it’s not how it actually works. Last night, I went to check my pending orders, only to find a pending order had been filled AFTER the system had quit, and right, it was there, without any stop loss or take profit at all (!!) Fortunately, I managed to close it at only a small loss, but it could have been a disaster.
I’ve just tried this:
/// 1-MINUTE CHART ON EURUSD
IF (NOT ONMARKET) THEN
BUY 1 SHARES AT 1.25 STOP
ENDIF
IF (CURRENTTIME >= 161000) THEN
QUIT
ENDIF
Now it’s 16.12, the system has quit, but the pending order is still there, on my screen and order list, until I close it manually.
So, if this is a bug (and a dangerous one), and not my mistake, I’ll have to report it to PRT. Although, I have to say, I’ve reported other bugs before and never got any useful feedback from them.
I’m also reporting it now too.
In platform’s automatic trading settings, if “position and order status after stop of systems” is set to “Keep trading system positions(s) and pending order(s)”, your pending orders initiated by a trading program will remain on market, even if you QUIT.
Thank you Nicolas, I was told so by IG support. Then again, I’d like my open positions to be kept after quitting, but not my pending orders. I guess this can’t be done.