Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Out of the last x bars mark bars with the same high/low
Collapse
X
-
Thanks,ninZa!Originally posted by ninZa View PostPlease use the following statement for drawing text:
Can you please suggest how to lift the message a bit?Please,consult the image attached.It seems that the message itself a little bit blurred,as well.
Another thing is,i`m not sure how that gentleman intended to use all this,as with this combination:
i only found one single occurrence over a month span,provided the Bar type is completely seamless, without any gapsCode:if(Low[0] == Low[1] && Low[1] == Low[2] && Low[2] == Low[3] && Low[0] == Low[Math.Min(CurrentBar, 5)]) { DrawLine("high" + CurrentBar, false, 10, Low[0], -10, Low[0], Color.Black, DashStyle.Solid, 2); DrawText("txt" + CurrentBar, AutoScale, "3Bars Lows", 10, Low[2], 10, Color.Black, ChartControl.Font, StringAlignment.Near, Color.Transparent, Color.Transparent, 0); } if(High[0] == High[1] && High[1] == High[2] && High[2] == High[3] && High[0] == High[Math.Min(CurrentBar, 5)]) { DrawLine("high" + CurrentBar, false, 10, High[0], -10, High[0], Color.Black, DashStyle.Solid, 2); DrawText("txt" + CurrentBar, AutoScale, "3Bars Highs", 10, High[10], 10, Color.Black, ChartControl.Font, StringAlignment.Near, Color.Transparent, Color.Transparent, 0);
Comment
-
Please change the red value to offset the text to a higher or lower place, depending on whether you set it positive or negative:
If you find it blurred, I think there are 4 or 5 bars of equal highs, so the indicator draw 2 or 3 texts very close to one another. If that's the case, I will help you handle this issue.DrawText("txt" + CurrentBar, AutoScale, "3Bars Highs", 2, High[2], 30, Color.Black, ChartControl.Font, StringAlignment.Near, Color.Transparent, Color.Transparent, 0);
Pi
Comment
-
Yes,that`s the issue.It doubles/tripples the text.Originally posted by ninZa View PostPlease change the red value to offset the text to a higher or lower place, depending on whether you set it positive or negative:
If you find it blurred, I think there are 4 or 5 bars of equal highs, so the indicator draw 2 or 3 texts very close to one another. If that's the case, I will help you handle this issue.
Pi
Comment
-
Use this version outsource. You can adjust "minimumBars" to your preference.
int lastBar; // last texted bar
int minimumBars = 6; // 2 consecutive texts must be at least this number of bars apart
protected override void OnBarUpdate() {
if (CurrentBar < 2) return;
if(High[0] == High[1] && High[1] == High[2] && CurrentBar - lastBar >= minimumBars) {
lastBar = CurrentBar;
DrawLine("high" + CurrentBar, false, 2, High[0], 0, High[0], Color.Black, DashStyle.Solid, 2);
DrawText("txt" + CurrentBar, AutoScale, "3Bars Highs", 2, High[2], 10, Color.Black, ChartControl.Font, StringAlignment.Near, Color.Transparent, Color.Transparent, 0);
}
}
Comment
-
Oops looks like the thread has taken off
I just want a solution that does the job.
If someone can post it all well and good.
There are 100s of much more complicated free indicators etc here and at Big Mike's.
If I cannot get it that way I will get someone to code it for me.
Comment
-
A couple of questions,while we are at it,if you don`t mind.
1)what this bold statement are actually doing?
&& CurrentBar - lastBar >= minimumBars) {
lastBar = CurrentBar;
How the calculation goes,in general,what is minimumBars,Currentbar - lastBar,etc...
2)Where do you get the extra furniture,that lacking in the default Ninja Guide you`ve added to the DrawText synthax?And it`s somehow under the ''drawarrowdown'',beside all that,but that`s cool
I outlined some of them.
Code:DrawText("txt" + CurrentBar, AutoScale, "3Bars Highs", 2, High[2], 30, Color.Black, [U]ChartControl.Font[/U], [U]StringAlignment.Near[/U], Color.Transparent, Color.Transparent, 0);
Comment
-
Sorry skiguy, outsource asked and I answered :|
1. As I commented in the code, lastBar is the most recent bar where text is printed.
mimimumBars is the minimum number of bars between 2 texts. In the code I set it to 6, this means 2 consecutive texts must be at least 6 bars apart, so we won't have "blurred" effect due to double/triple texts.
2. The version of DrawText you used is a very simple one (that I have never used). I just use the standard version to draw text. You can learn more about it at: http://www.ninjatrader.com/support/h...l?drawtext.htm
Pi
Comment
-
To Support
Maybe Support will figure it ,why the DrawText() chapter`s link is under the 'drawarrowdown' link??
Comment
-
1.Got it.But is there a way to exclude those extra text?Originally posted by ninZa View PostSorry skiguy, outsource asked and I answered :|
1. As I commented in the code, lastBar is the most recent bar where text is printed.
mimimumBars is the minimum number of bars between 2 texts. In the code I set it to 6, this means 2 consecutive texts must be at least 6 bars apart, so we won't have "blurred" effect due to double/triple texts.
2. The version of DrawText you used is a very simple one (that I have never used). I just use the standard version to draw text. You can learn more about it at: http://www.ninjatrader.com/support/h...l?drawtext.htm
Pi
2.This link you`ve posted,i`ve referred to,but re-directed to this link somehow:
And yet,i din`t see there those extra stuff you`ve added...Maybe some book on coding,that you can recommend to read?.....Anyways,thanks!Nice job!
Comment
-
NP.Originally posted by outsource View PostMaybe Support will figure it ,why the DrawText() chapter`s link is under the 'drawarrowdown' link??
http://www.ninjatrader.com/support/h...warrowdown.htm
Outsource can you take up your query in another thread or via PM to ninZa please.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
563 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
329 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
547 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
547 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment