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 rhyminkevin, Today, 04:58 PM
        3 responses
        49 views
        0 likes
        Last Post Anfedport  
        Started by iceman2018, Today, 05:07 PM
        0 responses
        5 views
        0 likes
        Last Post iceman2018  
        Started by lightsun47, Today, 03:51 PM
        0 responses
        7 views
        0 likes
        Last Post lightsun47  
        Started by 00nevest, Today, 02:27 PM
        1 response
        14 views
        0 likes
        Last Post 00nevest  
        Started by futtrader, 04-21-2024, 01:50 AM
        4 responses
        50 views
        0 likes
        Last Post futtrader  
        Working...
        X