Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time limitation for not filled LimitBuy?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Time limitation for not filled LimitBuy?

    Hello.
    Is there some way to limit the order

    MyOrder = EnterLongLimit(0, true, 1, SomePrice, "MyBuy1");

    by time when it does not get Filled? Lets say give it 30 minutes on 5M chart to fill, otherwise cancel it.


    I tried approach like this with no success.

    Code:
    if ( MyOrder != null && ToTime( MyOrder.Time)  > (ToTime(Time[0]) + 1000*30 ) ) 
    {
    CancelOrder(MyOrder);
    }

    Or is there any simple way to set up limit prices on which it will automatically cancel the unfilled EnterLongLimit()?

    Lets say I EnterLongLimit() but the market goes short for hours and not get filled. So is there a way to set Limit for example

    EnterLongLimit(0, true, 1, 10000 , "MyBuy1")

    to cancel this order at 9970 (-30 ticks) if it did not get filled by then?

    I didnt find anything useful
    Thank you very much

    #2
    Hello Avisak,

    Thank you for your post.

    Checking the time would be the recommended way to set a time limit for the order.

    For the price, just compare against the price wanted and the current value. For example:
    Code:
    if(Close[0] <= 9970)
    CancelOrder(MyOrder);

    Comment


      #3
      Thanks for the prompt reply.

      That sounds good. And is there a way to close the order immediately as the price match 9970? Not waiting for the current Bar to close? ( with still having OnBarUpdate = true; )

      Comment


        #4
        Hello Avisak,

        Unfortunately, you would need CalculateOnBarClose = False for this. However, you could split logic between COBC = True and COBC = False. You can find an example detailing this at the following link: http://www.ninjatrader.com/support/f...ad.php?t=19387

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        67 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        150 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        162 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        100 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        288 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X