This is going to be a vague question, but I don't know how else to put it. I'm trying to compare a current period situation to a past period. So for instance to be lookback and compare all the times during the day that price closed at x. Can anyone give me an idea of how to do that? Thanks.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Comparing a current period to a past period
Collapse
X
-
Comparing a current period to a past period
Hello,
This is going to be a vague question, but I don't know how else to put it. I'm trying to compare a current period situation to a past period. So for instance to be lookback and compare all the times during the day that price closed at x. Can anyone give me an idea of how to do that? Thanks.Tags: None
-
There are a number of ways to handle this depending on what you're looking for.
There are many NS methods that are designed to help you pull past values. I'd suggest looking at our resource sample on Referencing the Correct bar for a few examples of this:
If these are custom calculations, you would need to save the past period values in an array so you can compare to the current values.
This is similar to the way you'd check the current high value to the high 3 bars ago. (High[0], High[3], etc)
For this, please see our Reference Sample on Using a DataSeries Objects to store calculations:
MatthewNinjaTrader Product Management
-
Thanks Matthew. Alright I've been going over this I think I'm in the ball park. Now once I have created my DataSeries how do I then compare the values? The items I'll be comparing could have happened 2 bars ago or 10.
Comment
-
Thanks again. Unfortunately I'm comparing a condition such as "at what value did this indicator close every time price closed at 100" so I can't name a specific bar in which that happened.
Comment
-
This is what I have so far:
I'm hoping that this will identify every time the RSValue was greater than 10. If this is correct I would like to use this information to then determine what price was at each of these instances. Any ideas?Code:private BoolSeries pricecomp; pricecomp = new BoolSeries(this,MaximumBarsLookBack.Infinite); pricecomp.Set(RSValue(3, period).iClose[0] > 10);
Comment
-
Here is an example of reading what the price was when the RSI indicator is greater than 50
If you actually want to store that price to be able to compare those, that would take a DataSeries rather than the BoolSeries.Code:if(RSI(20, 3)[0] > 50) { pricecomp.Set(true); } else pricecomp.Set(false); if(pricecomp[0] == true) { Print("Price: " + Close[0] + " RSI: " + RSI(20, 3)[0]); }
Code:private DataSeries isTrueprice; isTrueprice = new DataSeries(this, MaximumBarsLookBack.Infinite); if(RSI(20, 3)[0] > 50) { isTrueprice.Set(Close[0]); } Print(isTrueprice[0] + " RSI: " + RSI(20, 3)[0]);Last edited by NinjaTrader_Matthew; 02-08-2013, 07:48 AM.MatthewNinjaTrader Product Management
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
600 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
347 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
103 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
558 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
558 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment