Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mathias79, Today, 10:38 AM
        6 responses
        18 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by eladlevi, Today, 11:02 AM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by Skifree, Yesterday, 11:41 PM
        2 responses
        13 views
        1 like
        Last Post eDanny
        by eDanny
         
        Started by TraderCro, 04-12-2024, 11:36 AM
        8 responses
        105 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Started by synthhokie, Today, 10:24 AM
        3 responses
        9 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X