JangoFolly
09-11-2007, 01:03 PM
Hi. I cannot figure out how to make an int type variable take the value of an integer which is held in a double type variable.
Here is some sample code:
#region Variables
private double tickAltPeriodPro = 0.20;
// User defined variables (add any user defined variables below)
private int tickAltPeriod;
#endregion
protected override void Initialize()
{
tickAltPeriod = Math.Floor(Bars.Period.Value * tickAltPeriodPro);
Add(PeriodType.Tick, tickAltPeriod);}
For example, let's say the variable tickAltPeriodPro takes a value of 0.20. Using a tick chart with a period of 266, I would like tickAltPeriod to be equal to 53 (Floor function return value of the expression [266 * 0.20]).
If I make tickAltPeriod an int variable then I get an error when the Floor function returns a double. If I make tickAltPeriod a double then the Add function returns an error (it's expecting a int input).
Hopefully there's a simple workaround that I'm overlooking. Thank you.
Regards,
Here is some sample code:
#region Variables
private double tickAltPeriodPro = 0.20;
// User defined variables (add any user defined variables below)
private int tickAltPeriod;
#endregion
protected override void Initialize()
{
tickAltPeriod = Math.Floor(Bars.Period.Value * tickAltPeriodPro);
Add(PeriodType.Tick, tickAltPeriod);}
For example, let's say the variable tickAltPeriodPro takes a value of 0.20. Using a tick chart with a period of 266, I would like tickAltPeriod to be equal to 53 (Floor function return value of the expression [266 * 0.20]).
If I make tickAltPeriod an int variable then I get an error when the Floor function returns a double. If I make tickAltPeriod a double then the Add function returns an error (it's expecting a int input).
Hopefully there's a simple workaround that I'm overlooking. Thank you.
Regards,