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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        64 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        35 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        59 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        62 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        51 views
        0 likes
        Last Post CarlTrading  
        Working...
        X