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
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
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:
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
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 usazencort, Today, 01:16 AM
|
0 responses
1 view
0 likes
|
Last Post
by usazencort
Today, 01:16 AM
|
||
Started by kaywai, 09-01-2023, 08:44 PM
|
5 responses
603 views
0 likes
|
Last Post Today, 12:32 AM | ||
Started by xiinteractive, 04-09-2024, 08:08 AM
|
6 responses
22 views
0 likes
|
Last Post Today, 12:31 AM | ||
Started by Pattontje, Yesterday, 02:10 PM
|
2 responses
20 views
0 likes
|
Last Post
by Pattontje
Yesterday, 11:49 PM
|
||
Started by flybuzz, 04-21-2024, 04:07 PM
|
17 responses
230 views
0 likes
|
Last Post
by TradingLoss
Yesterday, 11:45 PM
|
Comment