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 SalmaTrader, 07-07-2026, 10:26 PM
        0 responses
        47 views
        0 likes
        Last Post SalmaTrader  
        Started by CarlTrading, 07-05-2026, 01:16 PM
        0 responses
        22 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 06-17-2026, 10:32 AM
        0 responses
        15 views
        0 likes
        Last Post CaptainJack  
        Started by kinfxhk, 06-17-2026, 04:15 AM
        0 responses
        21 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 06-17-2026, 04:06 AM
        0 responses
        23 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Working...
        X