NexusFi: Find Your Edge


Home Menu

 





Is NT7 "CalculateOnBarClose = false" broken?


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Curbfeeler with 3 posts (3 thanks)
    2. looks_two Big Mike with 2 posts (5 thanks)
    3. looks_3 Trader.Jon with 1 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 3,887 views
    2. thumb_up 8 thanks given
    3. group 2 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread

Is NT7 "CalculateOnBarClose = false" broken?

  #1 (permalink)
 Curbfeeler 
Central Iowa
 
Experience: Beginner
Platform: NinjaTrader
Posts: 22 since Nov 2009
Thanks Given: 34
Thanks Received: 16

I am trying to code a quick indicator which will write out some text on each incoming tick. I'm on a 333 tick chart, just crossed over the swing indicator, and I want to write a line of HTML for each high and each low from the entry. I'm just trying to get some simple stats about risk:reward.

For hours I've been struggling and suddenly realized my code is fine. I think there is something wrong with "COBC = false" in NT7 beta 20, because my simple indicator is only called on the first tick of the bar.

I went back to the drawing board and wrote the simplest possible indicator, just to dumb things down and test. Guess what....

 
Code
        protected override void Initialize()
        {
            Overlay				= false;
			CalculateOnBarClose = false;

        }

         protected override void OnBarUpdate()
        {
			
				if (FirstTickOfBar)
				{
					Print("TICK 1");
				}
				else{
					Print("ELSE");
				}
				
        }
The output says...

TICK 1
TICK 1
TICK 1
TICK 1
TICK 1
TICK 1
TICK 1

Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Exit Strategy
NinjaTrader
Better Renko Gaps
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
MC PL editor upgrade
MultiCharts
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
36 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
19 thanks
Spoo-nalysis ES e-mini futures S&P 500
18 thanks
GFIs1 1 DAX trade per day journal
16 thanks
  #3 (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,440 since Jun 2009
Thanks Given: 33,214
Thanks Received: 101,599


Historical charts and backtesting are incapable of COBC = false. It is a design limitation.

COBC = false is only available on live incoming data. So make sure your test is live incoming data in a moving market, and not based on adding the indicator to a chart --- at which point it is historical data only.

You could do:

 
Code
                            
if (Historical) return; 

At the top of your code.

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
  #4 (permalink)
 Curbfeeler 
Central Iowa
 
Experience: Beginner
Platform: NinjaTrader
Posts: 22 since Nov 2009
Thanks Given: 34
Thanks Received: 16

Thanks Mike. This explains what I was seeing then. I added another timeframe (single tick), and this seems to have fixed my problem. Of course my code is now much more complex than the simple HTML-generating indicator that I envisioned, but it's working for the most part.

Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #5 (permalink)
 
Trader.Jon's Avatar
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
Posts: 473 since Jul 2009
Thanks Given: 401
Thanks Received: 184


Big Mike View Post
Historical charts and backtesting are incapable of COBC = true. It is a design limitation.

COBC = false is only available on live incoming data. So make sure your test is live incoming data in a moving market, and not based on adding the indicator to a chart --- at which point it is historical data only.

You could do:

 
Code
                            
if (Historical) return; 

At the top of your code.

Mike

Mike,

""Historical charts and backtesting are incapable of COBC = true""

I think I am confused: this is from the NT7 f1 help:
If true, OnBarUpdate() is called on the close of each bar otherwise it is called on each incoming tick. This property should ONLY be set in an Initialize() method and be the last statement within that method.

· When indicators or strategies are running on historical data, OnBarUpdate() is only called on the close of each historical bar even if this property is set to false. This is due to the fact that with a historical data set, only the OHLCVT of the bar is known and not each tick that made up the bar.

· The CalculateOnBarClose property of indicators embedded within a strategy are overriden by the CalculateOnBarClose property of the strategy

Doesnt this mean that COBC=true is only workable option in backtesting/historical charts?

Jon

Reply With Quote
  #6 (permalink)
 Curbfeeler 
Central Iowa
 
Experience: Beginner
Platform: NinjaTrader
Posts: 22 since Nov 2009
Thanks Given: 34
Thanks Received: 16


Trader.Jon View Post

Doesnt this mean that COBC=true is only workable option in backtesting/historical charts?

Jon

I am no expert at this. I am a software developer with over 10 years experience, so my coding skills are fine, but NT has a bit of a learning curve.

I found a workaround and was able to get my indicator to be called for each incoming tick, but I had to add a 1-tick timeframe to my indicator. This means that you will have to reference price in a different way throughout your indicator. Instead of High[0] you will use Highs[0][0]. The first series of the array refers to which timeframe.

For me, I want to check for a crossover with each incoming tick, so I use this...

 
Code
					//CROSSOVER HIT!
					if (Closes[1][0] < (SMA(BarsArray[0],12)[0]-.2) && !bLongFirstIn && bLongSignalHit){
This means the 1-tick dataset crosses the 333 tick SMA(12). Hope that helps. There are other examples, but I will tell you it's a pain once you commit to multiple timeframes. Everything you code becomes more complex.

Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:
  #7 (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,440 since Jun 2009
Thanks Given: 33,214
Thanks Received: 101,599


Trader.Jon View Post
Mike,

""Historical charts and backtesting are incapable of COBC = true""

Was a type-o, I meant false. The very next sentence I said "COBC = false is only available on live incoming data.". I have corrected the type-o.

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
Thanked by:




Last Updated on August 26, 2010


© 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