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.
    JesseNinjaTrader Customer Service

    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)
        https://ninjatrader.com/support/help...enterlonglimit

        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.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by varsha, Today, 06:33 PM
        0 responses
        9 views
        0 likes
        Last Post varsha
        by varsha
         
        Started by NtFan, Today, 04:12 PM
        1 response
        8 views
        0 likes
        Last Post NtFan
        by NtFan
         
        Started by futurenow, Today, 01:44 PM
        2 responses
        38 views
        0 likes
        Last Post voltation  
        Started by Gerik, Today, 12:44 PM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_Jim  
        Started by autogenix, Today, 01:01 PM
        3 responses
        20 views
        0 likes
        Last Post NinjaTrader_Emily  
        Working...
        X