NexusFi: Find Your Edge


Home Menu

 





Convert String to double


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one westsider with 2 posts (0 thanks)
    2. looks_two Big Mike with 1 posts (1 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 bobwest with 1 posts (1 thanks)
    1. trending_up 5,454 views
    2. thumb_up 3 thanks given
    3. group 2 followers
    1. forum 5 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 
westsider's Avatar
 westsider 
St Louis, MO
 
Experience: Intermediate
Platform: Ninjatrader TOS Jigsaw
Broker: Ninjatrader
Trading: MES
Posts: 114 since Jun 2011
Thanks Given: 55
Thanks Received: 127

Anybody know how to convert a string to a double in ninjascript?


Follow me on X Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
What we know about Binances $6.3bn hack - BBC News
Cryptocurrency
My Rant with AMP Futures
Trading Reviews and Vendors
requesting .nrd replay files from 2026 spy and qqq
The Elite Circle
Bitcoin’s 2022 low, 2025 high and 2026 low so far arou …
Cryptocurrency
AI for Traders — Agents, Memory, Tools & Real-Worl …
Elite Quantitative GenAI/LLM
 
  #3 (permalink)
 
Tasker_182's Avatar
 Tasker_182 
Cedar Rapids, iowa
Legendary Market Wizard
 
Experience: Intermediate
Platform: Ninjatrader
Broker: Ninjatrader - Continuum
Posts: 716 since Aug 2009
Thanks Given: 476
Thanks Received: 1,406



westsider View Post
Anybody know how to convert a string to a double in ninjascript?

Does this help?

Double.TryParse Method (String, Double) (System)


Be yourself; everyone else is already taken. Oscar Wilde
Reply With Quote
Thanked by:
  #4 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 R.I.P. 1977-2026 
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,599


westsider View Post
Anybody know how to convert a string to a double in ninjascript?

mydouble = Convert.ToDouble(mystring);

Mike




We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on X Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #5 (permalink)
 
bobwest's Avatar
 bobwest 
Western Florida
Site Moderator
 
Experience: Advanced
Platform: Sierra Chart
Trading: ES, YM
Frequency: Several times daily
Duration: Minutes
Posts: 8,175 since Jan 2013
Thanks Given: 58,026
Thanks Received: 26,426

A few ways; all just C#, not specific to Ninja:

double doubleVar;
string stringVar = "12";
doubleVar = Convert.ToDouble(stringVar);

See Convert.ToDouble Method (String) (System)
(This is what I would use if I knew the string would only contain numbers)

---------
Also

string stringVar = "12";
double doubleVar;
doubleVar = Double.Parse(stringVar);

See Double.Parse Method (String) (System)

-------
Also

string stringVar = "12";
double doubleVar;

if (Double.TryParse(stringVar, out doubleVar))
{
// If successful, variable doubleVar will contain the converted double
// Do something with doubleVar here
}
else
{
// If not successful (maybe the string didn't have numbers in it, handle it here
}

See Double.TryParse Method (String, Double) (System)


When one door closes, another opens.
-- Cervantes, Don Quixote
Reply With Quote
Thanked by:
  #6 (permalink)
 
westsider's Avatar
 westsider 
St Louis, MO
 
Experience: Intermediate
Platform: Ninjatrader TOS Jigsaw
Broker: Ninjatrader
Trading: MES
Posts: 114 since Jun 2011
Thanks Given: 55
Thanks Received: 127

What a wealth of knowledge and talented programmers we have here! I was trying to take text from a windows form and use it as variables in a strategy. Worked perfectly!
Thank You!

This worked for my situation;

double doubleVar;
string stringVar = "12";
doubleVar = Convert.ToDouble(stringVar);


Follow me on X Visit my NexusFi Trade Journal Started this thread Reply With Quote




Last Updated on December 6, 2013


© 2026 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 - Downloads - Top
no new posts