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

Start Strategy to sell my existing stocks in my account

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

    Start Strategy to sell my existing stocks in my account

    I am asking this question because "Wait Until Flat" start behavior setting doesn't work for me as my Strategy is also using Level 2 data which isn't stored for historical sync. So I have to find a way to start with my account having purchased stocks already.

    So I need to sell these existing stocks first immediately after Strategy starts.
    When Strategy starts, I should be able to let Strategy know number of shares I have. For this purpose, what calls I can "sell" these stocks? ExitLong() or ExitLongLimit() doesn't seem to work as it must be used after EnterLong() or EnterLongLimit().

    Thanks.


    #2
    Hello localappleseed,

    The Strategy Position cannot be set in the code or manually and comes from the orders placed by the strategy only.
    NinjaScript Strategy methods can only close strategy positions.


    If the account has a position, this can be adopted with IsAdoptAccountPositionAware.



    You can use the Addon approach to change an account position outside of the strategy position.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Your answer really helps. Thanks a lot.

      Comment


        #4
        Through your leads, it looks like I can use SubmitOrderUnmanaged() to sell my existing stocks in my account when Strategy starts?

        if (Close[0] > SMA(20)[0] && entryOrder == null) // or whatever conditions
        SubmitOrderUnmanaged( 0, OrderAction.Sell, OrderType.Market, 1, 0, 0, "", "Enter Sell");

        Since this is under unmanaged setting, I may have to apply a separate Strategy to sell this existing stocks before I switch to managed Strategy?

        IsUnmanaged = true;
        Last edited by localappleseed; 09-22-2020, 03:24 PM.

        Comment


          #5
          Hello localappleseed,

          You can use SubmitOrderUnmanaged to submit an order without being in relation to a position. As a heads up, the account and strategy could be out of sync.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Thanks again for your very helpful tips.
            I am using these options at the beginning of Strategy for the purpose to flat my account (or sell my bought stocks). After my existing stocks are sold, I will switch to use regular managed Strategy to continue.

            In your early reply, you provided alternative option AddOn to sell my pre-existing stocks outside of my Strategy. What's the main differences between using SubmitOrderUnmanaged and this AddOn?

            AddOn:
            sellOrder = myAccount.CreateOrder(IBM, OrderAction.Sell, OrderType.Limit, OrderEntry.Automated, TimeInForce.Day, 1, 0, 1400, "myOrder", "sellOrder", Core.Globals.MaxDate, null);
            myAccount.Submit(new[] { sellOrder });


            SubmitOrderUnmanaged():
            I can call this SubmitOrderUnmanaged() in OnBarUpdate(), also OnOrderUpdate() can detect this order status change. So it looks like unmanaged order can be "managed" in the same place like OnOrderUpdate(). Is it a better option?
            Last edited by localappleseed; 09-22-2020, 09:29 PM.

            Comment


              #7
              Hello localappleseed,

              Place an order to the account would be outside of the strategy position.

              Placing orders with NinjaStrategy methods would affect the strategy position.
              Chelsea B.NinjaTrader 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