Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Current Range Bar possible High & Low Plot
Collapse
X
-
You need to be more specific with what you mean by "goes wrong". Just draw the line and you will see how it behaves. Lines connect two data points together.
You should check your script for errors in the logs.
-
Yes, starting at the previous bar and ending at the beginning of the current bar, right? Not like a Hash plot right?Originally posted by NinjaTrader_Josh View PostDrawLine(string tag, int startBarsAgo, double startY, int endBarsAgo, double endY, Color color)
DrawLine("line", 1, High[0], 0, High[0], Color.Blue)
The would draw a line segment at the current high price.
That is what I had in the Drawing Plots.
But as mentioned elsewhere in this (irritating little!) thread, the same problem exists with the Drawing option as with the Hash option in that sometimes it seems to get it wrong. Now perhaps that is due to certain elements in my original coding which was set up around Plots (made transparent when trying the Draw Line options) but the question remains:
How do you tell a Line to plot in the same place as a Hash plot, i.e. centred over the current bar? Your example does not do that.
Leave a comment:
-
DrawLine(string tag, int startBarsAgo, double startY, int endBarsAgo, double endY, Color color)
DrawLine("line", 1, High[0], 0, High[0], Color.Blue)
The would draw a line segment at the current high price.
Leave a comment:
-
Jason, thanks for encouragement. I too think this is worth getting right. It's not a big deal, but it is VERY handy.
For me there are two issues here:
1. Getting it right
2. Learning why it is not right and therefore simply: learning.
Thus far, unfortunately, we have not learned why on some charts it works exactly as it should and on others it doesn't. Clearly this is not a situation where what it being attempted is impossible because most of the time it works. Just sometimes it doesn't and we don't know why.
Josh: In terms of drawing it exactly where you want it: could you please supply a Drawline code example that plots a solid line in the same place as a Hash would be plotted? I have been unable to figure it out. If you place the first spot at 1 it starts at the previous bar. If you do 0....1 it doesn't plot at all. If you do 1....1, it doesn't plot. The only plot I get that works is 1...0 in which case it starts at 1 bar ago and ends up at the beginning of the current bar (as in plotting an indicator line). How to get it centred above the current plot eludes me. I have also tried 0.5's but it won't accept it.
I suspect that plotting a Hash is the way to go. The only issue is: how to get it to only plot on the current bar once the bar is complete. In working on this today I have put up several 2-range charts and seen the plots disappear AS SOON as the bar is complete, i.e. that very tick as it happens, so it doesn't need a second occurrence for the plot to be wiped out since in the code every time there is a new Close[0] the initial 'return' condition will erase the plot. Like I have said a few times, it works most of the time, but when it doesn't there is no apparent reason for it.
PS I now attach the latest Auto version with many lines disactivated but with both the Linedrawing and default Plot configurations just in case anyone on the forum wants to drill down into why there is this mysterious problem either way.Attached FilesLast edited by cclsys; 08-13-2009, 02:01 PM.
Leave a comment:
-
If you are using the initial code you have to ensure that the Range Bar setting in the menu is the same as the one you plot. Looks like yours are not lined up.Originally posted by NinjaTrader_Austin View PostJust to check in, I'm running the code posted near the beginning and everything looks fine to me. Is this what you guys are getting?
The second edition 'Auto' has the code seeing what the range bar setting is so you don't have to alter it manually.
Leave a comment:
-
Originally posted by cclsys View Postwell, I am just going to stick with the original version and use it for myself; it works 95% of the time fine. For charts where it doesn't work, won't use it.
I don't see any difference in plotting a line versus a plot. Removing the conditional code doesn't make a difference when plotting a line except that it doesn't plot at all for some reason.
So am sticking with the original and the problem will remain an unsolved mystery.
Plotting a Dot doesn't centre it above. It just plots little dots in exactly the same place as it plots a dash or a line. Adding in a displacement of 1 makes no difference either.
Cclsys,
Hopefully we could get a solution to this...this is a great indicator for those of us who trade range bars. Thanks for your initial post!
I have a proprietary indicator (subscription) that does this same type of thing but it plots the hash mark on an indicator rather than price (Desert Soft -Woodie CCI Pattern recog indicator)
I know its possible for this to be done.... just cant figure it out.
Leave a comment:
-
cclsys,
Draw() methods will place the object exactly where you tell it to go in the y parameter.
Leave a comment:
-
well, I am just going to stick with the original version and use it for myself; it works 95% of the time fine. For charts where it doesn't work, won't use it.
I don't see any difference in plotting a line versus a plot. Removing the conditional code doesn't make a difference when plotting a line except that it doesn't plot at all for some reason.
So am sticking with the original and the problem will remain an unsolved mystery.
Plotting a Dot doesn't centre it above. It just plots little dots in exactly the same place as it plots a dash or a line. Adding in a displacement of 1 makes no difference either.
Pity: I think for those that trade with Range Bars this would be a handy addition. But unless the problem can be nailed down, it is not 100% consistent so cannot be recommended.Last edited by cclsys; 08-13-2009, 01:29 PM.
Leave a comment:
-
I did change everything as per your suggestion to Drawing Lines instead of a Plot, but the same problem persisted in that sometimes it was fine and sometimes not.
I take your suggestion about the Dot instead of a line if indeed it is not possible to position a line as one positions the Hash, although presumably somewhere there is coding that tells the Hash where to be plotted and if so, in theory, one should be able to replicate that with a line, no? If it is absolutely not possible, then okay, have to go with a dot. Problem with a dot: it is hard to see unless you make it big. A small but 2-thickness thick line works great, but much better as a hash mark centred above the current bar than a line drawn from the end of the last bar to the beginning of the current bar.
I did not remove the return condition when I put in the Drawlines coding, although in theory that should not matter. But I will try without that condition to see if it makes a difference.
The issue still remains: on many, many charts it works exactly as foreseen and desired, so even though you say it won't work, it actually does. But on some other charts it doesn't work. It would be nice to know the precise reason why sometimes it works and sometimes it doesn't rather than a general statement saying 'what you are doing is impossible' (even though most of the time it works fine).
Leave a comment:
-
Just as Josh has stated in this thread multiple times, you can not "unset" a plot. If you want hash marks on the current bar only, do not use a plot--use DrawLine or DrawDot or something like that instead.Originally posted by Jason11 View PostYes...that is what is showing up. We just need the hash marks on the current bar only, not all the previous bars like you can see on your chart.
Leave a comment:
-
Yes...that is what is showing up. We just need the hash marks on the current bar only, not all the previous bars like you can see on your chart.Originally posted by NinjaTrader_Austin View PostJust to check in, I'm running the code posted near the beginning and everything looks fine to me. Is this what you guys are getting?
Check out my post below to see how it seems to work perfectly on the ES chart but not on the TF.
Leave a comment:
-
-
-
cclsys, you will have to get down and dirty with the code and figure out why it is not working via debugging.
To get a draw object directly overhead the bar, I would recommend using DrawDot instead of DrawLine. DrawDot plots directly overhead, instead of from the center of the current bar to the center of the previous bar, like with DrawLine.
A more efficient way to do your check would be this:
When using an "else if" only one if statement will be executed, saving computational resources because it doesn't have to check each one. If the first if statement is true, only the first "// do something" will be executed. If the first if statement is not true, it will move on to the second one and only execute the "// do something else'' if that if statement is true.Code:if (High[0] == (Low[0] + Bars.Period.Value * TickSize)) // do something else if (Low[0] == (High[0] - Bars.Period.Value * TickSize)) // do something else
If you still have questions, let us know.
Leave a comment:
-
I would still like to know why sometimes the original works and sometimes it doesn't. It is better (plotting the hash) but also there are occasional times with the new one when the line doesn't move in response to the bar changes, whereas the original plot hashes moved perfectly every time and immediately.
Here is the condition:
if (
( High[0] == ( Low[0] + (Bars.Period.Value*TickSize) ) )
||
( Low[0] == ( High[0] - (Bars.Period.Value*TickSize) ) )
)
return;
Now it is unnecessary to have both conditions since if one happens so does the other, but I don't think it can hurt. In other words, if the High-Low = the Range set for the bar, don't plot anything.
Is there another more foolproof way of doing this?
Leave a comment:
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by cmoran13, 04-16-2026, 01:02 PM
|
0 responses
51 views
0 likes
|
Last Post
by cmoran13
04-16-2026, 01:02 PM
|
||
|
Started by PaulMohn, 04-10-2026, 11:11 AM
|
0 responses
31 views
0 likes
|
Last Post
by PaulMohn
04-10-2026, 11:11 AM
|
||
|
Started by CarlTrading, 03-31-2026, 09:41 PM
|
1 response
165 views
1 like
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
100 views
1 like
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
160 views
2 likes
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|

Leave a comment: