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,098 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?

  #11 (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
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.

@Fat Tails I've attached the code for the strategy here, as well as screen shots of the trades from a backtest over the last week vs. what the actual results were while running the strategy in live sim. You should be able to see clearly that:

A) the strategy uses market orders and COBC = true
B) the strategy in live trading always enters before the backtest
c) while the entry prices are usually still the same or within a tick, the exits are quite different

Also at the time of running this it was not including commission properly due to an error on my end (the backtest is including it), but all that means is that the discrepancy is even larger in terms of net profit. As it stands now, backtest shows a loss of $415 for the week, while live trading (WITHOUT comish) shows a loss of $850, so the live result was twice as bad as the backtest would indicate it would be.

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?
Attached Files
Elite Membership required to download: CversARSShortSI.cs
Reply With Quote

Can you help answer these questions
from other members on NexusFi?
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
Are there any eval firms that allow you to sink to your …
Traders Hideout
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
Exit Strategy
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
65 thanks
Funded Trader platforms
40 thanks
Battlestations: Show us your trading desks!
29 thanks
NexusFi site changelog and issues/problem reporting
23 thanks
The Program
19 thanks

  #12 (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
@Fat Tails I've attached the code for the strategy here, as well as screen shots of the trades from a backtest over the last week vs. what the actual results were while running the strategy in live sim. You should be able to see clearly that:

A) the strategy uses market orders and COBC = true
B) the strategy in live trading always enters before the backtest
c) while the entry prices are usually still the same or within a tick, the exits are quite different

Also at the time of running this it was not including commission properly due to an error on my end (the backtest is including it), but all that means is that the discrepancy is even larger in terms of net profit. As it stands now, backtest shows a loss of $415 for the week, while live trading (WITHOUT comish) shows a loss of $850, so the live result was twice as bad as the backtest would indicate it would be.

@LightWeight: Your strategy uses both stop and limit orders, as you have set a stop loss and a profit target. Stop and limit orders will be executed intra-bar when trading live. During a backtest they are shown with the time stamp of the bar close.

Reply With Quote
Thanked by:
  #13 (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: Your strategy uses both stop and limit orders, as you have set a stop loss and a profit target. Stop and limit orders will be executed intra-bar when trading live. During a backtest they are shown with the time stamp of the bar close.

@Fat Tails Yes that's true, so that does explain the intra-bar discrepancy for live trading IF the stop or target is hit, but half the time neither the stop or target is hit, the signal changes and the strategy takes itself out with a market exit...but again, intra-bar, not waiting until the close like the backtest would (or like the strategy SHOULD if COBC = true).

Also this still doesn't explain to me why ENTRIES are occurring before the time stamps in backtest, as all entries are market orders, and should be COBC, and thus entered immediately as soon as the next bar starts, as indicated in the back test. Like I said my gut feeling is that the difference in results is largely explained by two things -- live trading executing entry intra-bar, instead of waiting until close; and live trading immediately exiting if exit conditions are reached intra-bar, instead of determining on the close and only exiting if the signal still holds (which is what backtest is doing). Because obviously the exit signal may no longer exist when the bar finally closes, then exit in backtest vs. live trading would vary considerably.

This is what is really frustrating me right now -- I have strategies that are profitable when entering and exiting at bar close, so in theory if I can get my live trading to do the same, to mirror that as closely as possible, then they should do better than they are currently....but as I said Ninja seems to be completely ignoring COBC and simply executing both entry AND exit as soon as signal is received.

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
  #14 (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
@Fat Tails Yes that's true, so that does explain the intra-bar discrepancy for live trading IF the stop or target is hit, but half the time neither the stop or target is hit, the signal changes and the strategy takes itself out with a market exit...but again, intra-bar, not waiting until the close like the backtest would (or like the strategy SHOULD if COBC = true).

Also this still doesn't explain to me why ENTRIES are occurring before the time stamps in backtest, as all entries are market orders, and should be COBC, and thus entered immediately as soon as the next bar starts, as indicated in the back test. Like I said my gut feeling is that the difference in results is largely explained by two things -- live trading executing entry intra-bar, instead of waiting until close; and live trading immediately exiting if exit conditions are reached intra-bar, instead of determining on the close and only exiting if the signal still holds (which is what backtest is doing). Because obviously the exit signal may no longer exist when the bar finally closes, then exit in backtest vs. live trading would vary considerably.

This is what is really frustrating me right now -- I have strategies that are profitable when entering and exiting at bar close, so in theory if I can get my live trading to do the same, to mirror that as closely as possible, then they should do better than they are currently....but as I said Ninja seems to be completely ignoring COBC and simply executing both entry AND exit as soon as signal is received.

@LightWeight: Yes, I can see that you strategy entered intra-bar during the live SIM test. I think that you had probably set the strategy to COBC = false via the dialogue box. Best you run it again and make sure that it is set to COBC = true.

