Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsSinceEntry() question

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

    BarsSinceEntry() question

    I am trying to set up a exit order which only triggers the SMA (condition1) if some number of bars has passed since the porisiton has been opened. However, when i use the code below no order is generated (even on strategy analyzer).
    What I ve been doing wrong?

    if (CrossAbove (Medians[1][0], SMA (BarsArray[1],SMACycle) ,1) && BarsSinceEntry() > 20)
    {
    ExitLong();
    }

    #2
    You may want to try adding a BIP for the BarsSinceEntry() condition along with the exit. There isn't any way for me to know what other logical checks are/aren't being met with just this statement.

    BarsSinceEntry(int barsInProgressIndex, string signalName, int entriesAgo)

    Note: When working with a multi-series strategy the BarsSinceEntry() will return you the elapsed bars as determined by the first Bars object for the instrument specified by the barsInProgressIndex.


    Debugging tips (Specifically you'll want to add prints or drawing objects before and inside the if statement to check values): http://www.ninjatrader.com/support/f...ead.php?t=3418

    Let me know if I can further assist.
    LanceNinjaTrader Customer Service

    Comment


      #3
      Why does this work...
      if (BarsSinceExit(series, "" ,0) > 1 || BarsSinceExit(series, "" ,0) == -1)

      but if you try to use it with BarsSinceEntry it doesn't work? It won't trigger any trades with BarsSinceEntry.
      Last edited by zachj; 10-08-2013, 09:00 PM.

      Comment


        #4
        You'll want to isolate it further by printing out something like this just before your print statement

        Print(BarsSinceEntry(0, "", 0) );

        And compare it to

        Print(BarsSinceExit(0, "", 0) );

        LanceNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        662 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        376 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        110 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        574 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        580 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X