Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
cumulative index
Collapse
X
-
what I want to do is have the data calculated to be added together with a base at zero.
So starting from a base of zero, after the first bar is complete, we add the data calculated based on the first bar to zero. This forms the new base. Then we add on the data that is calculated from the second bar to the new base. This goes on ad infinitum. The only thing to note is the denom does not equal zero.
I can't get these pieces of data calculated from each bar to add....
Comment
-
I see thanks - then I would suggest taking a look at the EMA indicator as example for such a technique, it builds a cumulative value with previous dataseries value (' * Value[1] ' part).
Code:{ Value.Set(CurrentBar == 0 ? Input[0] : Input[0] * (2.0 / (1 + Period)) + (1 - (2.0 / (1 + Period))) * Value[1]); }
BertrandNinjaTrader Customer Service
Comment
-
Hi Bertrand, It's similar in a way. It differs in that there are 1 value to use if true and another value to use if false. The cumulative index I am trying to create just adds the values calculated. Plus I'm not sure how to fit in the formula have have in the manner set out by EMA Indicator.
As you know, my formula is ((Close[0]-Open[0])/(Math.Max(High[0],Close[1]))-(Math.Min(Low[0],Close[1]))). That is essentially what is in the code. And the denominator>0.
Would appreciate your help if you wouldn't mind...thanks!
Comment
-
Josh/Bertrand,
When I compile the code, no errors appear but no output occurs too!
I tried to narrow down the possibilities and it seems it's the DataSeries that is not producing any output. Below is the code for the DataSeries:-
myDataSeries.Set((Close[0]-Open[0])/((Math.Max(High[0],Close[1]))-(Math.Min(Low[0],Close[1]))));
if (CurrentBar < 2)
Print("The values are " + myDataSeries[0] + " " + myDataSeries[1]);
Why isn't there any output? Could you guys please take a look? Do I need to type anything in the "Properties" section?
Thanks!
Just remembered to check the log...there was this message..."Error on caling the 'OnBarUpdate'method fot the indicator 'draftpresscum' on bar 0: Index was out of range. Must be non-negative and less than the size of the collection." What does this mean?Last edited by kaywai; 01-27-2010, 02:30 AM.
Comment
-
Josh/Bertrand,
Tried to narrow the error down further. The part that is creating the error log ..."Error on caling the 'OnBarUpdate'method fot the indicator 'draftpresscum' on bar 0: Index was out of range. Must be non-negative and less than the size of the collection."...is this part:-
myDataSeries2.Set(Math.Max(High[0],Close[1])-(Math.Min(Low[0],Close[1])));
I can't even generate data from this line and it's not even a denominator in this case! Please help.
Comment
-
Bertrand, I did what you instructed and it works fine but when I substitute this code in its place
if (CurrentBar > 2 )
myDataSeries.Set((Close[0]-Open[0])/((Math.Max(High[0],Close[1]))-(Math.Min(Low[0],Close[1]))));
This error message pops up: "Error on plotting indicator 'draftpresscum'. Please check the 'OnBarUpdate' or the 'Plot' method: Overflow error."
BTW this is still part of the cumulative index i'm still struggling with...
Comment
-
Guys, writing the cumulative index code has been the most frustrating to date. The code below is what I thought would help me achieve it but:-
if (CurrentBar > 2 )
myDataSeries1.Set((Close[0]-Open[0])/(((Math.Max(High[0],Close[1]))-(Math.Min(Low[0],Close[1])))!= 0? (Math.Max(High[0],Close[1])-(Math.Min(Low[0],Close[1]))):1.0));
Upper.Set(myDataSeries1[0]);
Value.Set(0);
if (Close[0]>Open[0])
Value.Set(Value[1]+Upper[0]);
elseif (Close[0]<Open[0])
Value.Set(Value[1]+Upper[0]);
else
Value.Set(Value[1]);
Please help.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by WHICKED, Today, 12:56 PM
|
2 responses
14 views
0 likes
|
Last Post
by WHICKED
Today, 02:15 PM
|
||
Started by Felix Reichert, Today, 02:12 PM
|
0 responses
1 view
0 likes
|
Last Post Today, 02:12 PM | ||
Started by Tim-c, Today, 02:10 PM
|
0 responses
1 view
0 likes
|
Last Post
by Tim-c
Today, 02:10 PM
|
||
Started by cre8able, Today, 01:16 PM
|
2 responses
9 views
0 likes
|
Last Post
by cre8able
Today, 01:40 PM
|
||
Started by chbruno, 04-24-2024, 04:10 PM
|
3 responses
49 views
0 likes
|
Last Post Today, 01:29 PM |
Comment