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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        152 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        87 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        131 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        127 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        106 views
        0 likes
        Last Post CarlTrading  
        Working...
        X