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
Prevent drawings from displaying in right margin
Collapse
X
-
Prevent drawings from displaying in right margin
Is it possible to prevent drawings from displaying in the right margin? When I am scrolling through price action, I don't want to see any drawings until the bar is displayed. In the example I am using DrawDots().Tags: None
-
Hello tjw, and thank you for your question.
If you use the overload for DrawDot that uses a BarsAgo parameter, that is
DrawDot(string tag, bool autoScale, int barsAgo, double y, Color color)
This will prevent you from drawing past the current bar. Here is the documentation for DrawDot for more information.
Please let us know if there is any other way we can help.Jessica P.NinjaTrader Customer Service
-
Jessica,
I am using the BarsAgo overload, which works if you are at the far left of the time frame you are looking at and step forward, but if you back up the Dots will still print in the right margin where Plots do not. Or more typically if the data is loaded and you look back in time you would have to reload the Ninjascript (F5) everytime you scroll back in time.
i.e in the example the Fuchia lines are a Plot and the Dots are from
DrawDot("Dot"+CurrentBar.ToString(), true, 0, High[0]+(TickSize*offset), Color.Cyan);
When you back up the chart the Plots will hide while the Dots (or any other drawings) remain.
Comment
-
Hello again tjw0001,
While the functionality you would need to accomplish this is not documented, the examples in these threads should give you all you need to accomplish this goal. You will need three pieces of information :
- The X coordinate of the furthest forward bar. Please see these threads :
- http://ninjatrader.com/support/forum...ad.php?t=23979
- http://ninjatrader.com/support/forum...ad.php?t=73732
- and search the internet for ChartControl.GetXByBarIdx()
- The right-side margin. Please see this thread :
- http://ninjatrader.com/support/forum...ad.php?t=29136
- and search the internet for ChartControl.BarMarginRight
- The coordinates of the right side of the screen. Please see this thread :
- http://ninjatrader.com/support/forum...ead.php?t=6210
- and search the internet for ChartControl.CanvasRight
This code snippet should help get you started.
Code:[FONT=Courier New] if (ChartControl.GetXByBarIdx(Bars, 0) < ChartControl.CanvasRight - ChartControl.BarMarginRight) { Print("On screen"); } else { Print("Off screen"); }[/FONT]
Please let us know if there are any other ways we can help.Jessica P.NinjaTrader Customer Service
Comment
- The X coordinate of the furthest forward bar. Please see these threads :
-
Can Ninja Devs implement what is being requested? The behaviour of the right hand margin is inconsistent. For histograms the right hand margin persists when scrolling left. For the chart price panel it does not persist when scrolling left. This really looks like a bug that has been overlooked. Can the Ninja devs at least provide a full code snippet to solve this problem or a custom ninja script indicator that can be loaded to solve this issue? Thank you.
Comment
-
Thank you for your question zextra.
NinjaTrader 7 is no longer under active development, and if a bug is discovered any fixes are going to have to be implemented at the user NinjaScript level.
I have used the code snippet I posted in July to create an indicator which moves a drawn object behind a margin. I recommend using 5 second bars to see it in action. Code samples we provide are for educational purposes, and are not intended for live trading, and are not guaranteed to accomplish any user goal or to be maintained.
Please let us know if there are any other ways we can help.Attached FilesLast edited by NinjaTrader_JessicaP; 04-24-2017, 10:05 AM.Jessica P.NinjaTrader Customer Service
Comment
-
Thank you for this additional information. The capability to draw objects past the right margin must be granted to programmers for several existing tools to continue working. ChartControl and ChartScale are now documented in NinjaTrader 8, with code samples available in the help guide.
If a user desires drawing objects always be placed within margins, they will need to use a filter similar to the one that exists in the script example I posted in post #6. In anticipation of the possibility that you were asking a NinjaTrader 8 question, the script example was created with NinjaTrader 8 in mind, and in your code the NT7 Plot code should work as-is in NT8 OnRender with minor modifications (such as using Draw.Rectangle instead of DrawRectangle). CurrentBar not being guaranteed is a limitation new to NinjaTrader 8, however this has already been accounted for in the NT7 code sample.
We will be happy to help with any specific questions that come up during the process of implementing the advice in this thread.Jessica P.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by r68cervera, Today, 05:29 AM
|
0 responses
3 views
0 likes
|
Last Post
by r68cervera
Today, 05:29 AM
|
||
Started by geddyisodin, Today, 05:20 AM
|
0 responses
6 views
0 likes
|
Last Post
by geddyisodin
Today, 05:20 AM
|
||
Started by JonesJoker, 04-22-2024, 12:23 PM
|
6 responses
35 views
0 likes
|
Last Post
by JonesJoker
Today, 05:14 AM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
12 responses
3,241 views
0 likes
|
Last Post
by Leafcutter
Today, 05:08 AM
|
||
Hi
by AveryFlynn
Started by AveryFlynn, Today, 04:57 AM
|
0 responses
7 views
0 likes
|
Last Post
by AveryFlynn
Today, 04:57 AM
|
Comment