Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ExitLong and then EnterShort

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

    ExitLong and then EnterShort

    Hi,

    I'm having an issue exiting a long position and then entering a short position within the same bar (a few lines lower in code). The issue is after calling ExitLong(), my Position.MarketPosition is Long and my Position.Quantity is 1 (from the long entry).

    After calling ExitLong(), I subsequently call EnterShort() but first check to see if Position is flat. My EnterShort() never gets called because at the time of the short entry, the position is long (even after ExitLong() has been called and executed).

    What's going on? I'm assuming its an issue with order handling and perhaps I am not using the appropriate order handling properties in the Initialize method of the strategy.

    Thanks!

    #2
    Jon, this would be expected if you run your strategy with CalculateOnBarClose set to true - you could work with the advanced order handling to check if your ExitLong() filled and then issue your reverse.

    Comment


      #3
      Bertrand,

      Yes, COBC is true on this strategy. How would I work with the Advanced order handling to check if my ExitLong has been filled? Why is this an issue when COBC is true? This seems like a pretty straightforward request.



      Originally posted by NinjaTrader_Bertrand View Post
      Jon, this would be expected if you run your strategy with CalculateOnBarClose set to true - you could work with the advanced order handling to check if your ExitLong() filled and then issue your reverse.

      http://www.ninjatrader-support.com/H...V6/IOrder.html

      Comment


        #4
        Jon, with COBC true all calcs are updated at the end of the bar, thus you can't work out the intrabar exit with this approach. If you for example monitor OnExecution() for the fill status of your ExitLong() IOrder you could reverse intrabar as you can send the EnterShort not tied to your OnBarUpdate() calls then (which are on bar close with your setting).

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        639 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        366 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        107 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        569 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        572 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X