1 - I need to find the amount of decimal places. The problem is that if the variable (in this case if opening price is 1.3200 Open[0] will return 1.32 instead of 1.3200. I am using this:
//Calculates the ammount of decimal places
string str = Convert.ToString(Open[0]);
string[] afterdot = str.Split('.');
string strfinal = Convert.ToString(afterdot[1]);
int Length = strfinal.Length;
Print("The Length Variable is" + Length);
In this case if the open price is 1.3200 Open[0] will return 1.32 and afterdot[1] will return 2 instead of 4. Is there a better way to accomplish this?
2 - The second problem is related to the first one. I am trying to convert Open[0] - Close[0] to pips. So I am using the variable Length for the amount of zeroes to multiply to this difference (Open[0] - Close[0]). I cant concatenate the zeroes.
//Round the body size. Convert to positive. Pass along the number of decimal places for the instrument.
actualbodysize = Math.Abs(Math.Round(Close[0] - Open[0],Length));
string cerodigits = "0";
for (int t = 0; t == Length; t++)
{
cerodigits = String.Concat(cerodigits, "0");
}
Print("cerodigits variable is " + cerodigits);
int actualbodysizepips = (int.Parse("1" + cerodigits) * Convert.ToInt32(actualbodysize));
Print("Actualbodysizepips variable is " + actualbodysizepips);
Print("Actual Body Size" + actualbodysize);
Print("Actual Body Size in pips" + actualbodysizepips);
cerodigits variable is returning 0 instead of 0000
actualbodysizepips is giving me 0 .
Is there a better way to to this. All this is to find the amount of pips Close - Open. Help
Comment