Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Difference Between Calculate on Close and On Incoming Tick

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

    Difference Between Calculate on Close and On Incoming Tick

    I have had some unexpected behaviour when trading live and I think it could be due to not calculating on bar close when trading live as opposed to caluating on bar close when backtesting. My problem relates to an exit condition.

    What is supposed to happen is if the price exceeds the high of the previous bar (when short) plus the ATR, the position closes.

    It works as expected on backtesting but as it is calculating live and not on the close of the bar should "High[1]" still be [1] ? Or should it be High [0]?

    Thanks

    Mark


    if (GetCurrentAsk() > High[1] + (ATR(14)[0])
    && Avalue ==
    2)

    {
    ExitShort();
    PrintWithTimeStamp(
    "Exit Short ATR");
    }

    #2
    Hi Mark,

    High[0] when CalculateOnBarClose = true in real time refers to the most recent closed bar. This will be one bar prior to the bar that's currently forming.

    For help with bar referencing issues, I suggest to get familiar with CurrentBar. It will indicate the bar index and can be printed or plotted. It's helpful for putting a reference to the values you access.

    Print(CurrentBar + " " + High[0]);
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks Ryan - what about when CalculateOnBarClose = False?

      Comment


        #4
        If COBC = false and real time, then High[0] is the high of the bar that's currently forming.
        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        668 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        377 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        110 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        575 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        580 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X