PDA

View Full Version : Problem using Math.ceiling & .floor


kuroro13
07-29-2008, 01:50 PM
Here's my script :

V1=Period / 2;
if ((Math.Ceiling (V1) - V1) <= 0.5)
{ HalvedLength = Math.Ceiling(V1);}
else
{HalvedLength = Math.Floor(V1);}

if ((Math.Sqrt(Period) - Math.Sqrt(Period)) <= 0.5)
{ SqrRootLength = Math.Sqrt(Period );}
else
{SqrRootLength = Math.Sqrt(Period);}

Value1.Set(2 * T3(Price,0.7,HalvedLength)[0]);
Value2.Set(T3(Price,0.7,Period)[0]);
Value3.Set(Value1[0]-Value2[0]);

Rising.Set(T3(Value3,0.7,SqrRootLength)[0]);

The problem is that my HalvedLength and SqrRootLength must be integer since they are T3 moving average parameters and the Math.Ceiling and .Floor can only be used with decimal or double.
What should I do ?

NinjaTrader_Ray
07-29-2008, 02:05 PM
Can't you just cast to an int?

HalvedLength = (int) Math.Floor(V1);

kuroro13
07-29-2008, 02:06 PM
This is weird because the floor of a number is an integer...why does the Math.Floor function return a double ?
That is simply illogic

kuroro13
07-29-2008, 02:08 PM
it works !!!

thank you very much, you're my savior