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
Getting the max price from the past x ticks
Collapse
X
-
Getting the max price from the past x ticks
I'm trying to get the max price from the past x number of ticks but I just don't know how to write that into the script. Ideally I would want to use something like maxbars = max.bars[5]; and this example would be looking at the past 5 ticks to get the max price, but I am not getting the max price from this and am stuck. Where am I messing up?Last edited by jertrade; 07-17-2019, 02:57 PM. -
Hello jertrade,
Can you provide more detail about how this code would be used and executed? Are you using a 1 tick series or something else?
On a 1 tick series, you could just use the Max indicator with a lookback of 5. If you are using a different time frame, you would need to create logic to gather the last 5 ticks and then see which is the biggest number of those 5 numbers. You can do that in a variety of ways, most would involve a loop and a variable which denotes the currently found max value. For this question, I would suggest doing a general web search for C# solutions as well. For example "C# find max value of array" or "C# find max value of List" are a couple of more simple ways to approach this concept.
If you have tried something which is not working, it also helps to provide a specific example instead of pseudo code.
I look forward to being of further assistance.JesseNinjaTrader Customer Service
-
Originally posted by NinjaTrader_Jesse View PostOn a 1 tick series, you could just use the Max indicator with a lookback of 5. If you are using a different time frame, you would need to create logic to gather the last 5 ticks and then see which is the biggest number of those 5 numbers.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by algospoke, Yesterday, 06:40 PM
|
2 responses
19 views
0 likes
|
Last Post
by algospoke
Today, 07:04 PM
|
||
Started by ghoul, Today, 06:02 PM
|
3 responses
14 views
0 likes
|
Last Post Today, 06:43 PM | ||
Started by jeronymite, 04-12-2024, 04:26 PM
|
3 responses
45 views
0 likes
|
Last Post
by jeronymite
Yesterday, 10:10 PM
|
||
Started by Barry Milan, Yesterday, 10:35 PM
|
7 responses
21 views
0 likes
|
Last Post Today, 06:16 PM | ||
Started by AttiM, 02-14-2024, 05:20 PM
|
10 responses
181 views
0 likes
|
Last Post
by jeronymite
Today, 06:11 PM
|
Comment