Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Setting Stop and Limit orders with Calculate.OnPriceChange vs Calculate.OnBarClose

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

    Setting Stop and Limit orders with Calculate.OnPriceChange vs Calculate.OnBarClose

    Hello,
    I have a strategy that, when entering a position, should also place stop and limit orders. The stop and limit orders are being placed, but not until the current bar finishes and the next one starts.

    I have `Calculate = Calculate.OnPriceChange;` in my `OnStateChange()` method, so I expect that the stop and limit orders should be placed as soon as the price changes (in the current bar).
    (I also see "OnPriceChange" selected in the Strategy popup window if I view that.)

    I'm using "separate logic" to place the initial order (and set a flag), and then on subsequent `OnBarUpdate()` calls, I check to see if the flag is set, and if so, use `ExitLongStopMarket()`, `ExitShortStopMarket()`, `ExitLongLimit()` and `ExitShortLimit()` methods to set the closing orders.

    So, I'm confused as to why the stop/limit orders aren't being set on the very next bar update after the order is placed.
    Any hints to point me in the right direction?
    Thanks!

    #2
    Hello GregX999,

    If you would like the orders submitted immediately when the entry fills, submit these from OnExecutionUpdate().

    Below is a link to an example (ProfitChaseStopTrailExitOrdersExample).
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Ah! That did the trick! Thanks!

      (I really wish Playback mode worked the same as Live/Simulation mode. It's so annoying to get everything working perfectly in Playback and then having bugs/errors when trying to switch to Simulation. I had others besides this one, but was able to find the answers. This was the only one I needed to ask about here.)

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      50 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      126 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      69 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