NinjaTrader previous bars OnBarUpdate problem - NinjaTrader | futures io social day trading
futures io futures trading


NinjaTrader previous bars OnBarUpdate problem
Updated: Views / Replies:779 / 2
Created: by Elenchus 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 90,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

Reply
 
Thread Tools Search this Thread
 

NinjaTrader previous bars OnBarUpdate problem

  #1 (permalink)
Trading Apprentice
Sydney
 
Futures Experience: Beginner
Platform: Ninja
Favorite Futures: NA
 
Posts: 2 since Dec 2014
Thanks: 1 given, 1 received

NinjaTrader previous bars OnBarUpdate problem

Hello,
I am trying to create an indicator using previous closing prices, however I ran into some problems. I've tried some troubleshooting, and come across something strange. Using Plot0.Set(Close[1]); in OnBarUpdate will not plot anything, nor will any value >0. I can use negative numbers, which will plot the close of the next bar (as expected), and the current bar will plot, but I can't get any previous prices to plot, nor can I work with Close[1] for calculations. I feel like I'm missing something obvious, but I have no idea what it is. Can anyone help?

Reply With Quote
 
  #2 (permalink)
Market Wizard
Columbus, OH
 
Futures Experience: None
Platform: NT 8, TOS
Favorite Futures: ES
 
Silvester17's Avatar
 
Posts: 3,332 since Aug 2009
Thanks: 4,579 given, 10,313 received

Answer
This post has been selected as an answer to the original posters question Answer


Elenchus View Post
Hello,
I am trying to create an indicator using previous closing prices, however I ran into some problems. I've tried some troubleshooting, and come across something strange. Using Plot0.Set(Close[1]); in OnBarUpdate will not plot anything, nor will any value >0. I can use negative numbers, which will plot the close of the next bar (as expected), and the current bar will plot, but I can't get any previous prices to plot, nor can I work with Close[1] for calculations. I feel like I'm missing something obvious, but I have no idea what it is. Can anyone help?

it always helps to check for errors. you probably get an error message in the log, saying "you're accessing an index with a value ...."

in your case, if you want to access the previous bar closing price, you'll need to add something like this:

 
Code
        protected override void OnBarUpdate()
        {
	    if (CurrentBar < 1)  
		return;
            
            Plot0.Set(Close[1]);

Reply With Quote
The following user says Thank You to Silvester17 for this post:
 
  #3 (permalink)
Trading Apprentice
Sydney
 
Futures Experience: Beginner
Platform: Ninja
Favorite Futures: NA
 
Posts: 2 since Dec 2014
Thanks: 1 given, 1 received



Silvester17 View Post
it always helps to check for errors. you probably get an error message in the log, saying "you're accessing an index with a value ...."

in your case, if you want to access the previous bar closing price, you'll need to add something like this:

 
Code
        protected override void OnBarUpdate()
        {
	    if (CurrentBar < 1)  
		return;
            
            Plot0.Set(Close[1]);


Ah, of course, that makes sense. Thank you very much.

Reply With Quote
The following user says Thank You to Elenchus for this post:

Reply



futures io > > > > NinjaTrader previous bars OnBarUpdate problem

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ninjascript -- Setting stop loss based on previous bars bstzgr The Elite Circle 6 August 25th, 2014 08:40 AM
current and previous Bar print highs/low above bars on chart Guss NinjaTrader 0 February 13th, 2014 12:28 PM
Reversal bars type problem alazif NinjaTrader 0 January 19th, 2014 08:02 PM
Backtesting range bars - problem? patbateman NinjaTrader 5 April 17th, 2012 12:19 AM
How to program price cross below a number of previous bars Twiddle NinjaTrader Programming 8 May 17th, 2011 05:58 PM


All times are GMT -4. The time now is 05:04 PM.

Copyright © 2017 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
Page generated 2017-12-11 in 0.08 seconds with 25 queries on phoenix via your IP 54.226.132.197