• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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 Mike Winfrey, Today, 11:27 AM
            0 responses
            4 views
            0 likes
            Last Post Mike Winfrey  
            Started by swcooke, Yesterday, 07:35 PM
            1 response
            19 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by brownsfan019, Today, 10:45 AM
            0 responses
            7 views
            0 likes
            Last Post brownsfan019  
            Started by brownsfan019, Today, 10:41 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_ChrisL  
            Started by bchip, Today, 09:25 AM
            1 response
            16 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X