Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calculate on Bar Close or not?

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

    Calculate on Bar Close or not?

    Hi,

    I have an simple strategy witch use the SMA to enter a position with a limit oder for the next bar. If i set the Caltulate on BarClose to false I can see that Nijatrader dont calculate the SMA for the current bar.
    Here is an example of the Entrylogic:

    //Long
    if(Position.MarketPosition == MarketPosition.Flat
    && Trade
    && (ToTime(Time[0])) >= 110000
    && (ToTime(Time[0])) <= 234500
    && Close[0] > Ma[0]
    && Close[0] > Filter[0])
    { EnterLongLimit(Stuck,Instrument.MasterInstrument.R ound2TickSize(Ma[0] - EntryTicks*TickSize*2), "Long");
    }

    The Backtest is fine but if i run the strategy in Realtime the Entryorders are not alway submitted. Do you think it could be because the Calculate on Bars Close is set to TURE? Would it be better to run such Code like in the example above in Calculate on BarClose = FALSE???

    #2
    It is up to you which one you want to run on. With CalculateOnBarClose = true, you are waiting till the close of the bar to run calculations on it. You are not calculating on the current building bar, but rather the bar that just closed. With CalculateOnBarClose = false, you are processing every single incoming tick on the building bar.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      So if I run the strategy with onBarClose = false, then I must use the condition
      "FirstTickOfBar"? Else will Ninjatrader submitt an Order on every Tick?

      In such case I must change such standart Entry like:
      Close[0] > Open[0] to Close[1] > Open[1] and then the oder will be submitted on the open of the current bar?
      Is this correct?

      Comment


        #4
        If you want it to submit on the open of a bar after calculating the values of the recently closed bar just stick with CalculateOnBarClose = true and use [0].

        Otherwise you will need if (FirstTickOfBar) and offsetting your [0] to [1]s to get the recently closed bar.
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        563 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        329 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        547 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        548 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X