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 charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        59 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        143 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        161 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        97 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        283 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X