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



Highest bar between 20 and 40 bars ago


Discussion in NinjaTrader

Updated
    1. trending_up 1,725 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 5 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,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)

 
Search this Thread
 

Highest bar between 20 and 40 bars ago

(login for full post details)
  #1 (permalink)
 DavidBodhi 
Milwaukee, WI, USA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Equities
 
DavidBodhi's Avatar
 
Posts: 171 since Oct 2014
Thanks: 14 given, 162 received

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 Started this thread Reply With Quote

Journal Challenge April 2021 results (now extended!):
Competing for $1800 in prizes from Jigsaw
looks_oneMaking a Living with the Microsby sstheo
(79 thanks from 10 posts)
looks_twoSalao's Journalby Salao
(23 thanks from 5 posts)
looks_3Deetee’s DAX Trading Journal (time based)by Deetee
(16 thanks from 8 posts)
looks_4Learning to Profit - A journey in algorithms and optionsby Syntax
(12 thanks from 7 posts)
looks_5Rogue MNQ 2/21 Journeyby RogueJoules
(0 thanks from 2 posts)
 
Best Threads (Most Thanked)
in the last 7 days on futures io
The Crude Dude Oil Trading System
73 thanks
futures io site changelog and issues/problem reporting
71 thanks
Would You Sell Your System?
65 thanks
FIO Journal Challenge - April 2021 w/Jigsaw Trading
30 thanks
Big Mike in Ecuador
25 thanks
 
(login for full post details)
  #3 (permalink)
 ABCTG   is a Vendor
 
 
Posts: 2,236 since Apr 2013
Thanks: 414 given, 1,486 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 Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #4 (permalink)
 DavidBodhi 
Milwaukee, WI, USA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Equities
 
DavidBodhi's Avatar
 
Posts: 171 since Oct 2014
Thanks: 14 given, 162 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 Started this thread Reply With Quote
 
(login for full post details)
  #5 (permalink)
 ABCTG   is a Vendor
 
 
Posts: 2,236 since Apr 2013
Thanks: 414 given, 1,486 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 Reply With Quote
 
(login for full post details)
  #6 (permalink)
 DavidBodhi 
Milwaukee, WI, USA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Equities
 
DavidBodhi's Avatar
 
Posts: 171 since Oct 2014
Thanks: 14 given, 162 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 Started this thread Reply With Quote


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


Last Updated on August 25, 2017


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1,800 in prizes!

April
 

Seven Trading Mistakes Solved With Smart Trading Tools w/Brannigan Barrett

Elite only
     



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