Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsSinceEntry

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

    BarsSinceEntry

    I have tried the following exit. It should exit after 5 bars. In my case I am using a 1 second chart which I select when I set the strategy to run.

    if (this.BarsSinceEntry() > 5)
    {
    ExitShort("", "");
    ExitLong("", "");
    }

    I would expect any position to close out after 5 seconds in this case. But it seems to just be ignoring it.

    #2
    I suggest debugging your strategy as per here: http://www.ninjatrader-support.com/v...ead.php?t=3418

    and here
    http://www.ninjatrader-support.com/v...ead.php?t=3627
    DierkNinjaTrader Customer Service

    Comment


      #3
      Did this exit system work in the end for you? I am trying it on a 3 minute chart but the strategy exits the position straight away which is frustrating.

      Everington_f

      Comment


        #4
        Everington_f, what are you using to exit your positions? Can you provide us a snippet of the code you're using?
        AustinNinjaTrader Customer Service

        Comment


          #5

          if (this.BarsSinceEntry() > 4)
          {
          ExitLong("Long");
          ExitShort("Short");
          }

          else


          if (Position.MarketPosition == MarketPosition.Long)
          {
          if (Close[0] < aligator.Lips[barsAgo] - stopOffset * TickSize)
          {
          if (!Historical)



          {

          }
          ExitLong(
          "Long");
          }
          }
          if (Position.MarketPosition == MarketPosition.Short)
          {
          if (Close[0] > aligator.Lips[barsAgo] + stopOffset * TickSize)
          {
          if (!Historical)
          {

          }
          ExitShort(
          "Short");

          Comment


            #6
            Everington_f, it appears you have two sets of exit conditions. Do you know which one is causing the exits? The easiest way to get to the root of a problem is to reduce the program until everything functions correctly, then add functionality one layer at a time until you find the problem.
            AustinNinjaTrader Customer Service

            Comment


              #7
              the bars since entry function is causing the problem... the strategy has worked for months without this additional condition...

              Comment


                #8
                Everington, it looks like you will have to debug. I recommend using Print() statements to get a feel for the data your strategy is using.

                In your case, since you said the strategy has worked fine without the BarsSinceEntry, just add a simple
                Code:
                Print("BarsSinceEntry:\t" + this.BarsSinceEntry())
                in OnBarUpdate() and see what values come back.
                AustinNinjaTrader Customer Service

                Comment


                  #9
                  Everington, another useful tool to figure out what is happening is TraceOrders. TraceOrders will let you know exactly what is happening with orders and why.
                  In Initialize:
                  Code:
                  TraceOrders = true;
                  AustinNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Stanfillirenfro, Today, 05:31 AM
                  0 responses
                  6 views
                  0 likes
                  Last Post Stanfillirenfro  
                  Started by sidlercom80, Today, 04:45 AM
                  0 responses
                  3 views
                  0 likes
                  Last Post sidlercom80  
                  Started by NT-Roland, Today, 04:44 AM
                  0 responses
                  4 views
                  0 likes
                  Last Post NT-Roland  
                  Started by knarfoe, Today, 04:26 AM
                  0 responses
                  2 views
                  0 likes
                  Last Post knarfoe
                  by knarfoe
                   
                  Started by manueldecastro, Yesterday, 10:59 PM
                  2 responses
                  9 views
                  0 likes
                  Last Post manueldecastro  
                  Working...
                  X