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

How to have strategy adopt account position

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

    How to have strategy adopt account position

    Hi NT 8 support,

    I am trying to automate my exits. I want a strategy to be enabled when I enter a trade, adopt my account position as I buy/short contracts, and then when exit conditions are met, the strategy exits my account position. I rememeber I used to be able to see "adopt account position" as an option in the strategy builder, but I can't find it now. How do I change this in the code. an example of my starting point in the strategy builder is attached for Long exits. thank you!
    Attached Files

    #2
    Hello Austiner87,

    Thank you for your post.

    Adopt Account Position will only be able to adopt the initial position when the strategy is started - you would not be able to just submit orders manually for entries after the strategy has been started and have the strategy manage them. You'd have to stop and restart the strategy every time you make a new entry.

    You could consider programming an indicator using add-on code that monitors the account for newly opened positions and uses Add-on code to submit an exit order when your conditions for exit are met, however, this would require more advanced programming skill and would not be something that could be done with the Strategy Builder.



    You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our business development follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request.

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hi Kate,

      can you please tell me how to adopt account position when enabled? I can't find that on the strategy builder, do i just change this text in the code? Why was this taken out of the startegy builder?

      thank you!

      Comment


        #4
        Also, can you help me with this code: does this give me my total position size for this account: Thank you

        Convert.ToInt32(TotalAccountPosition.Quantity)

        Comment


          #5
          Hello Austiner87,

          Thank you for your reply.

          The ability to select Adopt Account Position in the Strategy Builder was removed in version 8.0.22.0 because the Strategy Builder was unable to set IsAdoptAccountPositionAware, which must be set to true in order to use it. https://ninjatrader.com/support/help...itionaware.htm

          It would not be possible to create a strategy that can adopt the account position in the Strategy Builder, you would have to unlock your code and manually add the necessary logic.

          Here's a relatively simple example that will adopt an existing account position and add a stop and target for the adopted position that one of my colleagues created. Note that when imported, it can be found in a folder at the top of the list called "AlanStrategies".

          Please let us know if we may be of further assistance to you.
          Attached Files
          Kate W.NinjaTrader Customer Service

          Comment


            #6
            Hello Austiner87,

            Thank you for your reply.

            Originally posted by Austiner87 View Post
            Also, can you help me with this code: does this give me my total position size for this account: Thank you

            Convert.ToInt32(TotalAccountPosition.Quantity)
            No, you'd want to use PositionAccount.Quantity, which will give you the position size for the instrument/account combination on which the strategy is running. PositionsAccount[0].Quantity would be used if you have multiple data series in use within the strategy and wish to get the position for the primary series the strategy is running on.



            Please let us know if we may be of further assistance to you.
            Kate W.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Segwin, 05-07-2018, 02:15 PM
            14 responses
            1,788 views
            0 likes
            Last Post aligator  
            Started by Jimmyk, 01-26-2018, 05:19 AM
            6 responses
            837 views
            0 likes
            Last Post emuns
            by emuns
             
            Started by jxs_xrj, 01-12-2020, 09:49 AM
            6 responses
            3,293 views
            1 like
            Last Post jgualdronc  
            Started by Touch-Ups, Today, 10:36 AM
            0 responses
            13 views
            0 likes
            Last Post Touch-Ups  
            Started by geddyisodin, 04-25-2024, 05:20 AM
            11 responses
            63 views
            0 likes
            Last Post halgo_boulder  
            Working...
            X