Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MAX, BarsSinceEntry, Multi-Time-Frame

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

    MAX, BarsSinceEntry, Multi-Time-Frame

    I wrote the following code for a breakeven + 2, but it prints out some unexpected numbers for HighestBar and BarsSinceEntry. The entire body of the code is captured within BarsInProgress == 1, which refers to:

    Code:
    Add(PeriodType.Tick, 1);

    The principal chart runs off a 10min chart, but, the printout will show an entry, say, at 7:45:30AM and and exit at 8:00:00AM and a respective BarsSinceEntry equal to 1. Now, between the BarsInProgress referring to the tick data, and the BarsSinceEntry referring to Index 1 in its 1st overload, I would have expected it to return BarsSinceEntry equal to something in the 100's.

    Here's the code:

    Code:
     
    // Breakeven
    if (MAX(High, BarsSinceEntry(1,"",0))[0] >= Position.AvgPrice + beTrigger*TickSize)
    {
    if ((Open[1] > Position.AvgPrice + bePlus*TickSize) &&
    (Open[0] <= Position.AvgPrice + bePlus*TickSize))
    {
    ExitLong();
    Print(Time[0].ToString() + " ATR: " + ATR(BarsArray[2], atrPeriod)[1].ToString() + 
    " ATR Ticks: " + atrTicks.ToString() + " ATR Target: " + atrTarget.ToString() + " ExitLongBreakeven " + " HighestBar: " + MAX(High, BarsSinceEntry(1,"",0))[0] + " BarsSinceEntry: " + BarsSinceEntry(1,"",0));
    }


    I'm sure it's messing with things, what you think?

    Thanks!

    #2
    This tidbit in the Help Guide most likely pertains to your case here



    "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."
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      so it's always returning BarsArray[0]?

      Comment


        #4
        Originally posted by stevescott05 View Post
        so it's always returning BarsArray[0]?
        Yes Steve, this is correct for your setup outlined.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        581 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        338 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        554 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        552 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X