Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EnterLong with barsInProgressIndex issue

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

    EnterLong with barsInProgressIndex issue

    I have a strategy that trades several stocks at the same time.
    Each stock # of shares could increase or decrease over time.
    I am using :

    To add shares:
    EnterLong(int barsInProgressIndex, int quantity, string signalName)


    to reduce shares:
    ExitLong(int barsInProgressIndex, int quantity, string signalName, string fromEntrySignal)

    I was using unique signalNames for entries of the same stock but that doesn't working for exits.
    Can I use the same signalName for all entries for the same stock? so that I can exit with the same entry signal?

    Would this work?

    #2
    Hello afshinmoshrefi,

    Thank you for writing in.

    When you say that the number of stock shares could increase or decrease, are you referring to an existing open position or new trades?

    Would you provide the exact statements for your Enter and Exit methods rather than the syntax form? For example, EnterLong(0, 1, “Buy HOG”); etc.

    I look forward to your reply.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Thanks Alan. Here is an example of what would happen:

      BarsInProgress for MSFT = 2
      BarsInProgress for AAPL = 3

      Strategy buy 10 shares of MSFT and 20 shares of AAPL
      EnterLong(2, 10, “Buy MSFT”);
      EnterLong(3, 20, "Buy AAPL");

      The next day strategy will buy 20 more shares of MSFT and Buy 20 more shares of AAPL
      EnterLong(2, 20, “Buy MSFT”);
      EnterLong(3, 20, "Buy AAPL");

      now there are 30 share of MSFT and 40 shares of AAPL open

      on the third day strategy will sell 28 shares of MSFT and 18 shares of AAPL

      ExitLong(2, 28,"Sell MSFT", "Buy MSFT");
      ExitLong(3,18, "Sell AAPL", "Buy AAPL");

      in the above both EnterLong for MSFT have the same signal name "Buy MSFT";

      Question is:
      Is it valid to use the same buy signal name for buying the same stock multiple times?

      Comment


        #4
        Hello afshinmoshrefi,

        It would be suggested that the second round of entries would carry a different signal name, for example,

        Code:
        EnterLong(2, 20, “Buy MSFTTwo”);
        EnterLong(3, 20, "Buy AAPLTwo");
        For your exit calls you would then want to break up your quantities, so that your exit long for MSFT of 28 shares becomes,

        Code:
        ExitLong(2, 20,"Sell MSFT", "Buy MSFT");
        ExitLong(2, 8,"Sell MSFTTwo", "Buy MSFTTwo ");
        And since your opening trade for AAPL was 20, the call below would leave you with 2 shares as part of this AAPL position, you would not need to break it up.

        Code:
        ExitLong(3,18, "Sell AAPL", "Buy AAPL");
        You could also see Scaling out of a position reference example,
        http://ninjatrader.com/support/forum...ead.php?t=3751

        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          That will make my strategy impossible in NinjaTrader 8. If there is no workaround this is a huge limitation of NT8.
          for example I may have 107 shares of long AAPL while the entry signals spanned across 10+ different enterLong trades. How can I track the entry signals and number of shares for every share that is outstanding. In the next trade I may want to exit 43 shares, which entry signals would I use?

          The way I need to process partial exit requires that I specify exitLong with barsInProgressIndex but without fromEntrySignal; or to be able to specify all orders for the same stock EnterLong with the same exact EntrySignal.
          Last edited by afshinmoshrefi; 03-15-2017, 07:06 AM. Reason: additional information

          Comment


            #6
            Now I understand I have to switch to Unmanaged approach.

            Comment


              #7
              Hello afshinmoshrefi,

              Yes, the Unmanaged Approach would be better suited for what you are looking to do.

              Please let us know if you need further assistance.
              Alan P.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by bowling, Today, 06:16 AM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_ShawnB  
              Started by systemtrader4, Today, 01:54 AM
              1 response
              16 views
              0 likes
              Last Post NinjaTrader_ShawnB  
              Started by Futurestrader00, Today, 01:54 AM
              1 response
              25 views
              0 likes
              Last Post NinjaTrader_ShawnB  
              Started by timmbbo, Today, 01:40 AM
              2 responses
              10 views
              0 likes
              Last Post NT-Roland  
              Started by BGWTEX, Yesterday, 07:20 PM
              0 responses
              7 views
              0 likes
              Last Post BGWTEX
              by BGWTEX
               
              Working...
              X