When using Draw.TextFixed, is the application purposely removing any added spaces to the string? this doesn’t work. Is there any other way to add spaces at the beginning or end of the string here?
@several Someone may have a much simpler answer than mine, but here are two options if nobody else responds with a simpler answer.
If the NinjaScript framework is stripping the ’ ’ character specifically, you could try one of the many other Unicode whitespace characters instead of the ’ ’ character.
If the NinjaScript framework strips all Unicode whitespace characters, you could still accomplish the same visual effect by adding a Windows Presentation Foundation (WPF) Label control to the NinjaScript indicator’s (or strategy’s) “ChartControl” at the same location of the ChartControl you mentioned (BottomRight), and provide the desired number of device-independent pixels to the Label control’s left and/or right margin or padding. That would be a lot more work however, but it would definitely work on NinjaTrader charts that have a “ChartControl”, i.e. live charts and charts in Market Replay, but not Strategy Analyzer back-test charts.
I think the easiest way would be to use a fixed font like Consolas as opposed to other scalable fonts. This is especially useful if you have a multi-line string with fields that need to line up together - like decimal points, right or left justified, etc. Scalable fonts will squeeze the text differently depending on the characters in the string.
The Draw.TextFixed() documentation explains how you can print using a specific font.
[quote=“several, post:9, topic:2390”]
Sorry I can’t figure out how to post code in a box that maintains the exact formatting (like the code you posted). The leading/trailing spaces in the sample code I posted is being truncating, just like what NT is doing to your code.
Don’t use multiple “\u0000” entries…instead put the desired spaces in the " testing " string, surrounded by a single pair of “\u0000” entries. I believe the pic you posted does have the leading/trailing spaces that are in your code…just add more spaces within the quotes.
String text = “ Whatever your text is. “ Theres no need to create another set of quotes for your spaces… place the first quotation add spaces write your text add more spaces the close your quote”