NexusFi: Find Your Edge


Home Menu

 





NT8 Get String Size (Used to be Graphics.MeasureString in NT7)


Discussion in NinjaTrader

Updated
    1. trending_up 1,575 views
    2. thumb_up 2 thanks given
    3. group 1 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
Search this Thread

NT8 Get String Size (Used to be Graphics.MeasureString in NT7)

  #1 (permalink)
 Maza 
Cluj-Napoca Cluj/Romania
 
Experience: Intermediate
Platform: NinjaTrader, MetaTrader 4
Broker: FXCM, Continuum
Trading: Forex, Futures
Posts: 12 since Apr 2013
Thanks Given: 6
Thanks Received: 7

Hello NT8 Programmers Happy New Year,

I have been slaving over conversions from NT7 to NT8 lately and I ran into an issue that I just can't find the solution to.

Let's just get to the point. I am trying to build an arrow with text that doesn't overlap when you change the chart scale or zoom in and out (this I have figured out), but the issue now is when I try to have 2 arrows with text one above the other, and scale the chart of course. What I feel is missing is the ability to use a Grapics.MeasureString so I can get the size in pixels of the text and plot the arrow below or above what ever the case might be.

Does anyone have any idea how to "Measure String" in NT8 or something similar?

Thanks in advance,

Maza.

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
What broker to use for trading palladium futures
Commodities
REcommedations for programming help
Sierra Chart
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Cheap historycal L1 data for stocks
Stocks and ETFs
 
  #3 (permalink)
 
ratfink's Avatar
 ratfink 
Birmingham UK
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
Posts: 3,633 since Dec 2012
Thanks Given: 17,423
Thanks Received: 8,426



Maza View Post
Hello NT8 Programmers Happy New Year,

I have been slaving over conversions from NT7 to NT8 lately and I ran into an issue that I just can't find the solution to.

Let's just get to the point. I am trying to build an arrow with text that doesn't overlap when you change the chart scale or zoom in and out (this I have figured out), but the issue now is when I try to have 2 arrows with text one above the other, and scale the chart of course. What I feel is missing is the ability to use a Grapics.MeasureString so I can get the size in pixels of the text and plot the arrow below or above what ever the case might be.

Does anyone have any idea how to "Measure String" in NT8 or something similar?

Thanks in advance,

Maza.

I don't know NT8 or WPF but I would think you'd need to start somewhere near here:

https://msdn.microsoft.com/en-us/library/system.windows.media.formattedtext.aspx

Cheers

Travel Well
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #4 (permalink)
 Maza 
Cluj-Napoca Cluj/Romania
 
Experience: Intermediate
Platform: NinjaTrader, MetaTrader 4
Broker: FXCM, Continuum
Trading: Forex, Futures
Posts: 12 since Apr 2013
Thanks Given: 6
Thanks Received: 7


ratfink View Post
I don't know NT8 or WPF but I would think you'd need to start somewhere near here:

https://msdn.microsoft.com/en-us/library/system.windows.media.formattedtext.aspx

Cheers

Thanks for the link RatFink, I will have a detailed look at it.

Started this thread Reply With Quote
Thanked by:
  #5 (permalink)
 Maza 
Cluj-Napoca Cluj/Romania
 
Experience: Intermediate
Platform: NinjaTrader, MetaTrader 4
Broker: FXCM, Continuum
Trading: Forex, Futures
Posts: 12 since Apr 2013
Thanks Given: 6
Thanks Received: 7

Ok so I solved the issue, kind of, and I will write it here if anyone else wants to do this sort of thing in the future.

First of all I got the price from arrow1 and I changed it to pixels, then I added a few pixels and the custom auto pixeling bit of code that accounts for the scaling of the arrows and, to my surprise that it worked, I added the size of the font to the arrow1 pixels, then transformed it all back to price and set arrow2 price to the newly calculated price.

I hope this helps anyone that comes across the same problem in the future.

Maza.

Started this thread Reply With Quote




Last Updated on January 15, 2016


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts