Futures have varying increments. Here's (very inefficient) C# code to figure it out:
// Compute the trailing stop offset. Does rounding and sets intergral number of increments.
// (Could be done more efficiently.)
private double RoundIncrement(double rawAmount)
{
double w = rawAmount; // Start.
double x = w + tradeIncrement*0.499; // Add round up/down control, conservative.
x = Math.Round(w,2); // Round to 2 decimal places.
double y = Math.Floor(x); // Get integer part.
double z = (x - y); // Get fractional part.
double n = Math.Floor(z/tradeIncrement); // How many integral trade increments in the fraction?
double r = Math.Round(y + n*tradeIncrement,2); // Attach increments to integer part.
string msg = string.Format("Trail: submitted={0:F3} raw={1:F3} n={2}", r, w, n);
OutputMessage(msg);
return r;
}
rawAmount is the amount to be rounded. tradeIncrement is whatever is appropriate for the instrument. YM is 1. ES and NQ are 0.25. Stocks are .01.
-Pete
See also Yahoo group about applying RE.