Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CancelOrder

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    CancelOrder

    HI,

    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'

    #2
    Hello agenor,

    Thank you for your post.

    You are running into the Internal Order Handling Rules (http://www.ninjatrader.com/support/h...d_approach.htm) for the double Enter() methods that are opposing (Long vs. Short). You need to wait until the first Enter() order is cancelled, CancelOrder() submits the command to cancel but this does not mean the order is cancelled. You would check OnOrderUpdate() for the status of the order: http://www.ninjatrader.com/support/h...rderupdate.htm

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    648 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    369 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    108 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    572 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    573 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X