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 10-13-2008, 06:05 AM   #1
snaphook
Senior Member
 
Join Date: Apr 2008
Posts: 376
Thanks: 0
Thanked 20 times in 11 posts
Default DataSeries.Reset()

I thought I understood this method, but perhaps not. I have developed a very simple indicator that just plots the projected high and low of range bars thus.

double projectedhigh = Low[0]+Bars.Period.Value*TickSize;
double projectedlow = High[0]-Bars.Period.Value*TickSize;
Phigh.Set(projectedhigh);
Plow.Set(projectedlow);
if (FirstTickOfBar)
{
Phigh.Reset(1);
Plow.Reset(1);
}

I thought this would plot the hash for every bar and reset the value on the previous bar (1) each time a new bar was formed so all I would see is the current bar hash or dot.

Unfortunately, I see no plot at all. If I alter the .Reset(1) to .Reset(), I see the hash, but it is persistent from the implementation point forward. If I remove the resets altogether, of course I see hashes for all bars.

Is there a more detailed description or tutorial available than is provided in the help section? or am I misunderstanding the use for reset? I have used this technique several times before in non-price panels and it works fine.

Snap
snaphook is offline  
Reply With Quote
Old 10-13-2008, 08:54 AM   #2
NinjaTrader_Ben
NinjaTrader Customer Service
 
NinjaTrader_Ben's Avatar
 
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
Default

Hello,

You are using .Reset incorrectly. All you need to use is DataSeires.Set(int barsAgo, double value) instead. Reset only works for the current bar.

Calling the Reset() method is unique and can be very powerful for custom indicator development. DateTimeSeries objects can hold null values which simply means that you do not want to store a value for the current bar. Reset() will reset the current index value to null.

You will find more information about DataSeires here:
http://www.ninjatrader-support.com/H...riesClass.html
NinjaTrader_Ben is offline  
Reply With Quote
Old 11-07-2009, 04:55 PM   #3
jerryvellutini
Member
 
Join Date: Oct 2009
Posts: 67
Thanks: 0
Thanked 1 time in 1 post
Default

I'm trying to compute projected high low using the formula:

double projHigh = Low[0] + Bars.Period.Value * Bars.Instrument.MasterInstrument.TickSize;

Taken from an indicator by wlas on Woodies site. The indicator works perfectly but my computations are out of sync.

Does this have something to do with the Data Series command?

What's the MasterInstrument about that's not in snaphooks formula.
jerryvellutini is offline  
Reply With Quote
Old 11-07-2009, 05:23 PM   #4
NinjaTrader_Ben
NinjaTrader Customer Service
 
NinjaTrader_Ben's Avatar
 
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
Default

Hello,

The indicator works perfectly but my computations are out of sync.
>>do you mean your calc's that are trying to duplicate the indicator?

For your other questions I will need more details. What is a snaphook?

A master instrument is the instrument that you are basing everything off of and the instrument that you attach the indicator to.

I suggest giving it a try again and posting your code with a question.

Maybe tell me in words what you are trying to calc when you posted this?:
double projHigh = Low[0] + Bars.Period.Value * Bars.Instrument.MasterInstrument.TickSize;
NinjaTrader_Ben is offline  
Reply With Quote
Old 11-07-2009, 05:59 PM   #5
jerryvellutini
Member
 
Join Date: Oct 2009
Posts: 67
Thanks: 0
Thanked 1 time in 1 post
Default

Yes I'm trying to duplicate the indicator.

snaphook posted the original question with what I think is a similar problem. His formula is:

double projectedhigh = Low[0]+Bars.Period.Value*TickSize;

no master Instrument reference.

I'm trying to compute the values projHigh and ProjLow

My results seem to be those for the previous bar
jerryvellutini is offline  
Reply With Quote
Old 11-08-2009, 10:01 AM   #6
NinjaTrader_Ben
NinjaTrader Customer Service
 
NinjaTrader_Ben's Avatar
 
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
Default

