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
Rounding to the nearest integer...
Collapse
X
-
Thank you Sledge and Koganam
I will make some adjustments and keep you posted. Thanks!!
-
Originally posted by [email protected] View Postdoes not work...................
#region Variables
private int period = 14;
private int trueRangeInt = 0;
private double trueRange = 0;
#endregion
.
.
.
.
.
if (CurrentBar == 0)
Value.Set(High[0] - Low[0]);
else
{
trueRange = High[0] - Low[0];
trueRange = Math.Max(Math.Abs(Low[0] - Close[1]), Math.Max(trueRange, Math.Abs(High[0] - Close[1])));
trueRange = trueRange / 0.03125;
trueRangeInt = (int) trueRange;
Value.Set(((Math.Min(CurrentBar + 1, Period) - 1 ) * Value[1] + (int) trueRange) / Math.Min(CurrentBar + 1, Period));
}
.
.
.
It displays x.xx not x
why???
thanks.
Leave a comment:
-
Can we idiots get a clear example? thanks.
does not work...................
#region Variables
private int period = 14;
private int trueRangeInt = 0;
private double trueRange = 0;
#endregion
.
.
.
.
.
if (CurrentBar == 0)
Value.Set(High[0] - Low[0]);
else
{
trueRange = High[0] - Low[0];
trueRange = Math.Max(Math.Abs(Low[0] - Close[1]), Math.Max(trueRange, Math.Abs(High[0] - Close[1])));
trueRange = trueRange / 0.03125;
trueRangeInt = (int) trueRange;
Value.Set(((Math.Min(CurrentBar + 1, Period) - 1 ) * Value[1] + (int) trueRange) / Math.Min(CurrentBar + 1, Period));
}
.
.
.
It displays x.xx not x
why???
thanks.
Leave a comment:
-
Thank you!
I do lots of thanking in advance, but here it is again after the fact...
Thank you! Thank you! Thank you! Thank you! Thank you!
I realize that these are all the most simplistic of programing considerations that anyone who has taken an intro class could answer, but to me whose first encounter with C# is through NT, it's gold.
It's much appreciated.
Leave a comment:
-
If you want to convert double to int you can just cast it to an int.
(int) someDoubleVar
Leave a comment:
-
Thanks,
I guess a better question is how do you make the doube into an int. The Math.Round() that I used works just fine but the variable that's supposed to represent what is now a whole number still has to be a double instead of an int for it to compile.
I'm not sure if you're previous response was an answer to my question above. If so I will try to look it up somewhere else.
Thanks again,
Leave a comment:
-
8DTK8,
Please search google for methods of rounding numbers in C#. You should be able to find resources capable of answering your question more in depth than anything I could offer.
Leave a comment:
-
Rounding to the nearest integer...
How does one round to the nearest integer.
The particular reason is because I want to be able to take a fixed dollar amount, divide it by the risk to get the position size.
I'm coming up with errors because it's rarely a whole number.
double POSITIONsize = Math.Round(500/(ATR(Closes[0], 20)[0]*50));
EnterLongLimit(0, false, POSITIONsize, Lows[0][0] + OFFSETentry * TickSize, "Enter Long");
doesn't seem to do the trick because the system doesn't know what a .3 (for example of a contract is) and "int POSITIONsize" comes up with the same error.
Thank in advance.
Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by ageeholdings, Today, 07:43 AM
|
0 responses
8 views
0 likes
|
Last Post
by ageeholdings
Today, 07:43 AM
|
||
Started by pibrew, Today, 06:37 AM
|
0 responses
4 views
0 likes
|
Last Post
by pibrew
Today, 06:37 AM
|
||
Started by rbeckmann05, Yesterday, 06:48 PM
|
1 response
14 views
0 likes
|
Last Post
by bltdavid
Today, 05:43 AM
|
||
Started by llanqui, Today, 03:53 AM
|
0 responses
6 views
0 likes
|
Last Post
by llanqui
Today, 03:53 AM
|
||
Started by burtoninlondon, Today, 12:38 AM
|
0 responses
12 views
0 likes
|
Last Post Today, 12:38 AM |
Leave a comment: