NexusFi: Find Your Edge


Home Menu

 





What is the difference between COBC true vs false?


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one LightWeight with 9 posts (1 thanks)
    2. looks_two Fat Tails with 8 posts (12 thanks)
    3. looks_3 ericson with 1 posts (0 thanks)
    4. looks_4 Big Mike with 1 posts (0 thanks)
    1. trending_up 5,112 views
    2. thumb_up 13 thanks given
    3. group 3 followers
    1. forum 18 posts
    2. attach_file 3 attachments




 
Search this Thread

What is the difference between COBC true vs false?

  #1 (permalink)
 ericson 
Sacramento, CA
 
Experience: Advanced
Platform: NinjaTrader
Broker: NA
Trading: Stocks, Forex
Posts: 64 since Nov 2013
Thanks Given: 14
Thanks Received: 19

Still confusing to me. Can someone explain it to me? I know true its at close of bar, that calculates to send order. False is for every tick. But how is that different live trading? I know its always true for backtesting, but what happens when its set t0 false live trading?

How does that affect comparing indicators [0] to [1] in conditions?

Side question: If set to true, is it guaranteed to buy/sell at open next bar like how it is done in backtesting.Is their a difference between forex and stocks trading?


Thanks to all!

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Futures True Range Report
The Elite Circle
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Online prop firm The Funded Trader (TFT) going under?
Traders Hideout
Ninja Mobile Trader VPS (ninjamobiletrader.com)
Trading Reviews and Vendors
Better Renko Gaps
The Elite Circle
 
  #2 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,399 since Jun 2009
Thanks Given: 33,175
Thanks Received: 101,541

All historical data is calculated as-if COBC = true. Once you start processing live data, COBC=true means indicators are evaluated once at the close of the bar. If set to false it means indicators are evaluated on each incoming tick.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #3 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102



ericson View Post
Still confusing to me. Can someone explain it to me? I know true its at close of bar, that calculates to send order. False is for every tick. But how is that different live trading? I know its always true for backtesting, but what happens when its set t0 false live trading?

How does that affect comparing indicators [0] to [1] in conditions?

Side question: If set to true, is it guaranteed to buy/sell at open next bar like how it is done in backtesting.Is their a difference between forex and stocks trading?


Thanks to all!


Let us assume that you watch a 1-minute chart. It is 9:35:20 AM EST. In that case the last bar that you will see on your chart is the 9:36 bar. It is incomplete and you can see, how the close moves up and down.

COBC = true : The indicator value will only be calculated, when the current bar is complete. In the example this means that the calculation is performed once every minute, because you are watching a 1-minute chart. No value will be displayed for the current incomplete bar.

COBC = false: The indicator value is recalculated for every incoming tick. The preliminary value will be displayed for the current incomplete bar.

The NinjaTrader default setting is COBC = true. The reason is that the CPU load is much lower with COBC = true (only one calculation performed per bar) compared with COBC = false (one calculation performed with every incoming tick). The CPU issue may be important for a complex or badly coded indicator. Also some indicators, such as the average true range should not be used at all with COBC = false. The reason here is that the true range of a new developing bar is close to 0, therefore the ATR is systematically distorted to the downside, when used with incomplete bars.

For backtests, COBC = true is the only option, because the data used for the backtest is just the OHLC and volume of the bar series loaded. The intra-bar information - that is single ticks - are not used, because this would take too many resources to conduct a standard backtest on an average PC.

The setting COBC = false should only be used

- when intra-bar signals are required for trading
- when the indicators and strategies are coded in a proper way to make efficient use of the CPU

Reply With Quote
  #4 (permalink)
 
LightWeight's Avatar
 LightWeight 
Kirkland, WA/United States
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Optimus/Vision/Rithmic
Trading: Futures
Posts: 138 since Jul 2012
Thanks Given: 138
Thanks Received: 42

I am a little confused about this -- I am running several strategies with COBC set to true, and yet they're jumping into trades at random times throughout the one minute period. They all use market orders for entry and exit, and operate on 1 minute charts. In backtesting the same strategy will show entry at say 18:44:00, while the live sim strategy will show entry at 18:33:48, even though COBC is set to true. I would assume that the live results should mirror the backtest -- if anything, the live sim would go in AFTER the backtest entry, say at 18:44:01 or 18:44:02. I tried changing the setting to false in case Ninja had it reversed and it didn't seem to make much difference. Of course, all of my backtesting results are based on COBC = true and then activation at that time, so how the hell do I get my live sim strategies to take the same approach? Because so far it seems like this making a huge difference in live performance vs. backtesting performance.

I also wonder if this is affecting the exit -- many times it seems like the strategy hops out with a small gain, while letting the losers go all the way to stop loss. I would guess that perhaps that there was an exit signal intrabar which caused the strategy to exit live, but in backtesting the signal was not present at the close of the same bar and thus it did not exit the position, giving it more time/chances to reach profit target instead.

I don't see how I can possibly get accurate results without either A) getting the backtest to execute intrabar trades just as the live strategies are doing, or B) get the live strategies to wait until the bar close for entry, like backtest is doing.

Think big, think positive, never show any sign of weakness. Always go for the throat. Buy low, sell high. Fear? That's the other guy's problem. In this building, it's either kill or be killed. You make no friends in the pits and you take no prisoners. One minute you're up half a million in soybeans and the next, boom, your kids don't go to college and they've repossessed your Bentley. Are you with me?
Reply With Quote
  #5 (permalink)
 
LightWeight's Avatar
 LightWeight 
Kirkland, WA/United States
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Optimus/Vision/Rithmic
Trading: Futures
Posts: 138 since Jul 2012
Thanks Given: 138
Thanks Received: 42

I'm wondering if this would actually solve the issue for me:


Think big, think positive, never show any sign of weakness. Always go for the throat. Buy low, sell high. Fear? That's the other guy's problem. In this building, it's either kill or be killed. You make no friends in the pits and you take no prisoners. One minute you're up half a million in soybeans and the next, boom, your kids don't go to college and they've repossessed your Bentley. Are you with me?
Reply With Quote
  #6 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


LightWeight View Post
I am a little confused about this -- I am running several strategies with COBC set to true, and yet they're jumping into trades at random times throughout the one minute period. They all use market orders for entry and exit, and operate on 1 minute charts. In backtesting the same strategy will show entry at say 18:44:00, while the live sim strategy will show entry at 18:33:48, even though COBC is set to true. I would assume that the live results should mirror the backtest -- if anything, the live sim would go in AFTER the backtest entry, say at 18:44:01 or 18:44:02. I tried changing the setting to false in case Ninja had it reversed and it didn't seem to make much difference. Of course, all of my backtesting results are based on COBC = true and then activation at that time, so how the hell do I get my live sim strategies to take the same approach? Because so far it seems like this making a huge difference in live performance vs. backtesting performance.

I also wonder if this is affecting the exit -- many times it seems like the strategy hops out with a small gain, while letting the losers go all the way to stop loss. I would guess that perhaps that there was an exit signal intrabar which caused the strategy to exit live, but in backtesting the signal was not present at the close of the same bar and thus it did not exit the position, giving it more time/chances to reach profit target instead.

I don't see how I can possibly get accurate results without either A) getting the backtest to execute intrabar trades just as the live strategies are doing, or B) get the live strategies to wait until the bar close for entry, like backtest is doing.


@LightWeight: Live results never mirror the back test for various reasons. For example the latency of your trading PC, the delay imposed by the broker to execute your trade (due to credit control to comply with margin requirements), the depth of the order book are not known or used in backtest.


Stop and limit orders - managed approach

In your case where the live strategy entered earlier than the backtest, the likely reason is that you used a stop or a limit order.

Let us take the case of a stop order: In a live environment the stop order is transformed to a market order, when the stop price is hit. The execution price is near the stop price. In a backtest any executions are shown with the time stamp of the bar close. However, the stop order should be excuted at a similar price.

It is important to understand that a backtest is performed on historical data. That means that you just have the historical bars (open, high, low, close and volume) but have no clue, what happened intra-bar. If you have a historical bar that lasts from 9:30 to 9:45 and that has hit a stop, you cannot tell whether the stop was hit at 9:32 or 9:44. Therefore the timestamp shown is always the time stamp of the bar, that is 9:45.

In real-time trading the stop will be hit when the market first trades at the stop price, which can be at any time between 9:30 and 9:45.


Unmanaged market orders

In case that you simply used unmanaged market orders and both the backtest and the live SIM strategy running in COBC = true, you will observe similar results. The only difference should be due to slippage.

Reply With Quote
Thanked by:
  #7 (permalink)
 
LightWeight's Avatar
 LightWeight 
Kirkland, WA/United States
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Optimus/Vision/Rithmic
Trading: Futures
Posts: 138 since Jul 2012
Thanks Given: 138
Thanks Received: 42


Fat Tails View Post
@LightWeight: Live results never mirror the back test for various reasons. For example the latency of your trading PC, the delay imposed by the broker to execute your trade (due to credit control to comply with margin requirements), the depth of the order book are not known or used in backtest.


Stop and limit orders - managed approach

In your case where the live strategy entered earlier than the backtest, the likely reason is that you used a stop or a limit order.

Let us take the case of a stop order: In a live environment the stop order is transformed to a market order, when the stop price is hit. The execution price is near the stop price. In a backtest any executions are shown with the time stamp of the bar close. However, the stop order should be excuted at a similar price.

It is important to understand that a backtest is performed on historical data. That means that you just have the historical bars (open, high, low, close and volume) but have no clue, what happened intra-bar. If you have a historical bar that lasts from 9:30 to 9:45 and that has hit a stop, you cannot tell whether the stop was hit at 9:32 or 9:44. Therefore the timestamp shown is always the time stamp of the bar, that is 9:45.

In real-time trading the stop will be hit when the market first trades at the stop price, which can be at any time between 9:30 and 9:45.


Unmanaged market orders

In case that you simply used unmanaged market orders and both the backtest and the live SIM strategy running in COBC = true, you will observe similar results. The only difference should be due to slippage.

Thanks for the reply.