Hello,

I think I am missing something... what is the calculation for the projected bar in words (not code)?
NinjaTrader_Ben is offline  
Reply With Quote
Old 11-08-2009, 10:08 AM   #7
jerryvellutini
Member
 
Join Date: Oct 2009
Posts: 67
Thanks: 0
Thanked 1 time in 1 post
Default

I really don't know. I stole the formula and am trying to use it. Can I send you my code and wlas's indicator which I'm trying to emulate?
jerryvellutini is offline  
Reply With Quote
Old 11-08-2009, 06:15 PM   #8
NinjaTrader_Ben
NinjaTrader Customer Service
 
NinjaTrader_Ben's Avatar
 
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
Default

Hello,

I'm sorry, this is beyond our level of service. However if you want some help when you get stuck on a specific coding issue we can try to help.
NinjaTrader_Ben is offline  
Reply With Quote
Old 11-09-2009, 03:48 PM   #9
jerryvellutini
Member
 
Join Date: Oct 2009
Posts: 67
Thanks: 0
Thanked 1 time in 1 post
Default

My specific coding issue is how do I compute values for a parameter based on current bar data as opposed to using prior bar data?
jerryvellutini is offline  
Reply With Quote
Old 11-09-2009, 03:56 PM   #10
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

[0] is the index to access values based on the current bar. You need to use CalculateOnBarClose = false to get it while the bar is still building. I am not quite sure I follow your requirements.
NinjaTrader_Josh is offline  
Reply With Quote
Old 11-09-2009, 04:28 PM   #11
jerryvellutini
Member
 
Join Date: Oct 2009
Posts: 67
Thanks: 0
Thanked 1 time in 1 post
Default

Thank you very much!!!!! That solves my problem.
jerryvellutini is offline  
Reply With Quote
Old 11-10-2009, 09:55 AM   #12
jerryvellutini
Member
 
Join Date: Oct 2009
Posts: 67
Thanks: 0
Thanked 1 time in 1 post
Default

I have an indicator which works the way I want with CalculateOnBarClose = true
Is there a way to embed code which needs CalculateOnBarClose = false
without affecting the original code?
jerryvellutini is offline  
Reply With Quote
Old 11-10-2009, 10:07 AM   #13
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
Default

Yes, but the other way round - set the indicator to calculate on bar close = false. Then do end of bar calculations on the first tick of the new bar and reference one bar back further to adjust for calling it at the start of the next bar.

Code:
 
if (FirstTickOfBar)
{
// do on bar close calcs, reference a bar further back 
myROC = Close[1] - Close[2];
}
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 11-11-2009, 09:51 AM   #14
jerryvellutini
Member
 
Join Date: Oct 2009
Posts: 67
Thanks: 0
Thanked 1 time in 1 post
Default

I'm not sure I get it.

if (FirstTickOfBar)
{
All my old stuff with [0] replaced by [1]
}
New stuff calculated on building bar using [0]

I'm not getting my old stuff
jerryvellutini is offline  
Reply With Quote
Old 11-11-2009, 09:56 AM   #15
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
Default

Jerry, to clarify, please put on calculations that you want be calculated 'on bar close' into the if (FirstTickOfBar) statement. Then rest would need to be done outside of this to be updated on each tick then, provided indicator would be run on CalculateOnBarClose = false.
NinjaTrader_Bertrand is offline  
Reply With Quote
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
Reset indicator each 60 minutes whitegun Indicator Development 6 05-28-2008 02:19 AM
Reset P&L aaronxie SuperDOM and other Order Entry Windows 6 03-11-2008 07:15 AM
Simulator reset? kenne Miscellaneous Support 1 01-13-2008 10:23 PM
Reset values in a DataSeries Rollins Indicator Development 2 12-09-2007 01:05 AM
Reset data history? Antraman Miscellaneous Support 9 05-15-2006 05:00 AM


All times are GMT -6. The time now is 07:53 PM.