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 bortz, 11-06-2023, 08:04 AM
            47 responses
            1,602 views
            0 likes
            Last Post aligator  
            Started by jaybedreamin, Today, 05:56 PM
            0 responses
            8 views
            0 likes
            Last Post jaybedreamin  
            Started by DJ888, 04-16-2024, 06:09 PM
            6 responses
            18 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by Jon17, Today, 04:33 PM
            0 responses
            4 views
            0 likes
            Last Post Jon17
            by Jon17
             
            Started by Javierw.ok, Today, 04:12 PM
            0 responses
            12 views
            0 likes
            Last Post Javierw.ok  
            Working...
            X