NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 04-03-2007, 06:02 PM   #1
zoltran
Senior Member
 
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

Another amibroker-ish question.

AFL has no intra-bar 'memory'. Ie, it recalculates every bar from the begining of the series every tick. This isn't an issue with daily or bar-close indicators, but it sure is an issue in R/T as new intra-bar ticks can move your indicator all over the place

How is this handled in NinjaScript. ?
For example,
ie
1) if x = true then do something
2) x = close> sma(9)

Tick1
- x is false the 1st tick into the bar and statement 1 does not branch out.
- Statement 2 is executed and sets it to be true.
Tick 2
- Will x remain set for the next tick/pass ?
zoltran is offline  
Reply With Quote
Old 04-03-2007, 06:14 PM   #2
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Post imported post

Hmm not sure I follow. Since NinjaScript basically is C#, the livetime concepts of C# for variables do apply.

a) Any class variable you defined in your strategy (see "Variables" region) is persisted as long as the strategy is running.

b) If you define a varoiable within the scope of the OnBarUpdate method then it's not persisted as you processed the current tick and returned from the OnBarUpdate method.
NinjaTrader_Dierk is offline  
Reply With Quote
Old 04-04-2007, 12:46 AM   #3
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Post imported post

Here are examples to illustrate what Dierk was stating.With example 1, x is preserved from tick to tick. Example 2 likely behaves like AFL where x is not preserved from tick to tick.



Example 1:
Quote:
private bool x = false;

OnBarUpdate()
{
if (x)
// Do something

x = close > SMA(9)[0]
}


Example 2:
Quote:
OnBarUpdate()
{
bool x = false;

if (x)
// Do something

x = close > SMA(9)[0]
}
NinjaTrader_Ray is offline  
Reply With Quote
Old 04-04-2007, 01:12 AM   #4
zoltran
Senior Member
 
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

Thanks Dierk and Ray!

zoltran 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


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