![]() |
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Dec 2008
Posts: 118
Thanks: 0
Thanked 0 times in 0 posts
|
I like to find the HighestBar starting from High[1] to High[20].
Do I have to copy 'High' DataSeries elements (1 to 20) to another DataSeries, then pass the new DataSeries into HighestBar () function. How do I do it? |
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
That is correct. Or you can just save the value out from the previous bar. In your previous bar just save a variable that does not get reset for when you access HighestBar().
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Dec 2008
Posts: 118
Thanks: 0
Thanked 0 times in 0 posts
|
How do you copy from DataSeries? Would you be able to show the code?
|
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
http://www.ninjatrader-support.com/H...iesObject.html
myDataSeries.Set(High[1]); int value = HighestBar(myDataSeries, 20);
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Dec 2008
Posts: 118
Thanks: 0
Thanked 0 times in 0 posts
|
myDataSeries.Set(High[1]);
Does this automatic copy High[1], High[2], High[3], High[4], High[5], ... High[19], High[20] into myDataSeries? I don't really understand how DataSeries works? Would you try to explain further? |
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Dec 2008
Posts: 118
Thanks: 0
Thanked 0 times in 0 posts
|
I think I got how it works because we try to put the value of the previous bar into the dataseries hence it is always one bar behind the current high.
And I would need to protect the series by if (CurrentBar < 2) return; inside the OnBarUpdate(). This is neat. But would it be possible to have an optional parameter int HighestBar () or functions that uses dataSeries to specify the starting index that would be good too. Thanks Josh |
|
|
|
|
|
#7 |
|
NinjaTrader Customer Service
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
|
Hello,
You are correct. High[1] always returns the high value of one bar to the left of the current bar. if(CurrentBar < 2) return; could be: if(CurrentBar < 1) return; Because all you need is one bar of history. If there are no bars to the left of the current bar yet, then do nothing. I do not understand your last statement regarding HighestBar(). HighestBar() returns the index value of the highest bar within a range: http://www.ninjatrader-support.com/H...ighestBar.html
Ben
NinjaTrader Customer Service |
|
|
|
|
|
#8 |
|
Senior Member
Join Date: Dec 2008
Posts: 118
Thanks: 0
Thanked 0 times in 0 posts
|
I mean add an optional parameter to HighestBar. Instead of
HighestBar (IDataSeries ds, int length), we can have HighestBar (IDataSeries ds, int length, int startIndex), where startIndex is 0 by default |
|
|
|
|
|
#9 |
|
NinjaTrader Customer Service
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
|
Hello,
Thank you for your suggestion, I will send it to development for consideration. You may want to use MAX(High, 20)[1] or something like that to return the highest VALUE. However, this does not return the bar INDEX with the highest value. This link will help: http://www.ninjatrader-support.com/H...aximumMAX.html
Ben
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| DataSeries.Reset() | snaphook | General Programming | 16 | 11-11-2009 10:43 AM |
| DataSeries Weirdness | CashCache | General Programming | 1 | 09-04-2008 10:53 PM |
| DataSeries Issue | Antonio79 | General Programming | 8 | 09-03-2008 12:40 PM |
| OHLC Dataseries? | michaelbb | Indicator Development | 3 | 05-28-2008 09:45 AM |
| DataSeries doubt | cls71 | Indicator Development | 1 | 01-21-2008 10:49 PM |