I keep getting the following error:

Algorithm Error: Error in orders - Order price ($198.73) too far from reality ($198.66).

OnTradeBar code is:

decimal min_limit = 1.02m;

foreach(string security in mySecurities){

if (securityData.ContainsKey(security)){

if (Portfolio[security].HoldStock){

if (securityData[security].high / Portfolio[security].AveragePrice >= min_limit ||

Portfolio[security].AveragePrice / securityData[security].high >= min_limit){

Order(security, -100); //symbol, quantity


} else {

Order(security, 100);




mySecurities is defined as an array of strings:

private string[] mySecurities = {"IBM"} // etc etc

The error only occurs when mySecurities has more than one item, eg {"IBM", "AIG", "AXP"}

It seems random and when it occurs the simulation halts.

Any ideas what is going on?