protected override void OnMarketData(MarketDataEventArgs e)
{
[snip]
entryOrder = EnterLongStop(0, true, DefaultQuantity, longFill, signalName);
[snip]
}
protected override void OnExecution(IExecution execution)
{
{
{
targetOrder = ExitLongLimit(0, true, DefaultQuantity, targetValue, signalName + "Limit", signalName);
// Reset our stop order and target orders' IOrder objects after our position is closed.
if ((stopOrder != null && stopOrder.Token == execution.Order.Token) ||
(targetOrder != null && targetOrder.Token == execution.Order.Token))
{
execution.Order.OrderState == OrderState.PartFilled)
{
targetOrder = null;
entryOrder = null;
If I remember correctly, I took the bulk of this code from the sample code. Basically what I want to do is once I get into a long position, I want to set the target as well as stop prices immediately.
This code has been working pretty reliably for about 1 month, since I implemented it.
However, last Thursday night, I found that this code was never triggered. This was trading the DAX on the Eurex. It left my position open and just hanging there and my position had crossed both the target and stop levels.
The only thing I can think of is that OnExecution was never called, or it came out of order somehow.
My broker is IB. Is this a possibility? If so, what can I do to prevent this from occurring again? My faith in the reliability of this code is shaken because I expect this to cover all situations and I run it overnight while I sleep. I don't want to wake up again and see it in a massively losing trade.
Thanks in advance,
Ken
Comment