I don't think the issue is stop orders, as again these strategies all use a market order (Enter Long, Enter Short) for entry and exit, not a limit order -- so they should fill instantly. They are also using a 1 minute chart, so a longer time based bar shouldn't be the issue. What I'm finding strange is that live sim results are going in EARLIER than the backtest entry, which I would assume means that the strategy is taking the signal intra-bar, rather than on the close (which is what the backtest is doing)...I can't think of any reason why my entry (and exit) times would be anything other than :00 or :01 in the order history. But instead I have fills all over the one minute period even when using market orders and in highly liquid markets, and ALL of them earlier than what the time stamp is for the backtest.

The bigger issue seems to be exits though -- entries almost always seem to be within a tick, so say 102.71 in live sim vs 102.70 in backtest, in spite of the time difference of almost up to a minute, or sometimes more, but the exits can differ wildly. Again, it seems to be because the live strategy is allowing itself to exit intrabar, BEFORE the close, while the backtest result is forced to wait, and thus the signal may be different at close and not trigger an exit after all. Exit times differ wildly between the two as well.

So that's my frustration here -- like you said, unmanaged market orders with COBC = true set to both SHOULD be showing similar results, with minor differences due to slippage -- but instead I am getting quite different results, particularly on the exit, and it seems to be because the live strategy is ignoring the close and executing immediately upon signal....

Think big, think positive, never show any sign of weakness. Always go for the throat. Buy low, sell high. Fear? That's the other guy's problem. In this building, it's either kill or be killed. You make no friends in the pits and you take no prisoners. One minute you're up half a million in soybeans and the next, boom, your kids don't go to college and they've repossessed your Bentley. Are you with me?
Reply With Quote
  #8 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


LightWeight View Post
Thanks for the reply.

I don't think the issue is stop orders, as again these strategies all use a market order (Enter Long, Enter Short) for entry and exit, not a limit order -- so they should fill instantly. They are also using a 1 minute chart, so a longer time based bar shouldn't be the issue. What I'm finding strange is that live sim results are going in EARLIER than the backtest entry, which I would assume means that the strategy is taking the signal intra-bar, rather than on the close (which is what the backtest is doing)...I can't think of any reason why my entry (and exit) times would be anything other than :00 or :01 in the order history. But instead I have fills all over the one minute period even when using market orders and in highly liquid markets, and ALL of them earlier than what the time stamp is for the backtest.

The bigger issue seems to be exits though -- entries almost always seem to be within a tick, so say 102.71 in live sim vs 102.70 in backtest, in spite of the time difference of almost up to a minute, or sometimes more, but the exits can differ wildly. Again, it seems to be because the live strategy is allowing itself to exit intrabar, BEFORE the close, while the backtest result is forced to wait, and thus the signal may be different at close and not trigger an exit after all. Exit times differ wildly between the two as well.

So that's my frustration here -- like you said, unmanaged market orders with COBC = true set to both SHOULD be showing similar results, with minor differences due to slippage -- but instead I am getting quite different results, particularly on the exit, and it seems to be because the live strategy is ignoring the close and executing immediately upon signal....

Live exits can only be taken intra-bar

- if you have set your strategy to COBC = false
- or if you use stop or limit orders

Please check your strategy und your settings.

Reply With Quote
Thanked by:
  #9 (permalink)
 
LightWeight's Avatar
 LightWeight 
Kirkland, WA/United States
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Optimus/Vision/Rithmic
Trading: Futures
Posts: 138 since Jul 2012
Thanks Given: 138
Thanks Received: 42


Fat Tails View Post
Live exits can only be taken intra-bar

- if you have set your strategy to COBC = false
- or if you use stop or limit orders

Please check your strategy und your settings.

Yes, but COBC = true
And the strategies use market orders

In other words I want my live strategies to replicate the backtest results as closely as possible, by also only going in and out at the close/open of the bar, when the signal is active. I don't want them to trade intra-bar, and yet they are anyway. In that post I linked to above, the one guy is saying you can add FirstTickOfBar && Close[1] to the code, and this will force the strategy to not enter trade until the first tick of the NEXT bar, and only if the strategy entry conditions are still in effect. I believe this is exactly how the backtest operates in its assumptions and why the results are different thus far from live testing. I assume this code could be applied to the exit as well. I would have thought that selecting COBC = true in the strategy GUI window would accomplish the same thing, but it does not apparently.

It's kind of amusing because most posts I see are by people who want the strategy to enter intra-bar, as soon as the signal generates, while instead I'm trying to delay it until the close of the bar.

Think big, think positive, never show any sign of weakness. Always go for the throat. Buy low, sell high. Fear? That's the other guy's problem. In this building, it's either kill or be killed. You make no friends in the pits and you take no prisoners. One minute you're up half a million in soybeans and the next, boom, your kids don't go to college and they've repossessed your Bentley. Are you with me?
Reply With Quote
  #10 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102



LightWeight View Post
Yes, but COBC = true
And the strategies use market orders

This is not possible.

For further discussion please attach your strategies and a few samples showing that the live simulation strategy entered prior to the backtest.

Reply With Quote




Last Updated on March 9, 2014


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts