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
Current Range Bar possible High & Low Plot
Collapse
X
-
I blew it up a little so you could see, but also everything got somewhat 'fat'.
When the indicator works properly, it simply plots a hash mark above and below the currently forming Range Bar until such time as it is complete, i.e. with a 4-tick range bar the bar is incomplete with only 1,2 or 3 tick range, but as soon as the High-Low = 4 ticks, that Range Bar is 'complete' and the code says that as soon as this condition is met, 'return', i.e. don't plot anything.
On most charts this is working exactly as desired, but for some reason on some charts, the plots remain there on previous bars making for a messy-looking chart. My picture shows many bars in the past (i.e. not the current bar on the chart, i.e. the last bar) with the hash plots at the High and Low of a bar. It doesn't happen every bar, but on many.
So I have no idea why most of the time it works fine, but some of the time it does not.
Comment
-
I attach a couple more little pictures showing it working properly, once when the bar is complete but the new bar is not yet up, the second with a new bar (and different range number of 6 versus 4 in the first) showing the hash plots indicating the maximum possible high and/or low of the currently -forming bar. I also show a few previous bars that have no left-over hash plots - as is the case when it is working properly.
Comment
-
I have also tried printing out to many decimals as in the following:
Print( PossHigh[0].ToString("0.0000000"));
Print( PossLow[0].ToString("0.0000000"));
Print( Close[0].ToString("0.0000000"));
But although it compiles, it does not print anything to the Output window. This is following the tip in the Help Menu:
Tips
1. You can align prices to be formatted for easier debugging such as Low[0].ToString("0.00").
I suspect I am not understanding how to use those strings, but since nothing is explained am not sure how to proceed. Do I have to alter the main coding to have everything put into string mode? I doubt it, but in any case, don't know how to do that yet.
Comment
-
Originally posted by NinjaTrader_Josh View PostOnce you set a plot it does not get unset just because a condition is no longer true. I suggest you drop the whole plot idea and just simply use DrawLine(). Draw two lines where needed and remove the line objects when not needed.
Also, when you say: "Once you set a plot it does not get unset just because a condition is no longer true.": the funny thing is, it works fine on 90% of the charts, but doesn't only on a few for mysterious reasons. Which is why I sent in the example pictures. in the first 'good' picture, there had been plots above and below but once the bar was formed they were no longer plotted.
I suspect another reason for this might be that if the bar closes at a high or low which often happens but the next tick is the new bar at which point there is a new Close[0] that the old bar did not have time to have the plots removed, i.e. Tick 300 makes the bar complete and Tick 301 makes a new bar, or maybe even Tick 300 was NOT a complete bar but it trades through the price and the next tick creates a new bar.
Having written the above I threw up a 2-tick range chart and it works perfectly with only the current forming bar having the two hash marks. Then I threw up a 1-tick range chart, can't get any tighter than that: works great! So: still a mystery!
If you could provide an example of how to plot a line that is only the width of a hash mark and also tell it to go away afterwards as a new bar forms, that would be much appreciated, since that is all I am trying to do here: plot the possible high and low of a forming Range Bar and once it is formed, have those plots disappear, either whilst the bar is still up there or when the new bar starts, either way is fine. But what I don't want is all those lines/hashes left over simply because it makes the chart look messy.Last edited by cclsys; 08-13-2009, 09:33 AM.
Comment
-
Unfortunately I cannot review your code to determine what is happening with it, but I assure you in normal behavior, once set, plots do not just unset.
DrawLine() then RemoveDrawObject() when you don't want it anymore.
You could even just use DrawLine() with a tag name and then when it is time to draw a new line, use the same tag name which would then move the old line to the new location.Josh P.NinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_Josh View PostUnfortunately I cannot review your code to determine what is happening with it, but I assure you in normal behavior, once set, plots do not just unset.
DrawLine() then RemoveDrawObject() when you don't want it anymore.
You could even just use DrawLine() with a tag name and then when it is time to draw a new line, use the same tag name which would then move the old line to the new location.
The Output Window is printing now. I guess when it is connected it only prints new occurrences. I didn't know that. In any case, the decimals seem to be identical so that isn't the issue.
Printing question:
How do I tell it to print 2 or more things on the same line with spaces in between. There are no examples in the Help Menu. For example:
Print(Time, Close[0], my double);
Comment
-
Originally posted by NinjaTrader_Josh View Postcclsys,
Please look at the Help Guide articles for them. Examples are almost always contained there.
Print(Time[0] + " " + Close[0] + " " + double);
As to the Drawing Objects, from the Help Menu (before reading your links which are the same) I added in:
DrawLine("PossHigh", false, 1, PossHigh[0], 0, PossHigh[0], Color.Olive,DashStyle.Solid, 3);
DrawLine("PossLow", false, 1, PossLow[0], 0, PossLow[0], Color.MediumBlue, DashStyle.Solid, 3);
Also shorter form:
//DrawLine("PossHigh", 1, PossHigh[0], 0, PossHigh[0], Color.Olive);
It is working fine although I haven't tested on lots of charts so maybe the same problem will re-occur as it does with the original version.
I have the original Plots as Transparent now though probably the whole thing should be re-written to have them just as data series and to start off defining 2 lines, but anyway:
Problem: is there any way to emulate the Hash plot which plots above the bar, centred above it. Right now it seems I can only draw a line from the previous bar to the beginning of the current bar. It works, but it would be much nicer if I could at least get it centred and/or stretch it out wider to a little bit past the current bar.
I attach pic so you can see the problem.
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?
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:
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.AustinNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by ageeholdings, 05-01-2024, 05:22 AM
|
6 responses
42 views
0 likes
|
Last Post
by ageeholdings
Today, 08:37 PM
|
||
Started by tony_28217, Today, 07:04 PM
|
0 responses
11 views
0 likes
|
Last Post
by tony_28217
Today, 07:04 PM
|
||
Started by flybuzz, Today, 10:33 AM
|
1 response
9 views
0 likes
|
Last Post
by flybuzz
Today, 06:59 PM
|
||
Started by spencerp92, 10-10-2023, 09:56 AM
|
4 responses
308 views
0 likes
|
Last Post
by flybuzz
Today, 06:45 PM
|
||
Started by samish18, Yesterday, 10:13 AM
|
1 response
26 views
0 likes
|
Last Post Today, 06:15 PM |
Comment