Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

last tick of bar

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

    last tick of bar

    Hi,

    1. I am looking to monitor ticks in a high intensity period to place MKT orders when a specific price is seen. My existing strategy has indicators that are calculated on the close of the bar. I have used your FirstTickOfBar attribute to limit calculations to the Open of the next bar which is the same instant as the close of the last bar.

    Can I modify attributes of the last bar (Color and text labels) from within the next bar OnBarUpdate method by indexing the previous bar in a similar way to the price attributes (ala Close[ago]). Can you send a code example?

    2. The manual recommends against dynamically switching the CalculateOnBarClose attribute and recommend limiting its use to the Initialize() method.

    "This property should ONLY be set in an Initialize() method and be the last statement within that method."

    I note the "should ONLY" rather and a "can ONLY". My strategy uses the close price for its indicators and I want to monitor tick by tick to enter and possibly close once my indicators provide the entry signal using the close event. Can I dynamically turn tick events on and off without any problems? This will reduce the time overheads (back testing) which for large data sets is considerable.

    3. Is there a way to still receive the Close events while at the same time receiving the tick events as they are not mutually exclusive?

    As you can see, these questions are all related to the same issue.

    Regards,

    Paul

    #2
    Paul,

    1. Yes, you can access the BarColorSeries for this purpose - http://www.ninjatrader.com/support/h...olorseries.htm

    The DrawText() method would also have a barsAgo parameter you could use.

    2. Unfortunatey setting the CalculateOnBarClose property dynamically is not supported - it would be 'true' per default in backtesting in any case.

    3. I'm not following you here - the closing tick of the current bar is the open tick of your new bar, this is the same event.

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      Paul,

      1. Yes, you can access the BarColorSeries for this purpose - http://www.ninjatrader.com/support/h...olorseries.htm

      The DrawText() method would also have a barsAgo parameter you could use.
      Thanks
      Originally posted by NinjaTrader_Bertrand View Post
      2. Unfortunatey setting the CalculateOnBarClose property dynamically is not supported - it would be 'true' per default in backtesting in any case.
      So this means there is no way to back test against tick data?
      Originally posted by NinjaTrader_Bertrand View Post
      3. I'm not following you here - the closing tick of the current bar is the open tick of your new bar, this is the same event.
      The recommended way to simulate the close is to use the FirstTickOfBar attribute but as the name suggests, this is not the same as the close of the previous bar. It would be nice to have a separate event for both of these. I guess I can produce the same results using (1) above.

      I seem to be getting tick events in associated Indicators even though I have CalculateOnBarClose=true in the Initialize() method of the indicators. Should this be the case?

      Comment


        #4
        Paul,

        You can for sure backtest against tickdata, however the OnBarUpdate() is still called at the close of the bar on historical data. To simulate getting filled intrabar, please see this sample -

        You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by


        The closing tick is the same event, however at the point you know this you're already at the open of the new bar, hence you need to reference one bar back further in your indicators to simulate OnBarClose behavior.

        Are you sure you're printing from the OnBarUpdate() from the indicators where you see tick events coming in?

        Or would you for example have overriden the CalculateOnBarClose setting in the GUI?

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          Paul,
          Are you sure you're printing from the OnBarUpdate() from the indicators where you see tick events coming in?

          Or would you for example have overriden the CalculateOnBarClose setting in the GUI?
          protected override void Initialize()
          {
          Overlay = true;
          CalculateOnBarClose = true;
          }

          protected override void OnBarUpdate()
          {
          // only monitor the bar close event which is the first bar of the next
          if (FirstTickOfBar) CheckIndicator();
          }

          Here's the code inside my Indicator. As you can see I now need to use the FirstTickOfBar before checking my indicator. I've also tried it without the qualifier and if calls my indicator every tick

          Comment


            #6
            Paul, is there any way I can test your script on my end here? Are you working with 6.5 or 7 beta? Also: Is the CheckIndicator() calling another indicator that could have a programmatically set CalculateOnBarClose inside it's Initialize(), too? If yes, please remove any COBC statements from the called indicators and let the calling indicator / strategy set this property.

            Comment

            Latest Posts

            Collapse

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