NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 05-31-2012, 09:55 AM   #1
sercava
Member
 
Join Date: Nov 2011
Posts: 55
Thanks: 18
Thanked 3 times in 3 posts
Default Using lists

Hi!

I was wondering about using lists. Is there any example where I can see its use?

I'm trying to solve this problem: (I don't know the proper syntax, but I'm trying to make it clear)

1. I have identified a bar (i bars ago) and I want to do a search around that bar to get its highest high, for example in the range (i +r ----> i-r).
2. I can create some kind of list and add the elements:
for (int x= i-r,x < i+r+1;x++)
add (high[x], highlist);
3. Then sort with the proper command to get the maximum.:
GetHighOfList(highlist)

Perhaps there is a native function to do this but I've searched and didn't see anything.

Thanks in advance,

Sergio
sercava is offline  
Reply With Quote
Old 05-31-2012, 10:05 AM   #2
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello Sergio,
Thanks for writing in and I am happy to assist you.

You can use the HighestBar fucntion to find the highest bar. Please refer here to know more
http://www.ninjatrader.com/support/h...highestbar.htm


Please let me know if I can assist you any further.
NinjaTrader_Joydeep is offline  
Reply With Quote
Old 05-31-2012, 10:11 AM   #3
sercava
Member
 
Join Date: Nov 2011
Posts: 55
Thanks: 18
Thanked 3 times in 3 posts
Default

But that only work if I want to search from last bar.

Let's explain a bit more:

With:

HighestBar(High, 6) I will check bars [0],[1],...[6]

but what I want is searching around bar [16]

and check [19],[18]...[16]...[14],[13] only

not [19],[18]...[0]

Hope this helps to know what I want.
sercava is offline  
Reply With Quote
Old 05-31-2012, 10:59 AM   #4
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello sercava,
Thanks for the clarification.

Please use the MAX function to do it. A sample code will be like
Code:
if (CurrentBar > 19)
double highestHigh = MAX(High, 6)[13];
http://www.ninjatrader.com/support/h...aximum_max.htm

Please let me know if I can assist you any further.
NinjaTrader_Joydeep is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Joydeep for this post:
Old 06-01-2012, 01:16 AM   #5
sercava
Member
 
Join Date: Nov 2011
Posts: 55
Thanks: 18
Thanked 3 times in 3 posts
Default

That's what I need, thanks. Will code it.

Have fun!

Sergio
sercava is offline  
Reply With Quote
The following user says thank you to sercava for this post:
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting Instrument Lists Tryder Market Analyzer 1 05-06-2010 03:30 AM
Instrument lists ct Version 7 Beta General Questions & Bug Reports 5 10-07-2009 09:23 AM
Use of Instrument Lists nomlas SuperDOM and other Order Entry Windows 3 07-31-2008 06:24 AM
Favorites lists Speedie6 Miscellaneous Support 1 04-23-2008 09:22 PM
Parameter selection lists ThePatientOne Indicator Development 3 05-11-2007 08:48 AM


All times are GMT -6. The time now is 10:21 PM.