For most instruments there isn't an issue, but for bonds that trade in fractions it's much easier to say 138'2 than 138.0625. Is there a type converter or tool that would convert the Bond's shorthand given as a string to a double?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Fractions as inputs for an indicator running on Bonds
Collapse
X
-
Fractions as inputs for an indicator running on Bonds
I have an indicator that takes two prices as inputs.
For most instruments there isn't an issue, but for bonds that trade in fractions it's much easier to say 138'2 than 138.0625. Is there a type converter or tool that would convert the Bond's shorthand given as a string to a double?Tags: None
-
Hello Dan,
Thanks for your post.
There isn't a TypeConverter available that I could suggest, but you could consider parsing the string, checking if it has a ' and then you can divide the subscript by 32 and add it to the whole number.
I look forward to assisting.Code:string input = "123'2"; string[] split = input.Split('\''); double subscript = double.Parse(split[1]); subscript = subscript / 32; double number = double.Parse(split[0]); Print((number + subscript).ToString());
-
Thanks Jim.
I didn't think there was anything, but wanted to check to be sure.
FYI for everyone reading this...
Jim's example is good for the specific case of ZB. To make this work for all instruments using the apostrophe use:
Also some supporting code to make sure you are starting with a number and didn't get any other characters in your string that won't convert to a number.Code:subscript = subscript * Instrument.MasterInstrument.TickSize;
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Mindset, 04-21-2026, 06:46 AM
|
0 responses
44 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
58 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
35 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|
||
|
Started by cmoran13, 04-16-2026, 01:02 PM
|
0 responses
95 views
0 likes
|
Last Post
by cmoran13
04-16-2026, 01:02 PM
|
||
|
Started by PaulMohn, 04-10-2026, 11:11 AM
|
0 responses
59 views
0 likes
|
Last Post
by PaulMohn
04-10-2026, 11:11 AM
|

Comment