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 Tasker_182 with 1 posts (1 thanks)
    3. looks_3 Big Mike with 1 posts (1 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 5,122 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?
Irans Answer Due Today: Peace Surges to 33.5%, Invasion …
Prediction Markets & Event Contracts
Victory Day Delivers: Russia-Ukraine Ceasefire Market Cl …
Prediction Markets & Event Contracts
Iran Airspace Contract Surges to 33.5% as Project Freedo …
Prediction Markets & Event Contracts
Prediction Markets Expiry Day: Trump Eyes War Exit, $230 …
Prediction Markets & Event Contracts
MyForexFunds Begins Returning Frozen Funds After CFTC Ca …
Funded Trading Evaluation Firms
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
7 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #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,405



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
 
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,557


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,174 since Jan 2013
Thanks Given: 57,989
Thanks Received: 26,406

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