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 charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        58 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        143 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        161 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        97 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        276 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X