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

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)


        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


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

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by XXtrader, Yesterday, 11:30 PM
            2 responses
            11 views
            0 likes
            Last Post XXtrader  
            Started by Waxavi, Today, 02:10 AM
            0 responses
            6 views
            0 likes
            Last Post Waxavi
            by Waxavi
             
            Started by TradeForge, Today, 02:09 AM
            0 responses
            11 views
            0 likes
            Last Post TradeForge  
            Started by Waxavi, Today, 02:00 AM
            0 responses
            2 views
            0 likes
            Last Post Waxavi
            by Waxavi
             
            Started by elirion, Today, 01:36 AM
            0 responses
            7 views
            0 likes
            Last Post elirion
            by elirion
             
            Working...
            X