Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 magnatauren, 08-15-2020, 02:12 PM
        5 responses
        206 views
        0 likes
        Last Post RaddiFX
        by RaddiFX
         
        Started by rene69851, 05-02-2024, 03:25 PM
        1 response
        20 views
        0 likes
        Last Post rene69851  
        Started by ETFVoyageur, Yesterday, 07:05 PM
        5 responses
        45 views
        0 likes
        Last Post ETFVoyageur  
        Started by jpeep, 08-16-2020, 08:31 AM
        13 responses
        487 views
        0 likes
        Last Post notenufftime  
        Started by realblubb, 04-28-2024, 09:28 AM
        2 responses
        32 views
        0 likes
        Last Post realblubb  
        Working...
        X