Bars Ago in an indicator - NinjaTrader Programming | futures io social day trading
futures io futures trading


Bars Ago in an indicator
Updated: Views / Replies:3,945 / 22
Created: by patbateman Attachments:1

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
 1  
 
Thread Tools Search this Thread
 

Bars Ago in an indicator

  #11 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,653 since Mar 2010
Thanks: 4,226 given, 25,602 received
Forum Reputation: Legendary


patbateman View Post
The bars ago function does NOT work when creating ninjascript for indicators. It ONLY works for creating indicators for strategies.

In other words, if you make an indicator that is simply Close[10], it will not function. It will compile, but the compiler will not read it.

So, I'm trying to figure out a way to use something like bars ago that does not involve the traditional approach.

If I can get just Close[0] - Close[20] to work, I can go from there.

Hope this helps!

The method works for all indicators, but you can only access Close[20] for bars > 20. You need to add the following line in the beginning of OnBarUpdate()

 
Code
if (CurrentBar < 20)
 return;


and the code should run after compiling it.

Reply With Quote
The following 2 users say Thank You to Fat Tails for this post:
 
  #12 (permalink)
Elite Member
Cedar Rapids, iowa
 
Futures Experience: Intermediate
Platform: Ninjatrader
Broker/Data: Ninjatrader - Continuum
Favorite Futures: 6E, TF, 6J
 
Tasker_182's Avatar
 
Posts: 626 since Aug 2009
Thanks: 426 given, 1,126 received

I think this clarifies it...

Abbott: You throw the ball to first base.
Costello: Then who gets it?
Abbott: Naturally.
Costello: Naturally.
Abbott: Now you've got it.
Costello: I throw the ball to Naturally.
Abbott: You don't! You throw it to Who!
Costello: Naturally.
Abbott: Well, that's it—say it that way.
Costello: That's what I said.
Abbott: You did not.
Costello: I said I throw the ball to Naturally.
Abbott: You don't! You throw it to Who!
Costello: Naturally.

"Money is better than poverty, if only for financial reasons." - Woody Allen
Reply With Quote
The following 3 users say Thank You to Tasker_182 for this post:
 
  #13 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,653 since Mar 2010
Thanks: 4,226 given, 25,602 received
Forum Reputation: Legendary



Tasker_182 View Post
I think this clarifies it...

Abbott: You throw the ball to first base.
Costello: Then who gets it?
Abbott: Naturally.
Costello: Naturally.
Abbott: Now you've got it.
Costello: I throw the ball to Naturally.
Abbott: You don't! You throw it to Who!
Costello: Naturally.
Abbott: Well, that's it—say it that way.
Costello: That's what I said.
Abbott: You did not.
Costello: I said I throw the ball to Naturally.
Abbott: You don't! You throw it to Who!
Costello: Naturally.


I was not aware that Abbott and Costello were traders?

Reply With Quote
 
  #14 (permalink)
Elite Member
NY, NY
 
Futures Experience: None
Platform: T4, NinjaTrader
Favorite Futures: All!
 
patbateman's Avatar
 
Posts: 235 since Mar 2012
Thanks: 113 given, 193 received


Tasker_182 View Post
Maybe I'm overthinking this. Lets use your example as an example, Close[0] - Close[20]

if you create a variable to put the results in, will that not meet your needs?

IE:

double diff = Close[0] - Close[20] ;

So the above code statement declares a variable called "diff" that is a double type. Next (on the other side of equals) the difference between Close[0] and Close[20] is put into diff. The ";" ends the C# statement.

Is that what you want?

Tried this, and it didn't work.

Also tried doing them in separate Ninjascript files... no go...

I confirmed with NT help, that bars ago does not work in indicators, only strategies.

"A Jedi's strength flows from the force."
-Yoda
Reply With Quote
 
  #15 (permalink)
Elite Member
Cedar Rapids, iowa
 
Futures Experience: Intermediate
Platform: Ninjatrader
Broker/Data: Ninjatrader - Continuum
Favorite Futures: 6E, TF, 6J
 
Tasker_182's Avatar
 
Posts: 626 since Aug 2009
Thanks: 426 given, 1,126 received


Fat Tails View Post
I was not aware that Abbott and Costello were traders?

I believe they traded quips, quite frequently.

"Money is better than poverty, if only for financial reasons." - Woody Allen
Reply With Quote
The following 2 users say Thank You to Tasker_182 for this post:
 
  #16 (permalink)
Elite Member
Cedar Rapids, iowa
 
Futures Experience: Intermediate
Platform: Ninjatrader
Broker/Data: Ninjatrader - Continuum
Favorite Futures: 6E, TF, 6J
 
Tasker_182's Avatar
 
Posts: 626 since Aug 2009
Thanks: 426 given, 1,126 received


patbateman View Post
Tried this, and it didn't work.

Also tried doing them in separate Ninjascript files... no go...

I confirmed with NT help, that bars ago does not work in indicators, only strategies.

Maybe you need to share with us the whole thing you are trying to do because there is clearly misunderstanding of your needs.

"Money is better than poverty, if only for financial reasons." - Woody Allen
Reply With Quote
 
  #17 (permalink)
Elite Member
NY, NY
 
Futures Experience: None
Platform: T4, NinjaTrader
Favorite Futures: All!
 
patbateman's Avatar
 
Posts: 235 since Mar 2012
Thanks: 113 given, 193 received

Not sure how much more clear I can get.

There are TWO types of ninjascripts: INDICATORS and STRATEGIES.

The BARS AGO function *ONLY* works for STRATEGIES.

So I need to write

Close[0]-Close[30]

in an alternate way WITHOUT using the [30]. That is all. No need to debate if this is true or not, since confusion on that part is irrelevant, since I've confirmed the issue with NT staff.



Again,

How can I write

Close[0]-Close[10]

in a way that does not use the [10]?

"A Jedi's strength flows from the force."
-Yoda
Reply With Quote
 
  #18 (permalink)
Elite Member
Cedar Rapids, iowa
 
Futures Experience: Intermediate
Platform: Ninjatrader
Broker/Data: Ninjatrader - Continuum
Favorite Futures: 6E, TF, 6J
 
Tasker_182's Avatar
 
Posts: 626 since Aug 2009
Thanks: 426 given, 1,126 received


patbateman View Post
Not sure how much more clear I can get.

There are TWO types of ninjascripts: INDICATORS and STRATEGIES.

The BARS AGO function *ONLY* works for STRATEGIES.

So I need to write

Close[0]-Close[30]

in an alternate way WITHOUT using the [30]. That is all. No need to debate if this is true or not, since confusion on that part is irrelevant, since I've confirmed the issue with NT staff.



Again,

How can I write

Close[0]-Close[10]

in a way that does not use the [10]?


int barsAgo = 10;

double diff = Close[0] - Close[barsAgo];

"Money is better than poverty, if only for financial reasons." - Woody Allen
Reply With Quote
The following user says Thank You to Tasker_182 for this post:
 
  #19 (permalink)
Market Wizard
Sarasota FL
 
Futures Experience: Intermediate
Platform: NinjaTrader, Sierra Chart
Favorite Futures: ES
 
Posts: 3,635 since Jan 2013
Thanks: 26,759 given, 11,115 received
Forum Reputation: Legendary


Fat Tails View Post
The method works for all indicators, but you can only access Close[20] for bars > 20. You need to add the following line in the beginning of OnBarUpdate()

 
Code
if (CurrentBar < 20)
 return;


and the code should run after compiling it.


patbateman View Post
Tried this, and it didn't work.

Also tried doing them in separate Ninjascript files... no go...

I confirmed with NT help, that bars ago does not work in indicators, only strategies.


patbateman View Post
Not sure how much more clear I can get.

There are TWO types of ninjascripts: INDICATORS and STRATEGIES.

The BARS AGO function *ONLY* works for STRATEGIES.

So I need to write

Close[0]-Close[30]

in an alternate way WITHOUT using the [30]. That is all. No need to debate if this is true or not, since confusion on that part is irrelevant, since I've confirmed the issue with NT staff.



Again,

How can I write

Close[0]-Close[10]

in a way that does not use the [10]?

Sorry, but everyone who is trying to help you writes indicators and uses the [bars ago] routinely in their indicators.

Close[0] - Close[10] works just fine in indicators; we all do this all the time. You just need to have the statement @Fat Tails mentioned to check that you have enough bars available to make the subtraction.

There may be a misunderstanding between you and NT support about what you are trying to accomplish, but, believe me, everyone who writes indicators uses the Close[bars ago] expression successfully. I do it and it works fine.

If you post the full code that is having a problem, I'm sure someone will help you fix it.

Bob.

Reply With Quote
The following 2 users say Thank You to bobwest for this post:
 
  #20 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,653 since Mar 2010
Thanks: 4,226 given, 25,602 received
Forum Reputation: Legendary


@patbateman: You can use barsAgo without limitations in indicators. The problem is that you do not disclose the information necessary to solve your problem. We cannot fix your bug, if you do not show us the code.

Please export the indicator with NinjaTrader and post it here. In a few minutes the bug will be identified and the discussion will be over.

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

Reply



futures io > > > > > Bars Ago in an indicator

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Scan for Gap Up N Bars Ago idenr ThinkOrSwim Programming 1 April 10th, 2013 10:17 PM
difference between prevclose and close of 1 day ago?? adam081527 EasyLanguage Programming 3 June 30th, 2012 01:52 PM
color bars indicator esam_jir NinjaTrader Programming 3 November 16th, 2010 04:06 AM
i am looking for median renko bars indicator dellcnu Traders Hideout 6 August 5th, 2010 08:38 PM
x sessions ago SARdynamite NinjaTrader Programming 15 July 13th, 2010 09:20 PM


All times are GMT -4. The time now is 07:05 AM.

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-16 in 0.14 seconds with 20 queries on phoenix via your IP 54.226.113.250