I read the MIN guide, but still don't know how to do it properly. Any help is appreciated. Thank you.
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 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 codeCode: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 ThoriSten, Today, 03:56 AM
|
0 responses
2 views
0 likes
|
Last Post
by ThoriSten
Today, 03:56 AM
|
||
Started by PhillT, 04-19-2024, 02:16 PM
|
3 responses
17 views
0 likes
|
Last Post
by mangel2000
Today, 03:04 AM
|
||
Started by TraderBCL, Today, 02:37 AM
|
0 responses
1 view
0 likes
|
Last Post
by TraderBCL
Today, 02:37 AM
|
||
Started by mangel2000, Today, 02:23 AM
|
0 responses
8 views
0 likes
|
Last Post
by mangel2000
Today, 02:23 AM
|
||
Started by mangel2000, Today, 01:30 AM
|
0 responses
15 views
0 likes
|
Last Post
by mangel2000
Today, 01:30 AM
|
Comment