I'm putting an iOrder and sometimes I need to change it's Action from SellShort to Buy as the following example. Actually I think this is not possible. So I'm both using the CancelOrder command and entryOrder =null to cancel it when I need to chance the Action....However, I'm getting an error. It is not being cancelled and the new order seems to be Ignored and returning an error since it has a different action....
if(disparo=="c") // this determined tha the entryOrder now it a Buy order
{
if(entryOrder[i]!=null)
if(entryOrder[i].OrderAction==OrderAction.SellShort)
{
CancelOrder(entryOrder[i]);
entryOrder[i]=null;
} if(Historical==true && CurrentBar==Count-1)
pin[i] = MAX(High,CurrentBar-fundobar)[1]-desvio;
else
pin[i] = MAX(High,CurrentBar-fundobar)[0]-desvio;
stop[i] = Math.Max(pin[i]-stopin,fundo);
alvo[i] = pin[i]+gain;
entryOrder[i]=EnterLongLimit(ncontratos,pin[i],"Entry"+Convert.ToString(i));
}
The Output:
11/12/2014 12:00:00 Entered internal PlaceOrder() method at 11/12/2014 12:00:00: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=1 LimitPrice=49365 StopPrice=0 SignalName='Entry0' FromEntrySignal=''
11/12/2014 12:00:00 Amended open order: Action=SellShort OrderType=Limit Quantity=1 LimitPrice=49365 StopPrice=0 SignalName=Entry0' FromEntrySignal=''
11/12/2014 12:03:00 Entered internal PlaceOrder() method at 11/12/2014 12:03:00: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=1 LimitPrice=49370 StopPrice=0 SignalName='Entry0' FromEntrySignal=''
11/12/2014 12:03:00 Amended open order: Action=SellShort OrderType=Limit Quantity=1 LimitPrice=49370 StopPrice=0 SignalName=Entry0' FromEntrySignal=''
11/12/2014 12:03:01 Entered internal PlaceOrder() method at 11/12/2014 12:03:01: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=1 LimitPrice=49250 StopPrice=0 SignalName='Entry0' FromEntrySignal=''
11/12/2014 12:03:01 Ignored PlaceOrder() method at 11/12/2014 12:03:01: Action=Buy OrderType=Limit Quantity=1 LimitPrice=49250 StopPrice=0 SignalName=Entry0' FromEntrySignal='' Reason='An Enter() method to submit an entry order has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.'
**NT** An Enter() method to submit an entry order at '11/12/2014 12:06:00' has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.
11/12/2014 12:03:01 Cancelled expired order: BarsInProgress=0: Order='dfe5e669d55a4869b776378cec3a34f9/Replay101' Name='Entry0' State=Working Instrument='WIN 12-14' Action=SellShort Limit price=49370 Stop price=0 Quantity=1 Strategy='Scalping' Type=Limit Tif=Day Oco='' Filled=0 Fill price=0 Token='dfe5e669d55a4869b776378cec3a34f9' Gtd='01/12/2099 00:00:00'

Comment