Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsSinceExit

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

    BarsSinceExit

    Hi,

    I am trying to add bars since exit condition to my trade logic, the code compiles however I am unable to enable the strategy with the line added. Can someone explain where I am going wrong? I am using Renko blocks could this be the issue, I'm guessing so. if this is the case how would I go about this?

    if (BarsSinceExit() >= 5
    && XavTrend1 == -5
    && ScalpTrader == 2
    && adxshort_in > ADXshort)

    )

    {

    {

    EnterShort(lots, "DT+DT");
    if (printtolog == true) Print("SHORT TRADE-----------RGAuto:");

    }

    #2
    Hello Gille1983,

    Thanks for your post.

    It looks like you are using BarsSinceExit() as part of your entry conditions. If there is no previous exit then the condition will never be true.

    You would need to check for either an exit (as you are now) or for the method to return a -1 value indicating there is no previous exit.

    Please see the example in the help guide that demonstrates checking for a number of bars or a -1 value: https://ninjatrader.com/support/help...ssinceexit.htm

    Comment


      #3
      OK so looking at the example this would be the correct way ?

      if ((BarsSinceExit() > 5 || BarsSinceExit() == -1)
      && XavTrend1 == -5
      && XavTrend2 == -5)

      Comment


        #4
        Hello Gille1983,

        Thanks for your reply.

        Yes, if there was no previous exit the BarsSinceExit() method will return -1 allowing the entry to occur (assuming the other conditions were also true).

        After the first exit, the method will always return the number of bars since the last exit.

        Comment


          #5
          ok and this should work on renko is that correct? I am still unable to enable the strategy with that line of code added

          Comment


            #6
            Hello Gille1983,

            Thanks for your reply.

            After adding the line of code, did you compile the strategy without errors?

            If successful, when you apply the strategy to a chart, are you connected to a live data feed, and did you set "Enabled" to true in the strategy parameters?

            If so, and the strategy does not run, please check the "log" tab of the control center for any error messages related to the strategy.


            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            557 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            324 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            545 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            547 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X