Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Entries per Direction & Unique Entries vs All Entries...

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

    Entries per Direction & Unique Entries vs All Entries...

    Hi everyone, I keep getting confused about what these two options do:

    - entries per direction
    - unique entries

    From my understanding, entries per direction specifies how many entries can be made, for example for a long position, if the strategy triggers a "long" signal. So if entries per direction is 2, I could see two open long trades open.

    The second point about unique entries I don't understand. I was thinking it may be that you can't have a long and a short position open at the same time, say if your strategy triggered long and short signals.

    Would anybody have the patience to explain this to me? Thanks a lot in advance!


    #2
    Hello Oracletrades,

    Thank you for your post.

    Entries per direction you're pretty much dead on. If you have entries per direction set to 2, you can take up to 2 entries simultaneously in the same direction before NinjaTrader will ignore further orders. So, if you have one long entry, and you take another, until you sell an entry you cannot enter again.

    Unique Positions is part of a property called Entry Handling, and that has to do with Signal Names. Basically, you can give unique names to your orders, and if you switch this to Unique Positions while your orders have unique names and your Entries Per Direction is 2, each of your uniquely named orders would be able to enter up to 2x each in a direction. So if I had 4 different uniquely named entries, I could have up to 8 entries with Unique Positions, but only 2 if I have it set to all entries.

    From our help guide:
    EntryHandling.AllEntries NinjaScript will process all order entry methods until the maximum allowable entries set by the EntriesPerDirection property is reached while in an open position
    EntryHandling.UniqueEntries NinjaScript will process order entry methods until the maximum allowable entries set by the EntriesPerDirection property per each uniquely named entry
    There's a good example on this page from our help guide that illustrates the signal names:



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

    Comment


      #3
      Kate is it possible to have the entries per direction set for different timeframes?

      I have a strategy that trades candlestick patterns based on the 15 30 and 60 minute charts. I would like to have only 1 entry per timeframe at any one time. So a max of 3 entries.

      Is this possible?

      Thank you,

      Nick

      Comment


        #4
        Hey Kate-

        Just wondering if you had a chance to review my question. Thank you,

        Nick

        Comment


          #5
          Hello njmeyer713,

          Thank you for your reply.

          Looks like my reply got eaten by the forum somehow.

          For something like you describe, you would want to use Unique Entries for your Entry Handling setting, with Entries Per Direction set to 1, and then you would want to give each of the three entries unique Signal Names:



          This will allow up to 1 of each uniquely named entries per direction.

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

          Comment


            #6
            Kate-

            Thank you for the reply. Let me elaborate a little, on each of the 3 different timeframes there are 4 different possible entries, each of them uniquely named. FifteenLongentry1, FifteenLongentry2, Fifteenshortentry1, Fifteenshortentry2. Same for the 30 minute and 60 minute timeframes. So 12 total unique named entries.

            As I understand it, if I set my entries per direction at 1 and set entry handling at unique entries, then I could potentially in 12 trades at one time. 4 unique entry names per each of the 3 different timeframes. Correct?

            What I want to do is only have a maximum of 1 trade per timeframe for a maximum total of 3 trades at any one time.

            Any thoughts on how to accomplish this?

            Thank you,

            Nick

            Comment


              #7
              Hello njmeyer713,

              Thank you for your note.

              What I would suggest is having a bool like OkToTradePrimary, OkToTrade15, OkToTrade30, OkToTrade60. Set these to true initially, and check whether this is true or not in the conditions for entry. If it is, submit the triggered order and set the bool to False. When the corresponding exit order is seen, set the correct bool back to true to allow another entry. With this, you could leave Entries Per Direction set to 1 and Unique entries to allow one trade per time frame at a time.

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

              Comment


                #8
                Thank you Kate,

                That seems to be working for me.

                My next question is this. Is there is way to tie Position.Quantity to a specific timeframe or data series?

                My exit logic is based on quantities. At the most basic level, I trade 2 contracts, scalp one and let the other go as a runner. So my code goes something like this, if quantity =2 Do this. If quantity =1 Do this.

                However, when I am trading on the three different time frames. That logic gets messed up because I could have up to 6 quantities.

                Thoughts on a solution to this?

                Does my question make sense?

                Thank you,

                Nick

                Comment


                  #9
                  Hello njmeyer713,

                  Thank you for your reply.

                  What you'd have to do in this case is to have basically a counter variable for each series and keep track of the current quantity submitted on that time frame there. You'd also need to be monitoring in OnExecutionUpdate or OnOrderUpdate for the exit orders to be filled and then decrement the counter when that occurs. So you'd keep track of each "separate position" separately without relying on NinjaTrader's internally calculated position, which would be the overall strategy position.

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

                  Comment


                    #10
                    Kate-

                    Thank you for the response. I was working on a solution when you posted how you would do it via the OnExecutionUpdate & OnOrderUpdate. Before I give that a try could you shed some light on the following.

                    For background. Here is my data series:

                    Code:
                     else if (State == State.Configure)
                    {
                    AddDataSeries(Data.BarsPeriodType.Minute, 30);
                    AddDataSeries(Data.BarsPeriodType.Minute, 60);
                    AddDataSeries(Data.BarsPeriodType.Minute, 240);
                    AddDataSeries(Data.BarsPeriodType.Day, 1);
                    AddDataSeries(Data.BarsPeriodType.Tick, 1);
                    
                    }
                    I'm thinking I might be misinterpreting the Positions array in the following help guide page



                    What I thought I could do is use this to check the position size for the 30 minute data series.

                    Code:
                    if (Position.MarketPosition == MarketPosition.Short
                    && (GetCurrentBid(0) + (ScalpDistance * TickSize)) > Position.AveragePrice
                    && (Positions[1].Quantity ==2))
                    
                    {
                    ThirtyDoubleStop = ExitShortStopMarket(0, true, Convert.ToInt32(Position.Quantity), Highs[1][1], @"30DoubleStop", @"30Short1-2D");
                    }
                    Would the above line of Positions[1].Quantity ==2 work or not?

                    When I run into an issue is when I have 2 contracts bought based on the 30 minute timeframe trigger and 2 bought based on the 60 minute timeframe at the same time. So total I have 4 contracts. I thought by using the above line colored red would check the quantity bought based on the 30 minute timeframe.

                    Does it make sense what I am trying to do? I looks like if it were two different instruments this would work?

                    Let me know your thoughts,

                    Thank you,

                    Nick

                    Comment


                      #11
                      Hello njmeyer713,

                      Thank you for your reply.

                      The approach you propose would only work if each added data series was of a different instrument. When it's the same instrument, the position would only be accessible from the primary data series and would represent the overall position on that instrument.

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

                      Comment


                        #12
                        Hi Kate,


                        I'm coding my strategy via NinjaScript. I have 6 entries. I typically only want one entry per direction. However, only on Mondays, between 6:00 am and 6:30 am, I'd like to enter 2 trades per direction, from any of my entries. Is this possible to code? If so, can you please give guidance on how to do this? Thank you.​

                        Comment


                          #13
                          Hello Ttrade12,

                          You would need to use logic to do that. The first step would be making a time condition for the time where you wanted more than one entry so you could make a specific condition for that day. Then you would need to come up with an entry condition that could become true more than once and use it within that time condition. To control the total quantity you can use the positions quantity to prevent more entries than a certain amount.
                          JesseNinjaTrader Customer Service

                          Comment


                            #14
                            Hi Jesse,

                            Thanks for your response. I did what you suggested, but it didn't work. I'm unsure how to control the total quantity by using the positions quantity.

                            This is what I did...

                            - The Entries per Direction is set to 1, All Entries - I was unsure what to do with this setting, so I left it alone
                            - I used a simple MAs strategy to enter and exit the longs and shorts so I can enter and exit a lot of trades
                            - I changed my time from 6:00a and 6:30a to 10:30a to give myself more time to enter
                            - For my other entries I enter 6 contracts.

                            - My thinking is:
                            On Monday, from 6:00a to 10:30a, if I'm in a Long and if the current position size is 6 contracts, and the BOP indicator is > .05, then Enter a Long with 10 contracts (that's the 'Enter_Mondays' amount for contracts) - this would be an additional 10 contracts added to the position and now I'd be in 16 contracts. However, the strategy only entered me in 6 contracts for each trade it took even when my above Monday criteria was met.

                            - Then, I changed the Entries per Direction to 2, All entries - and I ended up entering in 6 contracts 2x for other entries, but I did still did not enter the additional 10 contracts when my Monday criteria was met.

                            -- Below is the code I used. I don't think I'm using the positions quantity correctly. Can you tell me where I'm going wrong? How exactly can I use the positions quantity to control the total quantity and prevent more entries than a certain amount? Your help is appreciated.

                            if ((Times[0][0].DayOfWeek == DayOfWeek.Monday)
                            && (Times[0][0].TimeOfDay > new TimeSpan(6, 0, 0))
                            && (Times[0][0].TimeOfDay < new TimeSpan(10, 30, 0))
                            && (Position.MarketPosition == MarketPosition.Long)
                            && (BOP1[0] > 0.05)
                            && (Position.Quantity == 6))
                            {
                            EnterLong(Convert.ToInt32(Enter_Mondays), @"Monday 2nd Entry");
                            }

                            Comment


                              #15
                              Hello Ttrade12,

                              To place more than one entry in the same direction you would need to increase the number for entries per direction to accommodate for the amount you wanted. Beyond that your entry condition would need to be able to become true more than once or you would need multiple entry conditions that end up equaling the total number of entries that you wanted.

                              In the condition you posted you are checking if the quantity is 6 so that condition will only be true once when the position quantity is 6, if the quantity is not 6 it wont be true. If your other entries entered twice that means your other condition was true twice so you would have to add to that condition so its true only 1 time leaving the total quantity at 6, that would allow the condition you posted to work.

                              JesseNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by MatthewLesko, 05-21-2021, 09:37 PM
                              4 responses
                              164 views
                              0 likes
                              Last Post Mahmad1323  
                              Started by samish18, Today, 03:02 PM
                              3 responses
                              15 views
                              0 likes
                              Last Post bltdavid  
                              Started by Jakub, Today, 11:06 AM
                              1 response
                              16 views
                              0 likes
                              Last Post NinjaTrader_LuisH  
                              Started by samish18, Today, 03:50 AM
                              10 responses
                              19 views
                              0 likes
                              Last Post samish18  
                              Started by Mestor, 06-03-2018, 10:09 AM
                              16 responses
                              2,872 views
                              0 likes
                              Last Post myaha1000  
                              Working...
                              X