I get this error (attached) every time I place StopMarket close to the current price. This happens only on a real money account. The order still gets placed though.
Here is my code:
private void OnMyButtonClick(object sender, RoutedEventArgs rea)
{
var button = sender as Button;
if (button == null || account == null) return;
var bc = button.Content.ToString();
var dir = bc == "Buy Indy" ? 1 : bc == "Sell Indy" ? -1 : 0;
if (dir == 0) return;
TriggerCustomEvent(o =>
{
var ct = ChartControl.OwnerChart.ChartTrader;
if (ct == null) return;
OnAttach();
if (Attached == null) return;
isAttach = true;
initDir = IndieValue > Close[0] ? -1 : 1;
var v = IndieValue;
var oType =
v > Close[0]
? dir > 0
? OrderType.StopMarket
: OrderType.Limit
: dir > 0
? OrderType.Limit
: OrderType.StopMarket;
var entryOrder =
account.CreateOrder(
Instrument
, dir > 0 ? OrderAction.Buy : OrderAction.Sell
, oType
, TimeInForce.Day
, ct.Quantity
, v , v
, null, "Entry", null);
if (ct.AtmStrategy != null)
AtmStrategy.StartAtmStrategy(ct.AtmStrategy, entryOrder);
else
account.Submit(new[] { entryOrder });
myOrders.Add(entryOrder);
}, null);
}​
Comment