Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

SubmitOrderUnmanaged() don't match OCO orders

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

    SubmitOrderUnmanaged() don't match OCO orders

    Hi support!!!
    I'm sending to mkt this short trades (2)

    SubmitOrderUnmanaged(0, OrderAction.SellShort , OrderType.Market, 3, 7.638,25, 0, '', CTT_0);
    SubmitOrderUnmanaged(0, OrderAction.Buy , OrderType.StopMarket, 3, 0, 7.710,75, CTT_0-OCO, CTT_0);
    SubmitOrderUnmanaged(0, OrderAction.Buy , OrderType.MIT, 3, 0, 7.602,00, CTT_0-OCO, CTT_0);

    SubmitOrderUnmanaged(0, OrderAction.SellShort , OrderType.Market, 3, 7.630,75, 0, '', CTT_1);
    SubmitOrderUnmanaged(0, OrderAction.Buy , OrderType.StopMarket, 3, 0, 7.647,75, CTT_1-OCO, CTT_1);
    SubmitOrderUnmanaged(0, OrderAction.Buy , OrderType.MIT, 3, 0, 7.622,25, CTT_1-OCO, CTT_1)

    Why system match crossing different OCO orders, what's wrong in my code?

    Thanks!

    PD :

    1/4/2020 11:36:00 Strategy 'CTT/-1': Entered internal SubmitOrderUnmanaged() method at 1/4/2020 11:36:00: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=3 LimitPrice=7638,25 StopPrice=0 SignalName='CTT_0'
    1/4/2020 11:36:00 Strategy 'CTT/-1': Entered internal SubmitOrderUnmanaged() method at 1/4/2020 11:36:00: BarsInProgress=0 Action=Buy OrderType=StopMarket Quantity=3 LimitPrice=0 StopPrice=7710,75 SignalName='CTT_0'
    1/4/2020 11:36:00 Strategy 'CTT/-1': Entered internal SubmitOrderUnmanaged() method at 1/4/2020 11:36:00: BarsInProgress=0 Action=Buy OrderType=MIT Quantity=3 LimitPrice=0 StopPrice=7602,00 SignalName='CTT_0'
    1/4/2020 11:56:00 Strategy 'CTT/-1': Entered internal SubmitOrderUnmanaged() method at 1/4/2020 11:56:00: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=3 LimitPrice=7630,75 StopPrice=0 SignalName='CTT_1'
    1/4/2020 11:56:00 Strategy 'CTT/-1': Entered internal SubmitOrderUnmanaged() method at 1/4/2020 11:56:00: BarsInProgress=0 Action=Buy OrderType=StopMarket Quantity=3 LimitPrice=0 StopPrice=7647,75 SignalName='CTT_1'
    1/4/2020 11:56:00 Strategy 'CTT/-1': Entered internal SubmitOrderUnmanaged() method at 1/4/2020 11:56:00: BarsInProgress=0 Action=Buy OrderType=MIT Quantity=3 LimitPrice=0 StopPrice=7622,25 SignalName='CTT_1'
    1/4/2020 11:56:00 Strategy 'CTT/-1': Cancelled OCO paired order: BarsInProgress=0, orderId='NT-00004-271' account='Backtest' name='CTT_1' orderState=Working instrument='NQ 06-20' orderAction=Buy orderType='Stop Market' limitPrice=0 stopPrice=7647.75 quantity=3 tif=Gtc oco='CTT_1-OCO' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2020-04-01 11:56:00' gtd='2099-12-01' statementDate='2020-06-28'
    1/4/2020 12:40:00 Strategy 'CTT/-1': Cancelled OCO paired order: BarsInProgress=0, orderId='NT-00001-271' account='Backtest' name='CTT_0' orderState=Working instrument='NQ 06-20' orderAction=Buy orderType='Stop Market' limitPrice=0 stopPrice=7710.75 quantity=3 tif=Gtc oco='CTT_0-OCO' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2020-04-01 11:36:00' gtd='2099-12-01' statementDate='2020-06-28'



    Last edited by mbcito; 06-28-2020, 08:57 AM.

    #2
    Hello mbcito,

    Below is a link to an example of an unmanaged strategy that uses OCOID strings.


    What is the string value being used for the OCO?

    It appears you are using a blank string '' for the OCO and you are not using unique OCO strings.
    SubmitOrderUnmanaged(0, OrderAction.SellShort , OrderType.Market, 3, 7.638,25, 0, '', CTT_0);
    SubmitOrderUnmanaged(int selectedBarsInProgress, OrderAction orderAction, OrderType orderType, int quantity, double limitPrice, double stopPrice, string oco, string signalName)
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chelsea,
      My questions :

      First entry ( SellShort ) oco= "" for the stops, ocoOrder = CTT_0-OCO
      Second entry ( SellShort ) oco= "" for the stops, ocoOrder = CTT_1-OCO
      When (SubmitOrderUnmanaged(0, OrderAction.Buy , OrderType.MIT, 3, 0, 7.622,25, CTT_1-OCO, CTT_1)) takes profits, why the order closes the Order CTT_0 ???????????

      Regards Mariano

      Comment


        #4
        Hello Mariano,

        All orders using the same OCOID will tied with OCO. If one cancels, any others with that OCOID will cancel.

        Print the OCOIDs if you want to know why orders are tied with OCO.

        Below is a link to a forum post that demonstrates using prints to understand behavior.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by algospoke, Yesterday, 06:40 PM
        2 responses
        19 views
        0 likes
        Last Post algospoke  
        Started by ghoul, Today, 06:02 PM
        3 responses
        14 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        45 views
        0 likes
        Last Post jeronymite  
        Started by Barry Milan, Yesterday, 10:35 PM
        7 responses
        20 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by AttiM, 02-14-2024, 05:20 PM
        10 responses
        181 views
        0 likes
        Last Post jeronymite  
        Working...
        X