Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exit & Entry orders in the same bar

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

    Exit & Entry orders in the same bar

    Hi!,

    I've this code:

    if (BarsInProgress == 0 ) {
    if (Position.MarketPosition != MarketPosition.Flat) {
    if (Position.MarketPosition == MarketPosition.Long) {
    ExitLong(1, contratos, "OutUp_f", "Up");
    }
    if (Position.MarketPosition == MarketPosition.Short) {
    ExitShort(1, contratos, "OutDown_f", "Down");
    }
    }

    if (Close[0] > Open[0])
    orderlaunch = EnterShortStop(1, true, contratos, Low[0], "Down");
    if (Close[0] < Open[0])
    orderlaunch = EnterLongStop(1, true, contratos, High[0], "Up");
    }

    ... next at BarsInProgress == 1 it's possible to get out if reaches some condition, if not, like you can see in the above code exits at beginning of the next Bar (BarsInProgress == 0).

    Ok, then the problem I've found (or perhaps is the expected behavior) is that if it closes at next bar (BarsInProgress == 0) and also in the same bar the stop price is reached never launches an order into the market.

    Is this correct?

    I've tried also setting EntriesPerDirection > 1

    Thank you

    #2
    joanNT,

    To understand your orders I suggest you use TraceOrders = true so you can see if orders were ever submitted and if they were why they were ignored/rejected.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thanks Josh,

      but I'm doing backtest and I can't see what happens with orders even with TraceOrders = True, cause the information in the output window is not enough, but I really think two orders in the same bar (one exit and one entry stop) it's not possible, which is your opinion?

      Do you ever saw this? or could be cause of backtesting?

      Comment


        #4
        Hard to say. You will need to use TraceOrders to determine the behavior you are truly seeing. If you want additional tracking you can add prints from OnOrderUpdate() and see the state changes of the orders too.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Ok, I'll try tomorrow.

          Thanks

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          597 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          343 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          556 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          555 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X