Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Confused by the strategy documentation about managed entry/exit orders.

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

    Confused by the strategy documentation about managed entry/exit orders.

    I've decided I definitely want to use the managed approach to strategy development. But there is some wordage in the NT8 language reference that to me is conflicting and therefore I need clarification. In the page describing the managed approach I see the following text:

    By default, orders submitted via Entry() and Exit() methods automatically cancel at the end of a bar if not re-submitted

    But within the section on "Order submission for entry and exit methods - basic operation", I see the following statement:

    By default, orders are kept alive, provided they are re-submitted on each call of the OnBarUpdate() method. If an order is not re-submitted, it is then canceled.

    To me these two statements are at odds with each other. I prefer to run my charts with day bars. If I'm running a strategy on a chart, then I believe that the end of a bar means at the end of the day, even if I set "Calculate = Calculate.OnPriceChange or OnEachTick. Is that correct or am I changing the bar type when I use either of those Calculate options? If I'm correct, I should be able to use IsFirstTickOfBar() within OnBarUpdate() to know when I've entered a new bar. Am I correct or off base? Are those two statements from the reference equivalent or misleading? Because I truly thought that with a day chart I can enter OnBarUpdate() throughout the day and potentially make modifications to my orders as needed. If not, I will have to rethink how I do things.

    #2
    Hello dweems,

    They are not. They are just said in different ways.

    'automatically cancel at the end of a bar if not re-submitted'
    If not re-submitted it is automatically cancelled. if re-submitted it is kept alive.

    'orders are kept alive, provided they are re-submitted on each call of the OnBarUpdate() method. If an order is not re-submitted, it is then canceled.'
    If re-submitted it is kept alive, if not resubmitted it is cancelled.

    So re-submit to keep the order alive, is what both are saying.

    That said, if the script is unlocked (and not locked in the strategy builder), you can use the overload signature with IsLiveUntilCancelled as true and it will not be automatically cancelled.
    EnterLongLimit(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double limitPrice, string signalName)
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chelsea B.. Thanks for your reply. I'm still confused. Where does Calculate.OnEachTick or OnPriceChange come into play along with TimeInForce? If TimeInForce is set to GTC, then refreshing the order request shouldn't have to be performed ever. Or if TImeInForce is set to Day, then you shouldn't have to resubmit until a new day. Isn't this correct? Also, I may be making one assumption that is incorrect and please tell me if I right or wrong. If I'm running a strategy on a chart with day bars, then end of bar isn't at each entry into OnBarUpdate() unless Calculate is set to OnBarClose? Otherwise you will have multiple entries into OnBarUpdate() for one bar until you hit the boolean IsFirstTickOfBar(). That's the way I understand it. But the second quote I provided says to me that irrespective of TimeInForce, you have to resubmit every time in OnBarUpdate() unless, as you say, you use the overloaded version of the Enter command that allows you to specify isLiveUntilCancelled. Another thought -- if you have to resubmit orders on every entry into OnBarUpdate(), does CancelOrder() only work if you use the overloaded versions of Enter command, since, as it says, every order is automatically canceled upon entry into OnBarUpdate()?

      Comment


        #4
        Hello dweems,

        Calculate is not related to Time In Force.

        Calculate controls when OnBarUpdate() is updated and evaluates your logic. This can evaluate when the bar closes, when the price changes, or when a tick is received.

        Time In Force is a code that is sent with an order to the broker, telling the broker when you want the order to automatically cancel on the broker servers. (This would even mean if the strategy was disabled and the order was still working on the brokerage servers.) This could be expire at end of session Day, or remain working until cancelled GTC.

        It would not matter what the TIF setting is, NinjaTrader is still going to automatically submit an order cancellation for any managed approach order that is not using isLiveUntilCancelled as true and does not fill on the submission bar.

        A strategy that is using day bars, would be submitting orders at the open of the next session. An order with TIF DAY would expire at the end of the session. If it were still working at the start of the next session when the current bar closes and the new bar opens NinjaTrader would try and cancel it, but it would already have expired.Hello dweems,

        Where you have inquired:
        " If I'm running a strategy on a chart with day bars, then end of bar isn't at each entry into OnBarUpdate() unless Calculate is set to OnBarClose?"
        Unfortunately, I am not understanding what this means.

        End of bar isn't at each entry?

        Do you mean an entry order is being submitted before the bar closes when using Calculate.OnPriceChange? Yes sure, if you logic allows for it.

        "Otherwise you will have multiple entries into OnBarUpdate() for one bar until you hit the boolean IsFirstTickOfBar()."

        You can indeed have multiple entries on the same bar if you logic is allowing for it. Your logic could also place an order, set a bool, and not place another order until the bar has closed and the bool is reset.

        "irrespective of TimeInForce, you have to resubmit every time in OnBarUpdate() unless, as you say, you use the overloaded version of the Enter command that allows you to specify isLiveUntilCancelled."

        Correct, no matter the TimeInForce, orders that are not using isLiveUntilCancelled as true will still be cancelled if not filled on the submission bar and not resubmitted on the new bar.

        The short of it is, if you want to keep an order alive, resubmit it on each new bar or use isLiveUntilCancelled as true. That's all there is to it.

        "if you have to resubmit orders on every entry into OnBarUpdate(), does CancelOrder() only work if you use the overloaded versions of Enter command"

        You can use CancelOrder() with any working order, no matter what overload was used to submit it.

        The Strategy Builder cannot call CancelOrder(). So in the strategy builder if you want to cancel order, just don't resubmit it and wait for the bar to close and it will cancel itself automatically.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        62 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        134 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        75 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        50 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X