Settings in the dialogue box override the line "CalculateOnBarClose = true", which is part of the Initialize section of the indicator.

Reply With Quote
Thanked by:
  #15 (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: Yes, I can see that you strategy entered intra-bar during the live SIM test. I think that you had probably set the strategy to COBC = false via the dialogue box. Best you run it again and make sure that it is set to COBC = true.

Settings in the dialogue box override the line "CalculateOnBarClose = true", which is part of the Initialize section of the indicator.

@Fat Tails Unfortunately that isn't the problem either, I've carefully checked every time that COBC = true when setting up the strategy to run (it is also the default setting). In fact I even tried deliberately setting it to false (on another computer) on the off chance Ninja had it backward, but that just caused even more entries (all intra-bar as well). So the actual code is COBC = true, the dialogue box is COBC = true, and yet the strategies STILL go in early (and exit early when using a market order as well). I suppose at this point I should just ask Ninja support what's going on and see if they know, as we seem to agree that given the settings I have the entries in SIM should mirror the entries in backtest, and yet they do not, so something is clearly amiss.

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
  #16 (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
@Fat Tails Unfortunately that isn't the problem either, I've carefully checked every time that COBC = true when setting up the strategy to run (it is also the default setting). In fact I even tried deliberately setting it to false (on another computer) on the off chance Ninja had it backward, but that just caused even more entries (all intra-bar as well). So the actual code is COBC = true, the dialogue box is COBC = true, and yet the strategies STILL go in early (and exit early when using a market order as well). I suppose at this point I should just ask Ninja support what's going on and see if they know, as we seem to agree that given the settings I have the entries in SIM should mirror the entries in backtest, and yet they do not, so something is clearly amiss.

Did you run the SIM strategy on other than 1-minute bars?

Reply With Quote
  #17 (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
Did you run the SIM strategy on other than 1-minute bars?

@Fat Tails No, the strategy ran on 1 minute bars, the same as the back test. I do have other strategies that run on say 3 minute or 5 minute bars, but again I keep the live sim with the same settings as the backtest, and have the same issues. I've also checked to make sure my PC clock is synched, though I don't think that would be the problem.

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
  #18 (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

Okay, I think I may have figured some of this out then, but I'm not sure. First of all, if the time stamp for a backtest strategy entry is 7:45:00, would I be correct in assuming that the signal was actually calculated at 7:44:00, but that backtest is using the close price (and time) of the signal bar for entry? My assumption was that if it calculated the signal for entry as occurring on the bar close at 7:43:59/7:44:00, that it would then enter at the same spot...but it seems now that it actually enters on the close (or close price) of the bar immediately after the signal is calculated, which looks like a minute delay.

Second, I went back and looked at my time stamps for entry and then a 1 second chart, and I realized the entry problem -- because these are sim orders, then even though the are programmed for market trades, they can't actually fill until a real world trade takes place. In a market like Silver and in the evening, that may take 40 seconds or more into the one minute candle before a trade happens and a time stamp and price can be recorded in the simulator. So if we use what I'm guessing above -- that the entry signal was calculated at the close of the previous bar -- then COBC is in fact working properly and the signal was on the PREVIOUS bar, the time delay is simply due to the nature of sim requiring real world trades and the delay that causes, whereas in live trading obviously a market order would be filled right away, and I would see time stamp entries right around the bar open.

I think that solves my confusion about the entry time discrepancy, but the exit conditions are a little hazy. Again, as for the time delay I have to assume that's the same reason -- sim waiting for real world trades before it can record a transaction. The confusing bit is that sometimes the backtest exits much later, which makes me think that because backtest is exiting on the close, it is first calculating once again if the signal still exists BEFORE it will take itself out, and naturally sometimes the signal will have disappeared, so the strategy will actually not exit, while in live trading, because it did not wait until the bar close to exit, it would have already triggered.

If so, then if I wanted my exits to mirror backtest results more closely it seems like I would have to code the strategy to wait until the first tick of the next bar before exiting, and hope/assume that it is calculating whether the signal still exists before doing so. This is all conjecture but it's the closest I've gotten so far....at worst it seems like if I want live trading to more closely match backtesting then I need to code the strategy to wait until the first tick of the next bar to trade.

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
Thanked by:
  #19 (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
Second, I went back and looked at my time stamps for entry and then a 1 second chart, and I realized the entry problem -- because these are sim orders, then even though the are programmed for market trades, they can't actually fill until a real world trade takes place. In a market like Silver and in the evening, that may take 40 seconds or more into the one minute candle before a trade happens and a time stamp and price can be recorded in the simulator. So if we use what I'm guessing above -- that the entry signal was calculated at the close of the previous bar -- then COBC is in fact working properly and the signal was on the PREVIOUS bar, the time delay is simply due to the nature of sim requiring real world trades and the delay that causes, whereas in live trading obviously a market order would be filled right away, and I would see time stamp entries right around the bar open.

This looks like the key to understanding the different time stamps.

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