NexusFi: Find Your Edge


Home Menu

 





Offsetting HighestBar


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one gpiero with 1 posts (0 thanks)
    2. looks_two vadzzim with 1 posts (0 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 rleplae with 1 posts (0 thanks)
    1. trending_up 1,422 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

Offsetting HighestBar

  #1 (permalink)
 gpiero 
Gallarate
 
Experience: Beginner
Platform: NinjaTrader
Trading: DAX
Posts: 2 since Nov 2011
Thanks Given: 5
Thanks Received: 0

Hi!

I'm quite new to C# and ninja script and I am having some trouble coding a custom indicator. I need to find the index of the bar with the highest value in a specific interval offset from the current bar. More specifically, I am trying to find the lowest low and highest high for a range of bars - (let's say 12 for the sake of argument) but starting the search from an arbitrary bar index, say 5 bars ago from the current bar.

The standard Ninja Script instruction HighestBar(IDataSeries series, int period) returns the number of bars ago the highest price value occurred for the look back period, where period is an int value that represents the number of bars ago, I presume from the current bar. What I need is a way to specify the bar index from which to start looking for the highest value in the look back period, as if the standard syntax of this instruction were:

HighestBar(IDataSeries series, int period, int start);

where start is the offset from the current bar.

I am sure there is a way to sidestep the absence of this syntax, though I have not yet found it. I would appreciate any hint that could put me in the right direction.

Thanks in advance

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
REcommedations for programming help
Sierra Chart
Better Renko Gaps
The Elite Circle
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
How to apply profiles
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
34 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
18 thanks
GFIs1 1 DAX trade per day journal
16 thanks
Vinny E-Mini & Algobox Review TRADE ROOM
13 thanks
  #3 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863


Try using the following :

MAX(High,15)[5])

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
 vadzzim 
Belarus
 
Experience: Beginner
Platform: NinjaTrader
Trading: NQ, CL
Posts: 20 since Sep 2015
Thanks Given: 5
Thanks Received: 11

Do it in for cycle...

 
Code
		private int HighestBar(IDataSeries series, int start, int range)
		{
			double highestHigh = series[start];
			int highestBar = start;
			
			for (int i = start+1; i < range; i++) {
				if (series[i] > highestHigh) {
					highestHigh = series[i];
					highestBar = i;
				}
			}
			
			return highestBar;
		}

Reply With Quote




Last Updated on November 20, 2015


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts