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

How to set EnterLimit lifetime

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

    How to set EnterLimit lifetime

    Hi,
    Could someone show me the code for doing the following steps?
    1. EnterLimitLong/short
    2. If the order is not filled within 1 bar's time then cancel the order.
    Thanks ... Ed

    #2
    Hello edstaffin,

    Thanks for your post.

    Are you doing this with the strategy wizard?

    If so, by default orders will have liveUntilCancelled as false. This means they will automatically cancel when the bar closes. To keep them alive, they must be called (and ignored) on each new bar.

    This means that the condition that creates the order will have to no longer be true for the order to cancel. But once the entry condition is not true the order will automatically be cancelled.


    Or to just prevent the order from being kept alive on the next bar even if your conditions for entry are true you would need to set a variable that prevents the order from being placed on the next bar (and then reset on the next bar).

    Attached is an example of using variables to not submit an entry when the entry conditions are true on the next bar.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      So if I understand correctly, if I do a EnterShortLimit(), by default, it cancels itself after one bar? Even if I don't use the overload that explcityly sets LiveUntilCancelled?
      Thanks ... Ed
      Last edited by edstaffin; 10-24-2014, 08:43 AM.

      Comment


        #4
        Hi Ed,

        That is correct. By default, liveUntilCancelled is false.
        http://www.ninjatrader.com/support/h...rlonglimit.htm

        The trick is not submitting the order again on the new bar.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by StockTrader88, 03-06-2021, 08:58 AM
        45 responses
        3,992 views
        3 likes
        Last Post johntraderuser2  
        Started by TAJTrades, Today, 09:46 AM
        0 responses
        7 views
        0 likes
        Last Post TAJTrades  
        Started by rhyminkevin, Yesterday, 04:58 PM
        5 responses
        62 views
        0 likes
        Last Post dp8282
        by dp8282
         
        Started by realblubb, Today, 09:28 AM
        0 responses
        8 views
        0 likes
        Last Post realblubb  
        Started by AaronKoRn, Yesterday, 09:49 PM
        1 response
        19 views
        0 likes
        Last Post Rikazkhan007  
        Working...
        X