Announcement
Collapse
No announcement yet.
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]); }
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 Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
635 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
364 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
105 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
567 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
568 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment