CONTRACT LIMIT UNTIL TIME

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #192002 quote
    ashehzi
    Participant
    Average

    Hi,

    I put limit order based on my condition being fullfilled i.e.

    myLong= someValue

    TIMEOPERATE = TIME>000059 AND TIME<204500

    if condition=1 and TIMEOPERATE then

    BUY 1 CONTRACTS AT myLong limit

    endif

    Above will make sure the limit order is placed as (IG) GOOD UNTIL CANCEL.

    I don’t want any BUY orders after 2055 hours, so I want my LIMIT order to be LIMIT 205500 (time). Is there a way to do it in ProOrder?

    Thanks.

    #192004 quote
    robertogozzi
    Moderator
    Master

    There’s no UNTIL CANCEL instruction, as ProOrder CANCELS ALL pending orders when a candle closes (be it once a day in case of a Daily TF, or every second in case of 1-second TF).

    It’s the other way round… you’ll have to place pending orders again and again until you need it.

    So at any given time of your choice you only need to stop placing pending orders.

    #192006 quote
    ashehzi
    Participant
    Average

    Hi,

    The below logic is on 5m timeframe.

    Assuming I want my program to put orders until 204500 (08:45pm).

    Once condition is met, limit order is opened (attached snap bottom 20/04/22 20:45).

    The above is fine as per the rules till now.

    Now, I want to get my order cancelled (if already in place) and the time is 205000 (08:50 pm) because I don’t want any executions after 08:50pm.

    As per the snapshot, the original order of 20:45 stays in place and gets executed at 20:54 (because it was a limit order). At the same 20:54 stop and limit get amended as shown in the snapshot.

    Because of the price movement in my favour, Stop loss is pushed up at 21:05 (candle close/open time based on 5m tf).

    It gets closed at 21:06 on a small loss because of price movement of nasdaq based on TESLA earnings reporting.

     

    Is there a way to get the limit order closed at 08:50pm which was opened in the beginning at 08:45pm.

    Thanks for your quick responses.

    #192016 quote
    robertogozzi
    Moderator
    Master

    The rules about pending orders only apply to orders while they are still pending.

    Once they are triggered, you have to use the istructions to exit a trade at any given time, like any open trade.

    To exit an open trade at 08:45pm:

    IF Time = 204500 THEN
       SELL      AT MARKET
       EXITSHORT AT MARKET
    ENDIF

    If, instead, you are using a 5-minute TF and want to close any open trade AFTER 1 single bar, then place these few lines at the beginning of your code (just after DEFPARAMs, if any):

    IF OnMarket THEN
       SELL      AT MARKET
       EXITSHORT AT MARKET
    ENDIF
    #192018 quote
    ashehzi
    Participant
    Average

    Hi,

    If in trade, I have a condition already such as:

    IF LONGONMARKET and DayOfWeek = 5 and (TIME>205400) then
    Sell at market
    endif

    I am interested in closing my pending order programmatically at 2050 (e.g.) as I don’t want my pending order getting filled after 2050.

    #192020 quote
    ashehzi
    Participant
    Average

    I see your post on https://www.prorealcode.com/topic/cancel-pending-orders/ stating

    I will have a look and try that option of QUIT and system settings.

    Thanks.

    #192021 quote
    ashehzi
    Participant
    Average

    I’m going to use

    defparam FLATAFTER=205500

    hope it works.

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

CONTRACT LIMIT UNTIL TIME


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
ashehzi @ashehzi Participant
Summary

This topic contains 6 replies,
has 2 voices, and was last updated by ashehzi
3 years, 9 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 04/21/2022
Status: Active
Attachments: 1 files
Logo Logo
Loading...