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 charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        61 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        148 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        162 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        98 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        286 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X