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 12-14-2010, 04:59 PM   #1
ziggymeister
Junior Member
 
Join Date: Dec 2010
Posts: 27
Thanks: 0
Thanked 0 times in 0 posts
Wink recursive function

Hi I am not sure if this is available either with Ninjasscript or the MSDN library I am just trying to get the below function done: Thanks!
Syntax

compoundValue(int length, IDataHolder visible data, IDataHolder historical data);
The default value of the length parameter is 1.
Description

Calculates a compound value according to following rule: if a bar number is bigger than length then the visible data value is returned, otherwise the historical data value is returned. This function is used to initialize studies with recursion.
Example

declare lower;rec x = compoundValue(2, x[1] + x[2], 1);plot FibonacciNumbers = x;
The example calculates the Fibonacci sequence. Starting from the third bar each following number is calculated as the sum of the previous two numbers while the numbers for the first two bars are equal to one. As a result you will get a plot containing the 1 1 2 3 5 etc values.
ziggymeister is offline  
Reply With Quote
Old 12-14-2010, 05:03 PM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

ziggymeister,

I am not sure where you got that method from as it is not a standard method from .NET that I am aware of. You can still feel free to create yourself your own method named that that does exactly that if you wish though.
NinjaTrader_Josh 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
Recursive property bascher Strategy Development 3 09-01-2010 04:34 PM
Recursive Property Error ?? AresBowman Strategy Development 3 06-17-2010 11:23 AM
recursive parameter error junkone General Programming 2 11-20-2008 07:08 AM
Recursive Properties zoltran General Programming 3 05-07-2008 01:29 AM
a function that does this HelloHello Automated Trading 1 09-13-2007 03:24 AM


All times are GMT -6. The time now is 12:42 AM.