Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CalculateOnBarClose Question

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

    CalculateOnBarClose Question

    I have recently experienced differences in trade executions between live and historical data (i.e. on data reload) on two of my strategies. Both run on a 1-minute chart and I have already confirmed that the data is identical - I exported the data after the session, then reloaded the historical on the chart and then exported again. Finally I compared the data in WinMerge - and everything looks the same.

    Now given this I was puzzled that the executions are different until I noticed that I had set CalculateOnBarClose to false in the init methods of both strategies. However, both strategies on the chart had CalculateOnBarClose set to true. So I wonder - which one has priority? If I programatically set it to false and then set it to true in strategy configuration, which one overrides which?

    Any input would be appreciated.

    #2
    great question...my partner and i were tossing this question around recently.

    I am fairly certain that when it comes to, for example, minimum bars required, if your code specifies 10 bars and your GUI window says 20 for some reason, upon the start of a backtest or other compiling of code, the 10 will pop into the window and override the 20.

    If this is not correct or the procedure for calcOnBarClose is different, i'd be interested to understand the mechanics also.

    Comment


      #3
      Whatever option you set in the GUI has priority, the programmatically set one would just be the default one you see if you loaded up that specific script, but if you override via a GUI setting > this would be taking priority.

      Comment


        #4
        Thanks Bertrand. Do you have any idea why I would see a delta between live/historical executions then? In particular if the historical and live data are clearly identical?

        Comment


          #5
          Yes molecool, several common factors are outlined here : http://www.ninjatrader.com/support/h...ime_vs_bac.htm

          Comment


            #6
            There's something else going on...

            Well, the issues explained on that page are known to me. But the issue I'm having is more intricate I think. First up I have set CalculateOnBarClose to true - so this takes the tick issue away. I have also checked the data feed and it's identical - I am plotting the indicators below my strategy and compared them with Photoshop (live vs. historical) - the look the same and should trigger.

            Now, the big issue is that the LIVE feed executes later than the historical feed - which is rather surprising. I am painting the candle that's supposed to be executing and as you can see in the enclosed magnified screen grabs below the live strategy also executes three candles after the signal, not one candle after as it should (and which it does with historical data).

            BTW - on the chart I tried to set the fill type from default to liberal and had no impact on the historical entries, it may on the live - I would have to test that.

            Any input would be welcome - this is a big head scratcher for me.
            Attached Files
            Last edited by molecool; 08-18-2011, 06:41 PM.

            Comment


              #7
              Hi molecool,

              We don't expect that strategies function the same in real time and backtest, so there's nothing unusual about your screenshots. You have a different entry price on each, which as you see can lead to a stop being filled in one scenario but not the other. Even if running COBC = true, in real time trading your "Set" statements put forth actual working orders that are filled according to tick by tick market dynamics and in backtest these orders can only look at the OHLC of historical bars.

              If you want a better tool to simulate how your strategy will perform live, use the market replay feature.
              Ryan M.NinjaTrader Customer Service

              Comment


                #8
                Actually...

                This strategy only runs against the 101 demo account - it does not execute real market orders. Which is why this confused me so much. It should not do this with the demo account, right?

                Comment


                  #9
                  molecool, this could happen on the simulator as well as you're trading against the simulation engine that would attempt to recreate real world fill probabilities.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  666 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