Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stratgey Results Disapper With BarsSinceExit

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

    Stratgey Results Disapper With BarsSinceExit

    Hi all,

    I have a working staratgety, and I'm just trying to tweek it a bit, by ensuring it dosen't jump right back into a trade after getting stopped out. To accomplish this, I'm ensure we've waited at least one bar since we've exited, and I'm using BarSinceExit to accomplish this.

    Here is what code I"m using:

    Onbarupdate...

    if (Position.MarketPosition == MarketPosition.Flat &&
    ToTime(Time[0]) > ToTime(8, 00, 0) &&
    ToTime(Time[0]) < ToTime(15, 55, 0) &&
    BarsSinceExit() > 1 || BarsSinceExit() == -1)
    tradepermission = true;
    But when I add the BarsSinceExit part, I get no results on my backtest. Am I using this command improperly?

    Regards,

    Brian

    #2
    Brian,

    You need to () the BarsSinceExit() conditions.

    (BarsSinceExit() > 1 || BarsSinceExit() == -1)
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Still no workie...

      if (Position.MarketPosition == MarketPosition.Flat &&
      ToTime(Time[0]) > ToTime(8, 00, 0) &&
      ToTime(Time[0]) < ToTime(15, 55, 0) &&
      (BarsSinceExit() > 1) || (BarsSinceExit() == -1))
      tradepermission = true;

      Comment


        #4
        Then you will just need to debug out each one of those conditions to see if they are actually true. Use Print() to determine if you are even entering the if-statement. Then figure out which part is the limiting factor. Also, check your Control Center logs for errors.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Multi time frame issue:

          if (Position.MarketPosition == MarketPosition.Flat &&
          ToTime(Time[0]) > ToTime(8, 00, 0) &&
          ToTime(Time[0]) < ToTime(15, 55, 0) &&
          (BarsSinceExit(1, "", 0) > 1 || BarsSinceExit(1, "", 0) == -1))
          tradepermission = true;

          Comment


            #6
            Glad you got it resolved.
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by fincabayano, Today, 05:58 AM
            0 responses
            4 views
            0 likes
            Last Post fincabayano  
            Started by omribidi, 02-06-2025, 04:39 AM
            2 responses
            28 views
            0 likes
            Last Post omribidi  
            Started by Aileenapu, Today, 05:34 AM
            0 responses
            3 views
            0 likes
            Last Post Aileenapu  
            Started by fincabayano, Today, 05:28 AM
            0 responses
            6 views
            0 likes
            Last Post fincabayano  
            Started by litamm89, 02-01-2025, 11:33 AM
            2 responses
            36 views
            0 likes
            Last Post litamm89  
            Working...
            X