Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

"Calculate on Bar Close"

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

    "Calculate on Bar Close"

    I have a problem with setting up a simple strategy. I want to set up a trade when the price moves up above the top band of a bolinger band, and reverse when it when it falls below a lower band.
    I've set up the strategy using a 15 min candlestick chart. The problem I have when I backtest, the trade is executed in the following 15min candle period, not in the candlestick when the price crosses the band. I have unchecked the "Calculate on Bar Close" so that the script shows "false" but this has made no difference. I contacted Jason in the support dept, and he sent me the screenshot 'J1' but as you see from my screenshot 'J2' my screen is totally different.
    btw I have completely uninstalled/reinstalled the NT platform 3 times now, and I have tried all versions on your download page (currently I have v6.0.1000.11 installed), but I still have the same problem and I still don't have the same screenshot as Jason.
    Jason currently is unsure what the problem is, so I wonder if anyone could shed some light on this. Thanks.

    Click image for larger version

Name:	J1.JPG
Views:	1
Size:	95.7 KB
ID:	890530

    Click image for larger version

Name:	J2.jpg
Views:	1
Size:	49.1 KB
ID:	890531
    Last edited by John833; 06-20-2008, 10:41 PM.

    #2
    Here is how NinjasScript strategies are backtested: signals e.g. on bar 115 will trigger orders on bar 116. Basically CalculateOnBarCose=false makes no difference in backtesting more (different in live mode though).

    Comment


      #3
      Thank you Dierk for your very quick reply
      If I understand correctly from what you're saying, in live mode as soon as a signal is generated, for example during the time period in bar 116 then a trade is executed? Is that right?
      Therefore backtesting using 15min candle periods will always produce incorrect backtesting results if the order is triggered in the next bar.
      If that is the case, is there a way to accuratly backtest strategys that have generate signals on longer timeframes, is there a way around this?
      Also would you have any idea why my screenshot is different from the one that was sent over to me? Regards and thanks, John

      Comment


        #4
        >> If I understand correctly from what you're saying, in live mode as soon as a signal is generated, for example during the time period in bar 116 then a trade is executed?
        Correct, if CalculateOnBarClose=false.

        NT's backtest logic is accurate since anything would imply a high risk that you use data "in the future". Please check the web for implications on backtesting on historical data.

        Comment


          #5
          >>NT's backtest logic is accurate since anything would imply a high risk that you use data "in the future". Please check the web for implications on backtesting on historical data.

          Thanks again for your reply, sorry I don't completely understand what you mean. Are you saying that NT backtesting will not allow a trade to be generated when a signal appears, but only in the following time frame?

          Comment


            #6
            The way the orders are generated is the most realistic possible. Since historical backtesting means looking at bars sequentially you are essentially looking at each bar as that bar closed. This means that any order placed after will not be able to be filled except at the next bar. This next bar happens to be the new bar that happens immediately after the current signal bar. Hope that makes sense.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Thank you Josh for your post and your very clear explanation. Regards John

              Comment


                #8
                Backtesting Question over multiple timeframes

                Hi,
                I have made a strategy that uses multiple timeframes (1hr, 4hr, 8hr) and in real time it works well. The strategy executes every hour and will enter a trade (example here) if the 1hr close is above the 1hr SMA, the 4hr trend is above the 4hr SMA and the 8hr trend is above the 8hr SMA. There is a time where the 4hr and 8hr bars are still being built (not yet completed) but provided the current price on 4hr and 8hr is above the related SMA then the system will enter the trade - which is what I want. When I backtest however, the system will look at the current 1hr close bar but will look at the last complete 4hr bar and 8hr bar and will ignore the current (incomplete) bar. This is NOT how my strategy is designed to run, and it is effectively putting me up to 7hrs behind in making an entry. Surely I'm not the only person who has experienced this. Does anyone know a solution as I'm now being pressured by my client to move to another platform that gives this flexibility.
                Any comment would be greatly appreciated.
                Thanks
                Steve

                Comment


                  #9
                  Steve, in realtime you could work with CalculateOnBarClose set to false to update all your used timeframes on each incoming tick. Unfortunately in backtesting the tick formation of bars is not available and therefore you would need to customcode your strategy to emulate the longer timeframe conditions on your shortest bar interval (most likely the 1 hr frame in your case). To achieve a backtesting of intrabar fills on this timeframe then, please follow the structure provided in this sample - http://www.ninjatrader-support2.com/...ead.php?t=6652

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  579 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  334 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
                  554 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  551 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X