Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Easiest way to maintain limit order open across multiple bars

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

    Easiest way to maintain limit order open across multiple bars

    Hi everyone,

    I know this has been discussed a couple of times but I just can't get it to work. What is the easiest way to place a limit order that will stay open in a strategy that is tick-based, please? I have a simple strategy with a few lagging indicators and parabolic stop loss configured and it works like a charm. The two limit orders, one is names golong and one is named goshort. All orders are unique, max 1 entry per direction and 1 trade in total allowed.

    All I would like is to have a parameter to keep the trade open for, say 2 bars.
    Can anybody point me into the right direction please?

    Code:
    all the initial code...
    
    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;
    
    if (CurrentBars[0] < 1)
    return;
    
    // Set 1
    ...
        EnterLongLimit(Convert.ToInt32(DefaultQuantity), GetCurrentAsk(0), @"golong");
    
    // Set 2
    ...
        EnterShortLimit(Convert.ToInt32(DefaultQuantity), GetCurrentAsk(0), @"goshort");
    
    }

    #2
    Hello Oracletrades,

    Thank you for the post.

    Are you manually coding this or using the builder?

    If you are manually coding this you could use the IsLiveUntilCancelled overload set for the entry limit methods. That marks the order to not be cancelled unless you cancel it or it fills.

    If you used the builder you would need to use logic to maintain the order. That generally would involve using some kind of variable so you can keep a condition open for as long as the variable is true.

    Once I know how you are coding this we could go into further details where needed.

    I look forward to being of further assistance.

    Comment


      #3
      Hi Jesse, thanks for the offer to help. I would do this in code. I only use the strategy builder to provide the basic strategy architecture and then I move to the code.

      Comment


        #4
        Hello

        Thanks for confirming that.

        You could use the overloads which have IsLiveUntilCancelled or you could use logic to hold the orders open. It depends on your goals and how you wanted to design the strategy. If you wanted the order to remain open until filled or you specifically cancel it then you can use IsLiveUntilCancelled:

        EnterLongLimit(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double limitPrice, string signalName)


        To otherwise keep an order open you would have to keep calling EnterLongLimit for each bar where the order needs to be live. A variable would generally be used for that use case, a bool variable would be the most simple way. In your entry set you would flip a bool to true rather than calling EnterLongLimit. In another set you could check if the bool is true, if so submit the EnterLongLimit as long as that variable is true.


        I look forward to being of further assistance.

        Comment


          #5
          Originally posted by NinjaTrader_Jesse View Post
          Hello Oracletrades,

          ...
          If you used the builder you would need to use logic to maintain the order. That generally would involve using some kind of variable so you can keep a condition open for as long as the variable is true.
          ...

          I look forward to being of further assistance.
          Can you provide some more detail about doing this in strategy builder?

          Comment


            #6
            Hello Gimbalto,

            You can find an example of that concept in the following post: https://ninjatrader.com/support/foru...rategy-builder

            I look forward to being of further assistance.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            62 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            134 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            75 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            45 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            50 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X