minfound = MIN(Low, Swing1.SwingHighBar(Strength, 1, CurrentBar) - Strength - 1)[Strength + 1];
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
How to find bar at which MIN occurs?
Collapse
X
-
How to find bar at which MIN occurs?
This equation finds a minimum value. What code can i write to return the bar number? Thanks!
minfound = MIN(Low, Swing1.SwingHighBar(Strength, 1, CurrentBar) - Strength - 1)[Strength + 1];
Tags: None
-
It tried the The LowestBar method. And that is the right idea. But it starts the search for lowest bar at current bar But i need it to start the search Strength bars ago, not on [0] bar. problem is LowestBar[Strength] is not possible. How can a person express this idea int lowestBar = LowestBar(Low, x)[Strength]? thanks!
-
Hello Kicks.Spin,
You would need to loop through the bars.
Below is a link to a forum post with example code.
https://ninjatrader.com/support/foru...96#post1113896Chelsea B.NinjaTrader Customer Service
Comment
-
Thank you ChelseaB:
I was intimidated by the complexity involved with that solution (maybe because i am new to this). But i came up with this alternate method that finds the minimum value and minimum bar number with one loop on OnBarUpdate. Let me know if you see a problem with that. thanks!
protected override void OnBarUpdate()
{
//Kicks.Spin alternate logic for minbarnumber & minvalue not including previous 2 bars
barsback = 5;
startsearchbar = CurrentBar - 5;
minbarnumber = startsearchbar;
minvalue = Low[CurrentBar - minbarnumber];
for(int i = startsearchbar + 1; i < CurrentBar - 2; ++i)
{
if(Low[CurrentBar - i] < minvalue)
{
minbarnumber = i;
minvalue = Low[CurrentBar - i];
}
}
}
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by sambathraj, Today, 07:46 PM
|
0 responses
10 views
0 likes
|
Last Post
![]()
by sambathraj
Today, 07:46 PM
|
||
Started by topa11, Today, 12:52 PM
|
2 responses
33 views
0 likes
|
Last Post
![]()
by topa11
Today, 06:30 PM
|
||
Started by torento, Yesterday, 05:43 PM
|
4 responses
84 views
0 likes
|
Last Post
![]()
by torento
Today, 06:06 PM
|
||
Started by sprks7979, Today, 05:59 PM
|
0 responses
28 views
0 likes
|
Last Post
![]()
by sprks7979
Today, 05:59 PM
|
||
Started by intelligenttrader, 09-11-2022, 06:02 PM
|
8 responses
232 views
0 likes
|
Last Post
![]() |
Comment