I read the MIN guide, but still don't know how to do it properly. Any help is appreciated. Thank you.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
How to Write Previous Up Bars
Collapse
X
-
How to Write Previous Up Bars
Hey guys. I'm curious. How do I write a Condition to Look "If the Last 5 or More Bars are UP Bars...." Do something..... and How about "if the last 5 or more bars have Higher Lows than each previous bar.....Do something"
I read the MIN guide, but still don't know how to do it properly. Any help is appreciated. Thank you.Tags: None
-
I Tested This but Its Not working right. It keeps showing arrows everywhere. even when the Last 5 bars Were NOT UP bars.
PICTURE: http://screencast.com/t/aMYwD8pg6WN
Code:#region Variables // Wizard generated variables private int myInput0 = 1; // Default setting for MyInput0 // User defined variables (add any user defined variables below) #endregion /// <summary> /// This method is used to configure the indicator and is called once before any bar data is loaded. /// </summary> protected override void Initialize() { Overlay = true; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { if (CurrentBar < 5) return; if(MIN(Close, 5)[1] > MIN(Open, 5)[1]) //The MIN displays if the Last 5 bars Close UP starting with [1] bar ago. { DrawArrowDown("My down arrow" + CurrentBar, false, 0, High[1] + 3 * TickSize, Color.Red); } } //DON"T TOUCH
-
Hello ginx10k,
Thank you for your post.
There is no method to determine the up bars over a period. Max and Min look for the Highest or Lowest value over the period, not consistent highs or lows.
You can implement a for loop to quickly and easily check for these conditions without multiple repeating lines of code:
Code:int count = 0; for(int i = period; i >= 0; i--) { if(Close[i] > Open[i] && Close[i] > Close[i+1] && Low[i] > Low[i+1]) { count++; } } if(count == period) { Print("Last " + period + " bars are up."); }
Comment
-
Didn't work. Thanks for quick response Patrick (as always u rock). It didn't draw any arrows anywhere.
any ideas??
I tried this code:
Code:int count = 0; for(int i = period; i >= 0; i--) { if(Close[i] > Open[i] && Close[i] > Close[i+1] && Low[i] > Low[i+1]) { count++; } } if(count == period) { DrawArrowDown("My down arrow" + CurrentBar, false, 0, High[1] + 3 * TickSize, Color.Red); Print("Last " + period + " bars are up."); }
Comment
-
Also tried
I also Tried This codeand it Shows Arrows. but Still Shows arrows even in areas where we didn't get 5 consecutive UP BarsCode:for(int i = period; i >= 0; i--) { if((Close[i] > Open[i]) ) { count++; } }
I don't know why its just NOT working.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
579 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
334 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 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
554 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment