Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Tracking underlying orders of the ATM strategy?

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

    Tracking underlying orders of the ATM strategy?

    A strategy that I'm trying to test with uses an ATM strategy with a 2-step auto-trail.
    My OnBarUpdate() is occurring on the bar close - important to the strategy.

    Expected Result:
    The first bar closes and entry conditions are met
    The ATM order enters
    The ATM order fills
    The ATM stop or target is filled and the other is cancelled
    At the close of the bar in which the ATM stop or target executed, if entry conditions are met, enter a new ATM order

    Actual Result:
    I run into the limitation that the ATM order won't be recognized as completed until the close of the following bar, which would be a whole bar after the desired second entry.

    I think I might be able to work around this limitation. I'd like to know feedback or other solutions if you have them. I'm not entirely sure how I would implement my solution below.
    • OnBarClose, the ATM strategy enters and it fills
    • The ATM strategy will automatically create 2 orders: my stop and target
    • I need to get these 2 orderIds that were just created
    • I would then "monitor" when the order status of these 2 orders changes
    • If they are filled/cancelled, I can set a bool flag
    • When the bar closes, that bool flag will be read and a new entry would be made.
    It bypasses the need for the ATM strategy functions by watching the underlying orders instead - which may be retrievable with tick updates rather than bar closes.
    Last edited by brettcomardelle93; 08-19-2020, 10:42 AM.

    #2
    Hello brettcomardelle93,

    Thanks for your post.

    ATM strategies do not run on bar data and they run on the active market data. We should also think of the NinjaScript strategy and ATM strategy as separate entities. The NinjaScrtipt strategy will run off of bar data and can use the ATM strategy methods to start and peek/poke an ATM strategy.

    We would suggest creating a multi time frame strategy so you can run additional logic on different data series, or to modify the NinjaScript strategy so it uses Calculate.OnEachTick or OnPriceChnage so your ATM strategy handling logic is called more frequently. You won't necessarily need to wait for a new bar, but you would need to allow enough time for the ATM strategy actions to take place as these are separate strategies.

    If you want to use Calculate.OnBarClose functionality with Calculate.OnEachTick or Calculate.OnPriceChange, you can check BarsAgo 1 references when on IsFirstTickOfBar. Please see below.

    IsFirstTickOfBar - https://ninjatrader.com/support/help...ttickofbar.htm

    If you want to learn more about working with multi time frame strategies, please see here - https://ninjatrader.com/support/help...nstruments.htm

    As the ATM strategy is a separate strategy, you could consider tracking those orders from account level OrderUpdate events. I would suggest the former approach, however.

    Account OrderUpdate - https://ninjatrader.com/support/help...rderupdate.htm

    We look forward to assisting.
    Last edited by NinjaTrader_Jim; 08-19-2020, 11:02 AM.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    54 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    130 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    72 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    44 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X