Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by andrewtrades, Today, 04:57 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by chbruno, Today, 04:10 PM
    0 responses
    6 views
    0 likes
    Last Post chbruno
    by chbruno
     
    Started by josh18955, 03-25-2023, 11:16 AM
    6 responses
    436 views
    0 likes
    Last Post Delerium  
    Started by FAQtrader, Today, 03:35 PM
    0 responses
    7 views
    0 likes
    Last Post FAQtrader  
    Started by rocketman7, Today, 09:41 AM
    5 responses
    19 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X