Noob OnBarUpdate() question - NinjaTrader Programming | futures io social day trading
futures io futures trading


Noob OnBarUpdate() question
Updated: Views / Replies:3,961 / 5
Created: by SetFreeByTruth Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 100,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

 
 
Thread Tools
 

Noob OnBarUpdate() question

 
Minneapolis Minnesota
 
 
Posts: 5 since Mar 2011
Thanks: 2 given, 0 received

Noob OnBarUpdate() question

I have years of MT4 programming experience but am brand-new to NinjaTrader.

When does the OnBarUpdate() strategy event fire? I would expect it to fire whenever the current bar is updated, similiar to MT4's start() function, but when I load my test strategy it immediately fires for every historical bar in the chart. I added some debug lines to display Time[0] for each call to OnBarUpdate() and it's clearly being called hundreds of times as there are hundreds of bars on my 1-Min chart. This all happens within 1-2 seconds of enabling the strategy.

Am I loading the strategy incorrectly? It's behaving as if I'm doing a backtest, not a forward test. Again, for those familiar with MT4, I'm trying to duplicate MT4's start() functionality, which fires on each new incoming tick.

Thank you!

 
 
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
 
Dallas, TX
 
Trading Experience: Beginner
Platform: Ninjatrader
Broker/Data: Zen-Fire
Favorite Futures: ZN, 6E
 
gulabv's Avatar
 
Posts: 286 since May 2010
Thanks: 161 given, 166 received


You need to set the CalculateOnBarClose property to TRUE in the Initialize() method of the indicator/strategy for OnBarUpdate() to fire once your tick/range/minute/renko/etc. bar closes otherwise this event will fire for each incoming tick of data...

 
 
Minneapolis Minnesota
 
 
Posts: 5 since Mar 2011
Thanks: 2 given, 0 received

Clarification

Hello gulabv,

Thank you for the reply. I am already setting CalculateOnBarClose to TRUE in the Initialize method as you recommended.

The problem is: when I first load the strategy, OnBarUpdate() is getting called for every pre-existing historical bar in the chart. In other words: not just for new incoming ticks, but also for every bar already on the chart.

Again, it's acting like it's in "backtest" mode. I want it to process only future ticks, not past ticks. I must be missing something very elementary.

Kind regards...

 
 
Dallas, TX
 
Trading Experience: Beginner
Platform: Ninjatrader
Broker/Data: Zen-Fire
Favorite Futures: ZN, 6E
 
gulabv's Avatar
 
Posts: 286 since May 2010
Thanks: 161 given, 166 received

Check out the help in NT for the keyword HISTORICAL

Indicates if the NinjaScript object is running on historical data. With a strategy, when running a backtest, this property will always return true. When running a live strategy, this property will be true until the strategy starts processing real-time data. The property can be of value for many different applications.


1. Filtering out historical data for real-time strategies that does not require any historical data to initialize.


Property Value
This property returns true if the strategy is running on historical data; otherwise, false.


Syntax
Historical


Property Of
Custom Indicator, Custom Strategy


Examples
protected override void OnBarUpdate()
{
// Only run on real-time data
if (Historical)
return;
}

The following user says Thank You to gulabv for this post:
 
 
Minneapolis Minnesota
 
 
Posts: 5 since Mar 2011
Thanks: 2 given, 0 received

Now we're talkin'! That was exactly what I needed. Thank you!


 



futures io > > > > > Noob OnBarUpdate() question
Thread Tools



Upcoming Webinars and Events (4:30PM ET unless noted)
 

futures io is celebrating 10-years w/ over $18,000 in prizes!

Right now
 

$250 Amazon Gift Cards with our "Thanks Contest" challenge!

Right now
 

Webinar: The Seven Most Effective Trading Setups w/Peter Davies @ Jigsaw

Oct 17
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Complete noob programming MTF and nested indicator nirajkrishna Traders Hideout 2 March 26th, 2011 07:17 AM
CalculateOnBarClose as a bool or as a simulation within OnBarUpdate chapter SARdynamite NinjaTrader Programming 5 July 5th, 2010 01:02 AM
VWAP question Todd NinjaTrader Programming 3 March 14th, 2010 06:13 PM
Technical Question kaywai NinjaTrader Programming 3 March 6th, 2010 04:40 AM
A Strategy Question... keepdchange NinjaTrader 4 November 23rd, 2009 05:58 AM


All times are GMT -4. The time now is 10:43 PM. (this page content is cached, log in for real-time version)

Copyright © 2019 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts