highest bar close occuring within the last X number of bars . . . . - NinjaTrader Programming | futures io social day trading
futures io futures trading


highest bar close occuring within the last X number of bars . . . .
Updated: Views / Replies:11,880 / 37
Created: by jmejedi Attachments:5

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

highest bar close occuring within the last X number of bars . . . .

  #1 (permalink)
Elite Member
Lilburn, GA
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: VelocityFutures/TT
Favorite Futures: ES
 
jmejedi's Avatar
 
Posts: 62 since Jan 2011
Thanks: 13 given, 3 received

highest bar close occuring within the last X number of bars . . . .

sorry in advance if this already exists within this forum, but at least I can't find it and that's why I'm posting this as a new thread . . . . . . . . . . . . . . Here's the Q:

How would I accomplish the below in NinjaScript . . . . . .

// if CURRENT-BAR-CLOSE > HIGHEST-BAR-CLOSE within last 10 bars THEN enterLong()
//
// if CURRENT-BAR-CLOSE < LOWEST-BAR-CLOSE within last 10 bars THEN enterShort()
//
//


I'm thinking it would look something like this:

if ( Close[0] > INSERT-CODE-HERE-TO-DETERMINE-BAR-WITH-ITS-CLOSE-BEING-HIGHEST-AMONG-THE-#-OF-BARS-AGO )



Any help with this would be greatly appreciated !

Thanks in advance,

Jimmy

Reply With Quote
 
  #2 (permalink)
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.

 
  #3 (permalink)
Market Wizard
New Orleans, La (Mardi Gras City)
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Ninjatrader / Optimus Futures / AmpFutures
Favorite Futures: ES / 6E / 6B / CL
 
DavidHP's Avatar
 
Posts: 1,004 since Aug 2009
Thanks: 803 given, 1,367 received



jmejedi View Post
sorry in advance if this already exists within this forum, but at least I can't find it and that's why I'm posting this as a new thread . . . . . . . . . . . . . . Here's the Q:

How would I accomplish the below in NinjaScript . . . . . .

// if CURRENT-BAR-CLOSE > HIGHEST-BAR-CLOSE within last 10 bars THEN enterLong()
//
// if CURRENT-BAR-CLOSE < LOWEST-BAR-CLOSE within last 10 bars THEN enterShort()
//
//

Is this what you need?
From NT7 Help File:

 
Code
// Prints the highest  high value over the last 20 periods
double value = MAX(High, 20)[0]; Print("The current MAX value is " + value.ToString());
// Prints the lowest low value over the last 20 periods double value = MIN(Low, 20)[0]; Print("The current MIN value is " + value.ToString());

Rejoice in the Thunderstorms of Life . . .
Knowing it's not about Clouds or Wind. . .
But Learning to Dance in the Rain ! ! !
Reply With Quote
 
  #4 (permalink)
Elite Member
Lilburn, GA
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: VelocityFutures/TT
Favorite Futures: ES
 
jmejedi's Avatar
 
Posts: 62 since Jan 2011
Thanks: 13 given, 3 received

i don't think this is working . . . . .


// if CURRENT-BAR-CLOSE > HIGHEST-BAR-CLOSE within last 10 bars THEN enterLong()
if ( Close[0] > MAX(Close, 20)[0] ) {EnterLong();}
//
// if CURRENT-BAR-CLOSE < LOWEST-BAR-CLOSE within last 10 bars THEN enterShort()
if ( Close[0] < MIN(Close, 20)[0] ) {EnterShort();}
//


............... this code has got to be executed at some time,,,, I'm running back-testing on it............ & the back testing isn't resulting in any entries........... strange, b/c this situation happens all day, anytime, any day....



Please help ?

Reply With Quote
 
  #5 (permalink)
Elite Member
Lilburn, GA
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: VelocityFutures/TT
Favorite Futures: ES
 
jmejedi's Avatar
 
Posts: 62 since Jan 2011
Thanks: 13 given, 3 received

this code is executed within the method

OnBarUpdate()


.... furthermore,,,,,, I'm testing this on

6e

instrument . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Reply With Quote
 
  #6 (permalink)
Elite Member
Lilburn, GA
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: VelocityFutures/TT
Favorite Futures: ES
 
jmejedi's Avatar
 
Posts: 62 since Jan 2011
Thanks: 13 given, 3 received

alright, I think I found it:



"

NinjaScript > Language Reference > Data >
HighestBar()

Definition
Returns the number of bars ago the highest price value occurred for the lookback period.

Method Return Value
An int value that represents number of bars ago.

Syntax
HighestBar(IDataSeries series, int lookBackPeriod)

Parameters
lookBackPeriod
Number of bars back to include in the calculation
series
Any DataSeries type object such as an indicator, Close, High, Low, etc...


Examples
// Prints out the number of bars ago for the highest close of the current session
Print(HighestBar(Close, Bars.BarsSinceSession - 1).ToString());

"






please confirm this is correct as per my definition in my first post above ?

Reply With Quote
 
  #7 (permalink)
Elite Member
Lilburn, GA
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: VelocityFutures/TT
Favorite Futures: ES
 
jmejedi's Avatar
 
Posts: 62 since Jan 2011
Thanks: 13 given, 3 received

wait . . . . . . . . actually the above is wrong,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, what I really want is:



Close[HighestBar(Close, 10)]



, , , , , , Right ??

Reply With Quote
 
  #8 (permalink)
Elite Member
Lilburn, GA
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: VelocityFutures/TT
Favorite Futures: ES
 
jmejedi's Avatar
 
Posts: 62 since Jan 2011
Thanks: 13 given, 3 received

Apparently, that isn't right neither . . . . . . namely this:


// if CURRENT-BAR-CLOSE > HIGHEST-BAR-CLOSE within last 10 bars THEN enterLong()
if ( Close[0] > Close[HighestBar(Close, 10)] ) {EnterLong();}
//
// if CURRENT-BAR-CLOSE < LOWEST-BAR-CLOSE within last 10 bars THEN enterShort()
if ( Close[0] < Close[LowestBar(Close, 10)] ) {EnterShort();}
//


........... this code never gets executed during the course of the trading . . . . . . . . . . . . . I'm really losing it,,,,, anyone please help out ?


Thanks in advance,

Jimmy Espana

Reply With Quote
 
  #9 (permalink)
Trading Apprentice
London
 
Futures Experience: None
Platform: NinjaTrader
Favorite Futures: Currencies
 
Posts: 27 since Jun 2011
Thanks: 4 given, 2 received

Hi All,

Do you have any ideas why this is not working? if (CrossAbove(Close,MAX(High,5)[1],1))
I want a conbition which is will do something when the close price cross above the highest price of the previous 5 period

Thanks

Reply With Quote
 
  #10 (permalink)
Urban Samurai
Chicago IL
 
Futures Experience: Intermediate
Platform: Ninja, MT4,TOS, SC, Matlab
Broker/Data: CQG, AMP, MB, DTN
Favorite Futures: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,039 since Jun 2010
Thanks: 226 given, 688 received



Loukas View Post
Hi All,

Do you have any ideas why this is not working? if (CrossAbove(Close,MAX(High,5)[1],1))
I want a conbition which is will do something when the close price cross above the highest price of the previous 5 period

Thanks

Not sure what your intent is, but try this out. Of course you'll have to declare these two dataSeries above I added called 'temp' and 'temp1'. But if you want to use the CrossAbove function, I don't think you can index two different bars, from two different times like you want. So here i've captured into a DataSeries the PRIOR bar into the current bar... if that makes any sense?

 
Code
			temp[0] = MAX(High, 5)[0];
			temp1[0] = temp[1];
			if (CrossAbove(Close, temp1, 1)  )
			{
				DrawArrowUp("arrow"+CurrentBar, true, 0, Low[0]-12*TickSize, Color.Green);
			}

Attached Thumbnails
highest bar close occuring within the last X number of bars . . . .-prime2011-09-03_194602.jpg  

Last edited by forrestang; September 3rd, 2011 at 10:20 PM.
Reply With Quote
The following user says Thank You to forrestang for this post:

Reply



futures io > > > > > highest bar close occuring within the last X number of bars . . . .

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
number of ticks in a bar/ms timestamp ? sam028 NinjaTrader Programming 15 September 21st, 2012 08:50 AM
How to program price cross below a number of previous bars Twiddle NinjaTrader Programming 8 May 17th, 2011 05:58 PM
how to count in nt7 the number of bars that have closed? anniebee321 NinjaTrader 9 April 26th, 2011 12:27 PM
How do I access the bar number under the cursor? koganam NinjaTrader Programming 3 September 6th, 2010 10:25 AM
Close[0] not waiting until bar close dsraider NinjaTrader Programming 4 February 11th, 2010 06:49 PM


All times are GMT -4. The time now is 12:09 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-17 in 0.13 seconds with 20 queries on phoenix via your IP 54.90.92.204