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 4,517 views
    2. thumb_up 3 thanks given
    3. group 2 followers
    1. forum 5 posts
    2. attach_file 0 attachments




 
Search this Thread

Convert String to double

  #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 Twitter Visit my NexusFi Trade Journal 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
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Better Renko Gaps
The Elite Circle
MC PL editor upgrade
MultiCharts
How to apply profiles
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
18 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,401



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,443 since Jun 2009
Thanks Given: 33,217
Thanks Received: 101,607


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 Twitter 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,168 since Jan 2013
Thanks Given: 57,452
Thanks Received: 26,278

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 Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote




Last Updated on December 6, 2013


© 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