Converting Double to Int - futures io
futures io futures trading



Converting Double to Int


Discussion in NinjaTrader

Updated
    1. trending_up 1,984 views
    2. thumb_up 2 thanks given
    3. group 1 followers
    1. forum 3 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Converting Double to Int

(login for full post details)
  #1 (permalink)
Chicago, IL
 
Experience: Intermediate
Platform: Ninja Trader, Sierra Chart
Trading: ES, CL
 
Posts: 35 since Oct 2012
Thanks: 498 given, 12 received

Having a hard time getting this working. Looked at all the threads detailing converting a double value to an int, but I always get the 'Cannot implicitly convert type 'double' to 'int'. An explicit conversion exists.' error message int he Ninja compiler. There is no longer an error on my variable volTicks, but when I try to use volTicks in another variable's formula, I get the error on those lines.

Here is a code snippet:

volTicks = Convert.ToInt32((Position.AvgPrice - Instrument.MasterInstrument.Round2TickSize(Bollinger(1, 100).Upper[1])) / TickSize);

error is reported on these lines:
profitTarget1 = volTicks;
profitTarget2 = volTicks * 2.0;

All three variables are declared int. Really stuck on this, any help is appreciated!


Nevermind! Please delete thread... Missed a stupid error with the '2.0'.

Started this thread Reply With Quote

Can you help answer these questions
from other members on futures io?
Webinar: Finding your own way in trading w/Adam Grimes
The Elite Circle
Which kind of Blockvolume is visible? - order processing
Emini and Emicro Index
What blockvolume is visible? - order processing
NinjaTrader
Short Interest Ratio indicator?
ThinkOrSwim
Work with historical tcks data on MUltichart NET PowerLa …
MultiCharts
 
 
(login for full post details)
  #3 (permalink)
Cedar Rapids, iowa
 
Experience: Intermediate
Platform: Ninjatrader
Broker: Ninjatrader - Continuum
Trading: 6E, TF, 6J
 
Tasker_182's Avatar
 
Posts: 593 since Aug 2009
Thanks: 430 given, 1,142 received



Genshin View Post
Having a hard time getting this working. Looked at all the threads detailing converting a double value to an int, but I always get the 'Cannot implicitly convert type 'double' to 'int'. An explicit conversion exists.' error message int he Ninja compiler. There is no longer an error on my variable volTicks, but when I try to use volTicks in another variable's formula, I get the error on those lines.

Here is a code snippet:

volTicks = Convert.ToInt32((Position.AvgPrice - Instrument.MasterInstrument.Round2TickSize(Bollinger(1, 100).Upper[1])) / TickSize);

error is reported on these lines:
profitTarget1 = volTicks;
profitTarget2 = volTicks * 2.0;

All three variables are declared int. Really stuck on this, any help is appreciated!


Your line "profitTarget2 = volTicks * 2.0;" 2.0 is a double...

"Money is better than poverty, if only for financial reasons." - Woody Allen
Reply With Quote
The following user says Thank You to Tasker_182 for this post:
 
(login for full post details)
  #4 (permalink)
Chicago, IL
 
Experience: Intermediate
Platform: Ninja Trader, Sierra Chart
Trading: ES, CL
 
Posts: 35 since Oct 2012
Thanks: 498 given, 12 received


Tasker_182 View Post
Your line "profitTarget2 = volTicks * 2.0;" 2.0 is a double...

Yeah, thank you! I just caught that after I wrote this...

Started this thread Reply With Quote
The following user says Thank You to Genshin for this post:


futures io Trading Community Platforms and Indicators NinjaTrader > Converting Double to Int


Last Updated on January 29, 2014


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Importance of Finding Your Own Way w/Adam Grimes

Elite only
 

Journal Challenge w/Jigsaw

April
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts