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
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
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.
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());
JimNinjaTrader Customer Service
-
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:
Code:subscript = subscript * Instrument.MasterInstrument.TickSize;
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by johntraderuser2, Today, 02:34 AM
|
0 responses
6 views
0 likes
|
Last Post Today, 02:34 AM | ||
Started by IanS00, 03-27-2024, 11:24 AM
|
2 responses
12 views
0 likes
|
Last Post Today, 02:00 AM | ||
Started by Mariawilcoxi, Today, 01:32 AM
|
0 responses
4 views
0 likes
|
Last Post
by Mariawilcoxi
Today, 01:32 AM
|
||
Started by gleichnerany, Today, 01:17 AM
|
0 responses
5 views
0 likes
|
Last Post
by gleichnerany
Today, 01:17 AM
|
||
Started by WHICKED, 03-27-2024, 12:33 PM
|
4 responses
46 views
0 likes
|
Last Post Today, 12:28 AM |
Comment