How would or could you do it? Thanks!!
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Lookup Bars Question
Collapse
X
-
Lookup Bars Question
I was just curious if anyone might know how I could look back in the last say 50 bars from whatever current price where the 3 is on my chart Here's a chart, I need to get the value for #3 level.
How would or could you do it? Thanks!!
Last edited by clubfoot; 09-13-2016, 04:11 PM.Tags: None
-
Hello clubfoot, and thank you for your question.
For this kind of strategy, you need some kind of threshold you can cross to mark off sections. One popular threshold is an SMA (simple moving average). Your threshold can be either a single value, or a DataSeries.
However you define your threshold, you could collect crossover indices in a System.Collections.Generic.List object like this :
First remember to initialize like this :
Code:[FONT=Courier New]private System.Collections.Generic.List<int> myList; protected override void Initialize() { myList = new System.Collections.Generic.List<int>();[/FONT]
Code:[FONT=Courier New]if (CrossAbove(Close, threshold, lookbackPeriod) || CrossBelow(Close, threshold, lookbackPeriod)) { myList.Add(CurrentBar); }[/FONT]
Code:[FONT=Courier New]int oldBar = CurrentBar - myList[2] + 50;[/FONT]
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search, sort, and manipulate lists.
And here is some documentation on CrossAbove . CrossBelow has a similar method signature.
Finally, here is some documentation on CurrentBar .
Please let us know if there are any other ways we can help.Last edited by NinjaTrader_JessicaP; 09-14-2016, 08:26 AM.Jessica P.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by RichardHK, 08-22-2024, 09:02 AM
|
4 responses
59 views
0 likes
|
Last Post
by RichardHK
Today, 09:37 AM
|
||
Started by HGTrader, Today, 09:31 AM
|
1 response
3 views
0 likes
|
Last Post Today, 09:37 AM | ||
Started by Gibranes, 10-12-2024, 04:02 AM
|
3 responses
14 views
0 likes
|
Last Post Today, 09:37 AM | ||
Started by dbennett3, Today, 09:18 AM
|
1 response
6 views
0 likes
|
Last Post Today, 09:33 AM | ||
Started by cupir2, Yesterday, 05:27 PM
|
1 response
14 views
0 likes
|
Last Post Today, 09:33 AM |
Comment