Highest bar between 20 and 40 bars ago - futures io
futures io futures trading



Highest bar between 20 and 40 bars ago


Discussion in NinjaTrader

Updated by DavidBodhi
    1. trending_up 1,308 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 5 replies
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 100,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
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

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

 
Thread Tools Search this Thread
 

Highest bar between 20 and 40 bars ago

  #1 (permalink)
Milwaukee, WI, USA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Equities
 
DavidBodhi's Avatar
 
Posts: 137 since Oct 2014
Thanks: 10 given, 119 received

Highest bar between 20 and 40 bars ago

Hi -

I am aware of how to get the highest high/lowest low within the last X number of bars AND how to determine how many bars back each of those is.

What I'd like to do is find the highest high within X number of bars PRIOR to the highest high within X number of bars.

Huh, you say?

So, let's say I use MAX(High, 20)[1].
That tells me what the highest high in the last 20 bars was.
Then I use HighestBar(High, 20) and that tells me the actual value of that highest high.

Now, I want to find the highest high within the 20 bars prior to the high I just found, above.

Can anyone suggest code to do this? Or point to someone else's solution?

Thanks, in advance.

(My intention is to home in on the high/low cycles within a trading range, figuring out the width of the range and how many bars apart the highs and lows are.)

Follow me on Twitter Reply With Quote

Can you help answer these questions
from other members on futures io?
Convert NinjaTrader NT7 indicator to Tradestation EasyLanguage and RADARSCREEN
Platforms and Indicators
Issue meeting order entry conditions
Elite Automated NinjaTrader Trading
Last 5 minutes Label
ThinkOrSwim
Moving average with Lag reduction
NinjaTrader
Linux?
ThinkOrSwim
 
 
  #3 (permalink)
Hamburg Germany
 
Experience: Advanced
Platform: Multicharts, Tradestation
Broker: DTN IQ
Trading: ES
 
Posts: 2,178 since Apr 2013
Thanks: 384 given, 1,411 received


DavidBodhi,

one approach would be to loop over the desired bars once you have the bar number of the highest high.
You could adjust the code in the first post here, to loop over the 20 bars to the left of the bar that returned the highest high:


As you are using Max in your code already, you should also be able to get the value using:
 
Code
int barsAgo = HighestBar(High, 20);
double HighestH2 = MAX(High, 20)[barsAgo+1];
Regards,

ABCTG

Follow me on Twitter Visit my Facebook Reply With Quote
The following user says Thank You to ABCTG for this post:
 
  #4 (permalink)
Milwaukee, WI, USA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Equities
 
DavidBodhi's Avatar
 
Posts: 137 since Oct 2014
Thanks: 10 given, 119 received


ABCTG View Post
DavidBodhi,

one approach would be to loop over the desired bars once you have the bar number of the highest high.
You could adjust the code in the first post here, to loop over the 20 bars to the left of the bar that returned the highest high:


As you are using Max in your code already, you should also be able to get the value using:
 
Code
int barsAgo = HighestBar(High, 20);
double HighestH2 = MAX(High, 20)[barsAgo+1];
Regards,

ABCTG

Thanks, ABCTG. That will work well for the value of the previous high.

I'll also need the number of bars back that previous high occurred. I'm not much of a programmer, or I'm sure I'd see immediately how to look at all the prior closes from [1] to [barsAgo+1], but that code isn't clear to me. I'll do some research on that, unless you can offer another concise method.

Thanks, again.

Follow me on Twitter Reply With Quote
 
  #5 (permalink)
Hamburg Germany
 
Experience: Advanced
Platform: Multicharts, Tradestation
Broker: DTN IQ
Trading: ES
 
Posts: 2,178 since Apr 2013
Thanks: 384 given, 1,411 received

DavidBodhi,

you are welcome. This would be something you can accomplish with the loop from the link, too. While you loop over the bars, save the high into your variable in case it's higher than the currently found highest high and save the number of bars this high is back in another variable.

Regards,

ABCTG

Follow me on Twitter Visit my Facebook Reply With Quote
 
  #6 (permalink)
Milwaukee, WI, USA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Equities
 
DavidBodhi's Avatar
 
Posts: 137 since Oct 2014
Thanks: 10 given, 119 received


ABCTG View Post
DavidBodhi,

you are welcome. This would be something you can accomplish with the loop from the link, too. While you loop over the bars, save the high into your variable in case it's higher than the currently found highest high and save the number of bars this high is back in another variable.

Regards,

ABCTG

Thanks, again.

I'll look into that.

Follow me on Twitter Reply With Quote



futures io Trading Community Platforms and Indicators NinjaTrader > Highest bar between 20 and 40 bars ago




Upcoming Webinars and Events
 

Free BloodHound Licenses to everyone!

June
 

Every journal equals ten meals for the hungry

June
     



Copyright © 2020 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