Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

best way to simulate ExitLongLimit()

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

    best way to simulate ExitLongLimit()

    I have tried adding an ExitLongLimit() order as an exit order in addition to the simple stop loss and take profit but no order is issued, I think because it would go against the rules of the Managed Approach.
    So I am thinking of alternatives.
    If I understand correctly using ExitLongMIT() causes the same problem, so I thought of checking when the exit condition is met and exit on a simple market order via ExitLong().
    So my question is: what is the (best) way to control when a price level is hit and instantaneously (without waiting for the bar to close) trigger the market order?
    ex: if (Close[0]==High[1]) {ExitLong();}​

    #2
    Hello giulyko00,

    This would be ignored if there is a working Set method order.

    "Methods that generate orders to exit a position will be ignored if:
    •A position is open and an order submitted by a set method (SetStopLoss() for example) is active​"
    NinjaScript > Language Reference > Strategy > Order Methods > Managed Approach​ > Internal Order Handling Rules that Reduce Unwanted Positions

    And it is never recommended to mix set methods with exit methods.

    It may be a better option to just use exit methods.
    The ProfitCasestopTrailExitOrdersExample provides an example of this.


    To trigger an order before the bar closes, use Calculate.OnPriceChange. For historical this will also require enabling TickReplay and implementing 1-tick intra-bar granularity.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      That "ProfitChaseStopTrailExitOrdersExample" looks like the Unmanaged Approach but technically isn't, right?
      So the only way to set multiple types of exit is to deal with the Order object?
      I hoped to come up with something easier.

      Comment


        #4
        Hello giulyko00,

        The ProfitChaseStopTrailExitOrdersExample uses the managed approach with exit order methods. (The unmanaged approach uses SubmitOrderUnmanaged() to submit all orders)

        Using Order variables is an effective way of writing logic that prevents unwanted positions, orders, or order errors. By checking for the variables to be null or in specific OrderStates, we can prevent code from being executed at an unwanted time.

        But your logic is to you. I'm simply suggesting you use exit orders. You don't have to use order variables if your logic works another way.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Ok thank you

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          43 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          124 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          65 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          42 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X