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

Any tricks to use EnterLimit both long and short?

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

    Any tricks to use EnterLimit both long and short?

    Per "Internal Order Handling Rules that Reduce Unwanted Positions" it appears to be impossible to have EnterShortLimit orders active while EnterLongLimit orders (or their associated stop or target orders) are open.

    Essentially, if we want to simulate a full strategy it looks like we have to first run the long side, and then run the short side.

    Is there any way around this kludge that would allow both long and short orders to cohabitate within a strategy on an instrument in simulation?

    #2
    Hello,

    Thank you for the question.

    I would like to ask, in the strategy you are using have you called both of the long and short order methods in the same OnBarUpdate call?

    You can have both long and short entry logic in a strategy and also when using the EnterLong or EnterShort methods. they will exit the position and enter into the opposite direction for you when using the managed approach but this does mean that these would need to be called on two OnbarUpdate calls.

    You can seperate logic by checking the current position, there is an example here:


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      I want to be able to call them both in the same OnBarUpdate, and have them active at the same time.

      E.g., at the beginning of the day I would like to EnterLongLimit to buy if the price dips below a certain level, and EnterShortLimit to short if the price reaches another target level. And I don't care even if they both trigger in the same bar.

      So one practical way of looking at it is that I have two separate order books I'm handling for a single instrument, and I'd like to do it within the same strategy and simulation.

      Comment


        #4
        Hello,

        For this you would need to use unmanaged approach.

        The managed approach has rules that will prevent you from doing what you are trying to do, instead you could look into the unmanaged approach which has no set rules but is quite a bit more complicated. This is considered an advanced programmer task because you have to monitor everything yourself. There is more information here:



        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hi Jesse
          I am trying to do similar thing.

          After a 1hr session opens, i want nt to put two limit orders above and below the OPEN of this 1 hr session. i understand that it is possible only using unmanaged approach.

          i'm trying to put these limit orders 'x' number of ticks above and below (equidistant) immediately after the opening price of current session is known.

          please see this

          Code:
           LongOrder = SubmitOrder(0, OrderAction.Buy, OrderType.Limit, 1, 0 , 0, "", "Long Limit");
          ShortOrder = SubmitOrder(0, OrderAction.SellShort, OrderType.Limit, 1, 0 , 0, "", "Short Limit");
          i am not able to understand where these limit long and limit sell short orders are getting filled because I did NOT mention the limit price.

          Also I dont know what is the syntax to put these both orders above and below 'x' no. of ticks relative to the current session's opening price.

          please tell me how to do this.
          Originally posted by NinjaTrader_Jesse View Post
          Hello,

          For this you would need to use unmanaged approach.

          The managed approach has rules that will prevent you from doing what you are trying to do, instead you could look into the unmanaged approach which has no set rules but is quite a bit more complicated. This is considered an advanced programmer task because you have to monitor everything yourself. There is more information here:



          I look forward to being of further assistance.

          Comment


            #6
            Hello,

            Thank you for the question.

            For unmanaged Limit orders, you would need to use the SubmitOrder as you have but you do need to specify a price for the limit to work.

            Instead of specifying 0 in the Limit overload, you would use a price, if you wanted a tick associated price it would look like this:

            Code:
            Open[0] + 4 * TickSize
            This would be the open of the current bar plus 4 ticks, you could replace this statement with your current logic to get the opening price, if you do not currently have logic for this, you could look into using the CurrentDayOHL indicator to get the Open value for Today or PriorDayOHLC indicator for yesterdays values.

            Here is your long order using this:

            Code:
            LongOrder = SubmitOrder(0, OrderAction.Buy, OrderType.Limit, 1, Open[0] + 4 * TickSize , 0, "", "Long Limit");
            I look forward to being of further assistance,
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Mizzouman1, Today, 07:35 AM
            0 responses
            0 views
            0 likes
            Last Post Mizzouman1  
            Started by i019945nj, 12-14-2023, 06:41 AM
            6 responses
            65 views
            0 likes
            Last Post i019945nj  
            Started by aa731, Today, 02:54 AM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by BarzTrading, Today, 07:25 AM
            0 responses
            3 views
            0 likes
            Last Post BarzTrading  
            Started by ruudawakening, Today, 12:58 AM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X