Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Two strategies, one cancels another

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

    Two strategies, one cancels another

    Hello,

    My strategy is going to work like this:
    When certain requirements are met, two pending orders are placed: buy stop limit and sell stop limit. If I understand correctly, I cannot achieve it in one strategy - I have to code two.
    The next feature I'd like to have is to cancel one pending order when another is filled. Is it possible?
    I tried to search for global variables so that my strategies could communicate - I found nothing. I though that maybe OnExecution() could help - but apparently this is not how it works (I guess it works only for executions made by strategy which contains OnExecution() ).
    Any advice?

    #2
    alkamid, correct with this approach you would run into the Internal Order Handling Rules (http://www.ninjatrader-support.com/H...verview36.html bottom section here).

    NinjaTrader 7 will provide more flexibilty here with offering a totally unmanaged approach to order handling also -



    New Unmanaged Order Submission
    In 6.5 some users were burdened with our "Internal Order Handling" rules. We have introduced unmanaged order submission which bypasses the convenience of our order handling layer. This lower level of programming allows you to do what you want relative to order submission/management without any limitations other than any imposed by your broker. There are only three methods, SubmitOrder(), ChangeOrder() and CancelOrder(). You then get the flexibility of managing your orders how you see fit and optionally handling rejections.


    OCO handling is possible per default when using the SetProfitTarget / SetStopLoss methods...for all other Exit methods you would have to supply the OCO logic in your code.

    To learn how to work with the advanced order handling methods we offer, please check into this sample -

    The OnOrderUpdate() and OnExecution() methods are reserved for experienced programmers. Instead of using Set() methods to submit stop-loss and profit target orders, you can submit and update them manually through the use of IOrder and IExecution objects in the OnOrderUpdate() and OnExecution() methods. The OnOrderUpdate()

    Comment


      #3
      Thank you for your reply. However, I suspect OnExecution() and OnOrderUpdate() to work only if our strategy is generating a change or execution. If so, the sample you provided is not what I'm looking for. I need my strategy to "detect" external executions, manual or made by another strategy.

      Comment


        #4
        Sorry missed this in your first post, cross strategy communication is unforuntately not supported. Users worked around this for example with txt files or DLL's to provide global variables.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        656 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        371 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        109 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        574 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        579 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X