Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CalculateOnBarClose question

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

    CalculateOnBarClose question

    hi, is there a way that i can set CalculateOnBarClose = false, so i can monitor real time tick data (say, last traded price > entered price then i take profit) while for the indicators, it only fires when CalculateOnBarClose = true ? i mean, say, i want the RSI(14) calculated once every 5 minutes (5-min-bar)

    Is there a way to do that? Thanks

    #2
    Yes Lawrence, you can combine settings as needed with the concept shown in our reference sample on this topic below -

    BertrandNinjaTrader Customer Service

    Comment


      #3
      Bertrand,

      That trade strategy example really doesn't address the problem very well for two reasons.

      - Trade logic for the entry ( EnterLong() ) trigger is FirstTickOfBar, while exit ( ExitLong() ) trigger is every tick.
      - The trade strategy uses Add() to add two indicators to the chart which update with each tick, so unnecessary CPU resources would be taking place to update the chart with each tick even though the trade logic does not require this.

      An alternate to using 'CalculateOnBarClose = true' option, would be to use a look back or the BarsAgo parameter [1]. That way, the calculation result would be the same as a calculation immediately on bar close or with the final tick of the bar.

      Do you have any other examples that would work to conserve CPU resourses for multi-timeframe computations that use added timeframes with CalculateOnBarClose = false, but still allow some intrabar computations for some portion of the entry and exit trade logic? If not, how might one approach this in C# or Ninjascript?

      Comment


        #4
        Hello,

        You do not have to have the Add() call. That is just for show to display the indicator in the chart.

        You could remove the Add() and then manually add the indicator to the chart with COBC = true.

        Furthermore, with just 2 or more indicators cobc = false usually is no problem.

        -Brett

        Comment


          #5
          Originally posted by NinjaTrader_Brett View Post
          Hello,

          You do not have to have the Add() call. That is just for show to display the indicator in the chart.

          You could remove the Add() and then manually add the indicator to the chart with COBC = true.

          Furthermore, with just 2 or more indicators cobc = false usually is no problem.

          -Brett
          Brett,

          Regardless of how one adds the indicator to the chart, the indicator will update intrabar with each tick, thus wasting CPU processing ability.

          This is not generally a problem with simple strategies, however with fully developed strategies, it is a serious problem. If it wasn't a problem, COBC=true option would never have been added to the Ninjascript reference library, because as I pointed out in my earlier post, one could just use the barsAgo parameter [1].

          Do you have any other examples that would work to conserve CPU resourses for multi-timeframe computations that use added timeframes with CalculateOnBarClose = false, but still allow some intrabar computations for some portion of the entry and exit trade logic? If not, how might one approach this in C# or Ninjascript?
          Last edited by borland; 05-02-2012, 03:36 PM.

          Comment


            #6
            borland, we would unfortunately have no other optimizing examples available - if you need an intrabar updated indicator then you would need to run this portion of code COBC = false or introduce a timer for example that could help reduce OBU cycles. Yet another approach could be to filter out OBU's triggered by the same price being seen, this would be a good solution for price driven strategies / indicators.
            BertrandNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by bmartz, 03-12-2024, 06:12 AM
            4 responses
            32 views
            0 likes
            Last Post bmartz
            by bmartz
             
            Started by Aviram Y, Today, 05:29 AM
            4 responses
            12 views
            0 likes
            Last Post Aviram Y  
            Started by algospoke, 04-17-2024, 06:40 PM
            3 responses
            28 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by gentlebenthebear, Today, 01:30 AM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by cls71, Today, 04:45 AM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X