me again Happens I have another unexplained behavior now that the markets are open. I have a problem moving the stop price.
Here is the log, with explanations:
POSITION: Long 1 @ 9014
Activating Trail for Position Long
Cancelled custom managed order at 27/07/2009 18:24:55: Order='22eef3ad407c446e9a80cd0f6b0abc22/Sim101' Name='HA3 STP' State=Accepted Instrument='YM 09-09' Action=Sell Limit price=0 Stop price=8998 Quantity=1 Strategy='HeinekenAshiReversal' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='22eef3ad407c446e9a80cd0f6b0abc22' Gtd='01/12/2099 00:00:00'
27/07/2009 18:24:55 Entered internal PlaceOrder() method at 27/07/2009 18:24:55: Action=Sell OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=9009 SignalName='HA3 STP' FromEntrySignal='HA3 L'
27/07/2009 18:24:55 Ignored PlaceOrder() method: Action=Sell OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=9009 SignalName=HA3 STP' FromEntrySignal='HA3 L' Reason='There already is a matching, terminal exit order in place'
Basiucallz I am short one contract after the execution, so my stop loss on the last position has to change.
Here is what I do:
* I cancel the stop order in the system.
* I enter a new one.
Ad can be seen above, there is a cancel for a stop loss for signal "HA3 STP". This cancel is accepted from your system.
I then enter a new stop, same signal name. And I get the info that there laready is a terminal exit order in place.
Can be related to me doing that on a life feed, NOW (i.e. cancel and set stop happen in the same execution event). Do I have to wait until the cancel is accepted (which makes my code harder)? What can eplain this, and what is the proposed strategy to move trailing stops, if not cancel/reentry? Shall I just put in the new stop, and your system will turn that from a new order into an update?
My code is:
if (
Stop != null
&& (StopPrice != Stop.StopPrice || Quantity != Stop.Quantity)
) {
_Manager._Strategy.CancelOrder (Stop);
Stop = null;
}
if (StopPrice == 0 || Quantity == 0) {
return null;
}
string signal = Token + " STP";
string entrysignal = null;
switch (Direction) {
case MarketPosition.Long:
entrysignal = Token + " L";
Stop = _Manager._Strategy.ExitLongStop (0, true, Quantity, StopPrice, signal, entrysignal);
break;
case MarketPosition.Short:
entrysignal = Token + " S";
Stop = _Manager._Strategy.ExitShortStop (0, true, Quantity, StopPrice, signal, entrysignal);
break;
}
_Manager._ActiveOrders [Stop.Token] = new OrderIndex (this, OrderSlot.Stop);
return Stop;
Comment