Wizard
12-04-2007, 01:31 PM
I have an often recurring problem where I place multi-line text above a bar (using DrawText) and would like to keep it just above the bar regardless of the y range of the chart. Since DrawText anchors the text at the top of the specified Y value, I have to pick a Y value that is above the bar and high enough so that all lines of text are above the price bar. The problem is that when you scroll the chart left and right, the displayed Y range changes and the text will move drastically, from covering the bar (which I don't want; this happens when the chart's displayed Y range is large - during high volatility) to being so high above the bar that it is way off the chart and thus not visible (which I also don't want; this happens when the chart's displayed Y range is small - during low volatility).
I tried to get around this by choosing a Y value based on the chart's displayed Y range up to that point, but this often makes the problem worse because volatility, and thus the chart's displayed Y range, often changes and the nicely positioned text will suddenly move off the chart or over the bar as the chart moves or scrolls.
The only solution as far as I can tell is for NinjaTrader to add the capability to anchor text at the bottom of the text in addition to what it currently does, which is anchoring at the top. If you do this, which I sincerly hope that you do, you will probably want to do it via adding an extra argument to the DrawText() method. This way you can always add other anchoring options (now or in the future) for anchoring in other spots too (for example: left, right, center). You may also want to consider adding a pixel offset argument so that you could, for example, keep the text consistently 7 pixels above the price bar.
Thanks!
I tried to get around this by choosing a Y value based on the chart's displayed Y range up to that point, but this often makes the problem worse because volatility, and thus the chart's displayed Y range, often changes and the nicely positioned text will suddenly move off the chart or over the bar as the chart moves or scrolls.
The only solution as far as I can tell is for NinjaTrader to add the capability to anchor text at the bottom of the text in addition to what it currently does, which is anchoring at the top. If you do this, which I sincerly hope that you do, you will probably want to do it via adding an extra argument to the DrawText() method. This way you can always add other anchoring options (now or in the future) for anchoring in other spots too (for example: left, right, center). You may also want to consider adding a pixel offset argument so that you could, for example, keep the text consistently 7 pixels above the price bar.
Thanks!