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

Catch open order and set SL and TP

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

    Catch open order and set SL and TP

    Hello,
    If I press buttom "Buy Mkt" (without any ATM) I Will have an order without Stop Loss and Take Profit but if I want to catch this open order for set an SL & TP programmaticaly.
    How Can I do this? Do you have any code for example?

    Thanks.

    #2
    Hello razeus,

    Thank you for the post.

    I wanted to confirm, are you referring to specifically observing a manual entry?

    Will the market order be submitted from code as well, or are you trying to manually trade and apply targets?

    If you mean a manual entry and then observing the fill, you can do that using the Addon framework. There is an existing sample which shows observing an account here: https://ninjatrader.com/support/help...ount_class.htm

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello Jesse,
      "
      Will the market order be submitted from code as well, or are you trying to manually trade and apply targets? "
      In this case, I want to have an Strategy for catch the current order from manually trade then the Strategy must set SL and TP.

      Do you have any micro example about how do this? Thanks!

      Comment


        #4
        Hello razeus,


        I want to have an Strategy for catch the current order from manually trade then the Strategy must set SL and TP.
        You should not combine manual trading and a Strategy specifically. What you are asking for should use the Addon framework. You can use a Indicator for this use case if you wanted to do this from a chart or for a certain instrument and not all instruments.

        Strategies should only submit their own orders and use one of the strategy order handling approaches for their orders such as the Managed or Unmanaged approach. Strategies do not include manual trading in their specification so it would not observe a manual order. A strategy by nature will separate its performance from the actual account so it can be analyzed in the various tools. If you want to combine manual trading with logic, that is no longer a strategy but is instead a manual tool similar to ATM strategies.

        The page I previously linked has an example of the code used to observe manual orders, this is what would be required to do what you are asking. You can use this code from an Indicator to observe orders being filled. To submit orders, you would use the Account directly and the Submit method: https://ninjatrader.com/support/help...-us/submit.htm


        If you include this code with a NinjaScript strategy, you will not be able to account for the manual order in the other strategy properties it would have by default like Position, so these two concepts should not be combined. If you are observing manually placed orders, all actions from that point should be using the Addon framework and Account directly.


        I look forward to being of further assistance.


        JesseNinjaTrader Customer Service

        Comment


          #5
          Hello Jesse,
          In this case, if I make a manually trade I can not attach this trade to any strategy? Mi initial idea was: 1) I make a trade, 2) The Strategy catch this trade, Add SL and TP, 3) The Strategy will control this trade with more activities such move SL or TP, add more contracts, etc.

          Regards.

          Comment


            #6
            Hello razeus,

            In this case, if I make a manually trade I can not attach this trade to any strategy?
            No, what I explained in the last post is what you are asking about. I believe the term Strategy is being used loosely here, I will try to make this more clear.

            "Strategy" is not what would be suggested for this concept. A NinjaScript "Strategy" is to trade for you, on its own without manual interaction.

            What you are asking for is to combine manual trading and automated actions which would be a good use case for the addon framework and its account order methods. An Indicator would be used to execute this code in place of a NinjaScript "Strategy".

            Going back to the last post, I explained that you can use an Indicator with the Addon - Account code to observe orders and do other programmatic actions based on the manual entry. If you wanted to apply stops to a manual entry, you can do that with the addon code from the indicator.

            The help guide has a sample of using the account to observe orders which is a good starting point, you can also see the other samples in that section of the help guide. Based on the manual entry, you could observe that and check if the order needs targets or do anything else you wanted at that point.


            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Pattontje, Yesterday, 02:10 PM
            2 responses
            14 views
            0 likes
            Last Post Pattontje  
            Started by flybuzz, 04-21-2024, 04:07 PM
            17 responses
            229 views
            0 likes
            Last Post TradingLoss  
            Started by agclub, 04-21-2024, 08:57 PM
            3 responses
            17 views
            0 likes
            Last Post TradingLoss  
            Started by TradingLoss, 04-21-2024, 04:32 PM
            4 responses
            43 views
            2 likes
            Last Post TradingLoss  
            Started by cre8able, 04-17-2024, 04:16 PM
            6 responses
            56 views
            0 likes
            Last Post cre8able  
            Working...
            X