Cancel pending orders

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #66642 quote
    waterofleith
    Participant
    New

    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

    #66650 quote
    Nicolas
    Keymaster
    Master

    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.

    #66667 quote
    Vonasi
    Moderator
    Master

    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.

    #66669 quote
    Nicolas
    Keymaster
    Master

    No, once QUIT is read by the code, all active orders at market and pending ones are closed/deleted.

    Vonasi and robertogozzi thanked this post
    #66708 quote
    waterofleith
    Participant
    New

    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.

    #66716 quote
    Nicolas
    Keymaster
    Master

    I’m also reporting it now too.

    Vonasi and waterofleith thanked this post
    #69144 quote
    Nicolas
    Keymaster
    Master

    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.

    Vonasi thanked this post
    automatic-trading-settings.png automatic-trading-settings.png
    #69177 quote
    waterofleith
    Participant
    New

    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.

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.

Cancel pending orders


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 7 replies,
has 3 voices, and was last updated by waterofleith
7 years, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 03/29/2018
Status: Active
Attachments: 1 files
Logo Logo
Loading...