Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsSinceExitExecution issue

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

    BarsSinceExitExecution issue

    In the following line of code everything is fine until I add the bars since exit execution portion, which kills all entries:

    if (_ema[0] > _ema[1] && _macd.Diff[0] > _macd.Diff[1] && J2RSqueeze1.MomentumHistogram[0] > J2RSqueeze1.MomentumHistogram[1] && J2RSqueeze1.SqueezeDots[0] == 1 && BarsSinceExitExecution() > 1)

    Something missing someplace else maybe or just wrong syntax?

    Thanx

    #2
    Hello johnMoss,

    Thank you for your post.

    I suspect that you will need to add to your condition to consider the very first entry, which is when a previous exit does not exist. BarsSinceExitExecution() returns -1 if a previous exit does not exist, so similar to the snippet shown on the help guide page you may need to consider something like the following:
    if (BarsSinceExitExecution() > 1 || BarsSinceExitExecution() == -1)



    Please let us know if we may be of further assistance.

    Comment


      #3
      Yup ... That's It... Thank You Emily...

      Comment


        #4
        I have the same issue but can only use the Strategy Builder. How would one go about this using Strategy Builder?

        Comment


          #5
          Hi Sheri,
          Bars since exit in Strategy builder is located in the misc section. This is def doable in the builder, but you'll be doing something to make it work that is outside the norm of the manner in which your conditionals are normally constructed. Its easy, but a long winded answer as you need to understand why you're doing what you're doing; i.e. understanding the difference, if you don't know already, between && vs. ||... In your conditional set you'll be using a combination of "If Any" single line BarsSinceExit snippets as above along with grouped "If All" combinations as your overall entry execution method requires.

          In essence here is as you've discovered, you get no response because a a baseline hasn't been set, i.e. we gotta have a chicken to get an egg, and the chicken here is -1.

          So, Conditions and Actions, Up Top:

          1) Set If Any If All to If Any.
          2) Add - Conditions - Misc - Bars Since Exit = Misc - Numeric Value - -1.
          3. Add - Conditions - Misc - Bars Since Exit = Misc - Numeric Value - >1. (Or whatever value you want here)

          As you notice there are additional considerations you can toss in the bars since exit configuration. For now you may leave those blank and hence argument will apply to all conditions in continuance in the set as well as all unique entry names if you've named them.

          Now for the rest of your conditional set, you will group your arguments.
          So:
          4) Group - Condition Group Editor - Choose If All -

          then load up the rest of your arguments...

          JM

          Comment


            #6
            Works perfectly!

            Thank you

            Comment


              #7
              Lol... What I get for thinking before morning coffee requirement...

              This needs to be separated into two full conditional argument sets. Revisiting numbers 1,2,3 and 4 above:

              Condition set 1 - set to 'If All'

              Follow step 2.
              Follow step 4.

              Condition Set 2 - set to If All

              Follow Step 3.
              Follow Step 4.

              What I wrote previously above will cause entries to fire If Any of the conditions are true, i.e. ignoring your grouped conditional filters set and allowing entries just because another entry completed.

              This correction will now follow your plan properly.

              Comment


                #8
                Well thanks so much for the update. I guess I lucked out that it was behaving the way I wanted it to!

                Comment


                  #9
                  Originally posted by johnMoss View Post
                  Lol... What I get for thinking before morning coffee requirement...

                  This needs to be separated into two full conditional argument sets. Revisiting numbers 1,2,3 and 4 above:

                  Condition set 1 - set to 'If All'

                  Follow step 2.
                  Follow step 4.

                  Condition Set 2 - set to If All

                  Follow Step 3.
                  Follow Step 4.

                  What I wrote previously above will cause entries to fire If Any of the conditions are true, i.e. ignoring your grouped conditional filters set and allowing entries just because another entry completed.

                  This correction will now follow your plan properly.

                  Still not firing my trade executions
                  .
                  What should Start Behavior be set to?

                  Comment


                    #10
                    Go to j2Algotrader.com & send me an email. I suspect something else is amiss... Highly unlikely start behavior has anything to do with this...
                    Last edited by johnMoss; 06-01-2023, 03:36 PM.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by NullPointStrategies, Yesterday, 05:17 AM
                    0 responses
                    54 views
                    0 likes
                    Last Post NullPointStrategies  
                    Started by argusthome, 03-08-2026, 10:06 AM
                    0 responses
                    131 views
                    0 likes
                    Last Post argusthome  
                    Started by NabilKhattabi, 03-06-2026, 11:18 AM
                    0 responses
                    73 views
                    0 likes
                    Last Post NabilKhattabi  
                    Started by Deep42, 03-06-2026, 12:28 AM
                    0 responses
                    44 views
                    0 likes
                    Last Post Deep42
                    by Deep42
                     
                    Started by TheRealMorford, 03-05-2026, 06:15 PM
                    0 responses
                    49 views
                    0 likes
                    Last Post TheRealMorford  
                    Working...
                    X