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

Close Position - Bars Since Entry

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

    Close Position - Bars Since Entry

    I have a strategy that takes a second entry after 30 bars.

    The strategy has a time stop of 65 bars.

    The above exit works fine when there is only one entry but when there is a second entry the 65 bar stop is then referenced off of the second entry. In this case both the first and second entries are closed after 65 bars from the second entry.

    I would like both entries to close 65 bars after their respective entries.


    I tried making a second entry with a different name and setting BarsSinceEntry > 30 from the first entry.
    That did not work, in this case since both entries fire at the same time since they have the same entry logic.


    Any advice is appreciated.



    #2
    Hello sdauteuil,

    Thanks for your post.

    I would expect that using signal names would allow you to effectively use the BarsSinceEntryExecution() to operate as you intended on the two different orders. Please post an example of your code that shows the exit conditions and exit orders used in each case. Also, please advise if you are using a multi series/time frame script.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Here is the first strategy with one named entry, it is in the strategy builder. The stock symbol I used from analyzing was ALL

      The 30 bars between entries work but when a second trade is entry the BarsSinceEntry stop takes its reference from the second entry.

      Again my goal is 30 bars between entry and 65 bar Time stop from their respective entries.

      I will send a second strategy with two separately named entries. I am just cleaning the code up so as not to be confusing.
      Attached Files

      Comment


        #4
        Here is the second strategy with two named entries. For the entry I sent BarsSinceEntry > 30 from the name of the first entry.

        In this case the 65 bar exit works but since the two entries have the same basic logic they fire at the same time. The second entry does not wait 30 bars from the first entry.

        Thanks again for the help
        Attached Files

        Comment


          #5
          I meant to say - For the second entry I sent BarsSinceEntry > 30 from the name of the first entry

          Comment


            #6
            Hello sdauteuil,

            Thanks for your posts.

            I've created a simple demonstration strategy (no profit or stops) that you can test with and compare how it performs (as related to BarsSinceEntry/Exit execution). It starts with a simple cross over condition for the first entry and 30 bars later places a 2nd entry, 65 bar after the 1st entry the 1st entry is exited and 65 bars after the 2nd entry it is exited.
            Here is a screenshot of performance:

            Click image for larger version

Name:	sdauteeuil-1.PNG
Views:	385
Size:	121.5 KB
ID:	1083353

            Please download and install and test (on the same data). Note: I forgot to set entries per direction to two so please do this manually when you apply/run the strategy, in the strategy parameters.

            [ATTACH]n1083354[/ATTACH]
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              The issue with this is the only logic for the second entry is that 30 bars have passed since the first entry.

              The second entry needs to have the same entry conditions as the first.

              In this case I would be looking for a second cross over condition that happened 30 bars or more from the first entry. When I try to add the additional cross over logic to the second entry both entries fire simultaneously.

              Comment


                #8
                Hello sdauteuil,

                Thanks for your reply.

                I would suggest working with the provided example and test using the provided barssince logic and add your conditions and see how that works.
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  I think I have a solution I will try.
                  My entry has 3 possible conditions that would cause an entry. (if crosses above SMA1 or crosses above SMA2 or crosses above SMA3)
                  I will break each one of those into a separate named entry.

                  I will let you know how that works.

                  However I think the problem would persist if the entry logic was the same. If the only condition was price cross above 30 day moving average I would continue to get the multiple simultaneous entries.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Tim-c, Today, 03:54 AM
                  0 responses
                  3 views
                  0 likes
                  Last Post Tim-c
                  by Tim-c
                   
                  Started by FrancisMorro, Today, 03:24 AM
                  0 responses
                  2 views
                  0 likes
                  Last Post FrancisMorro  
                  Started by Segwin, 05-07-2018, 02:15 PM
                  10 responses
                  1,772 views
                  0 likes
                  Last Post Leafcutter  
                  Started by Rapine Heihei, 04-23-2024, 07:51 PM
                  2 responses
                  31 views
                  0 likes
                  Last Post Max238
                  by Max238
                   
                  Started by Shansen, 08-30-2019, 10:18 PM
                  24 responses
                  945 views
                  0 likes
                  Last Post spwizard  
                  Working...
                  X