Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error with OCO ID in automated strategy.

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

    Error with OCO ID in automated strategy.

    I am getting the error "Order XXXXXX can't be submitted: The OCO ID "XXXXXX" cannot be reused. Please use a new OCO ID. affected Order: Sell 10000 Lmit @ 1.15431

    Then the strategy shuts down.I have same strategy running in 15 markets and this error happens randomly every other day or so.

    How do I manage OCO IDs on Ninjascript so I can make sure the system is not reusing one???

    #2
    Hello,

    Thanks for posting.

    It sounds like OCO was possibly left on after submitting the original OCO orders group. Could you confirm if this may be the case?

    To use OCO, it must be enabled, the orders placed, and then OCO must be disabled. These steps would need to be repeated each time OCO orders are used to prevent this error message.
    Drew O.NinjaTrader Customer Service

    Comment


      #3
      How do I check if OCO is ON using Ninjascript? How do I turn it off?

      I am using Ninja Trader 8. The only way to turn off OCO is thru the account connections configuration. There is no reference to turing off/on OCO on the NinjaScrip reference guides.

      Thanks.

      Comment


        #4
        Help!!!!!!!!!!!!!!!!!!!!

        Can anyone please help? I am using NT8, no chart trader, I only use a very simple automated strategy.

        Is there anything I need to clarify?

        i see other threadabout OCO issues but those involve chart trader. I don;t use chart trader.

        Thanks.

        Comment


          #5
          Hello cesario1234,

          Thank you for the post.

          You will manage the OCO ID of your orders in NinjaScript with an unmanaged approach. NijaScript Strategies will ignore the user interface OCO, orders made by the strategy while OCO is on will not be assigned an OCO ID from NinjaTrader. You will use SubmitOrderUnmanaged() function to submit OCO orders.

          More information on SubmitOrderUnmanaged() here


          You can access the OCO property of any Order object.

          More on the Order object here:


          More information on an Unmanaged approach:


          The managed approach already handles OCO orders for you with functions like SetProfitTarget() and SetStopLoss()

          Please let us know if we may be of any further assistance.
          Last edited by NinjaTrader_ChrisL; 09-21-2017, 10:34 AM.
          Chris L.NinjaTrader Customer Service

          Comment


            #6
            Thank you for your reply.

            So the only way to prevent this error is using the Unmanaged approach? Does this mean the managed approach does not work on NT8? or is this a bug that will be fixed in the future?

            It seems odd that what is likely the most popular approach (managed) won't work on NT8.

            Thanks.

            Comment


              #7
              Hello cesario1234,

              Thank you for the reply.

              Please send me your log and trace files to platformsupport[at]ninjatrader[dot]com.

              You can do this by going to the Control Center-> Help-> Mail to Platform Support.

              Please reference the following in the email body: ATTN CHRISL <paste the link to this forum post here>

              I look forward to your reply.
              Chris L.NinjaTrader Customer Service

              Comment


                #8
                I just sent you the files.

                Thank you for looking into this.

                Comment


                  #9
                  Hello cesario1234,

                  Thank you for sending in the logs.

                  The reason the OCO was not accepted was due to your stop loss being above the market.
                  This stop loss was cancelled with an OCO ID tied to it, then the strategy tried to submit a profit target with the same OCO ID, which would cause this error. If you are the author of this script, please provide some additional information on how the logic works and I will advise further on implementing the use of an unmanaged approach.

                  I look forward to hearing of your results.
                  Chris L.NinjaTrader Customer Service

                  Comment


                    #10
                    Hello, thank you for your response.

                    The stop loss order HAS to be above the market in the example I gave as it is a short position, or am I missing something?

                    The strategy is very simple. I am just entering market orders with a stop and a target. I don't understand why it has to be changed to the unmanaged approach. Is this a bug with NT8 or is the managed approach not available anymore on NT8?

                    The strategy uses SetStopLoss(CalculationMode.Ticks, StopLoss); and SetProfitTarget(CalculationMode.Ticks, Target); to set the stop and targets in TICKS. One would expect NT8 to know where to put the stop if going long or short.

                    Here is the code: (SRHHMAOSC is an indicator similar to the stochastics)

                    public class A0 : Strategy
                    {
                    int cnt = 10000;
                    int std_cnt = 10000;

                    protected override void OnStateChange()
                    {
                    if (State == State.SetDefaults)
                    {
                    Description = @"SRHHMAOSC on Range Barrs";
                    Name = "A0";
                    Calculate = Calculate.OnBarClose;
                    EntriesPerDirection = 1;
                    EntryHandling = EntryHandling.AllEntries;
                    IsExitOnSessionCloseStrategy = false;
                    ExitOnSessionCloseSeconds = 30;
                    IsFillLimitOnTouch = false;
                    MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
                    OrderFillResolution = OrderFillResolution.Standard;
                    Slippage = 0;
                    StartBehavior = StartBehavior.WaitUntilFlat;
                    TimeInForce = TimeInForce.Gtc;
                    TraceOrders = false;
                    RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
                    StopTargetHandling = StopTargetHandling.PerEntryExecution;
                    BarsRequiredToTrade = 20;
                    // Disable this property for performance gains in Strategy Analyzer optimizations
                    // See the Help Guide for additional information
                    IsInstantiatedOnEachOptimizationIteration = true;
                    Target = 50;
                    StopLoss = 50;
                    Dob1 = 1.5;
                    Dob2 = 0.5;


                    }
                    else if (State == State.Configure)
                    {

                    AddChartIndicator(SRHHMAOSC(Dob2 + "/" + Dob2 + "/Renko"));
                    SetStopLoss(CalculationMode.Ticks, StopLoss);
                    SetProfitTarget(CalculationMode.Ticks, Target);

                    }
                    }

                    protected override void OnBarUpdate()
                    {

                    if(Position.MarketPosition == MarketPosition.Flat)
                    {

                    if(

                    SRHHMAOSC("1/1/Renko").Plot0[0] > Bollinger(SRHHMAOSC("1/1/Renko").Plot0, Dob1, 50).Upper[0]
                    && SRHHMAOSC("1/1/Renko").Plot0[0] < Dob2

                    )
                    {
                    EnterShort(cnt);

                    }

                    if(
                    SRHHMAOSC("1/1/Renko").Plot0[0] < Bollinger(SRHHMAOSC("1/1/Renko").Plot0, Dob1, 50).Lower[0]
                    && SRHHMAOSC("1/1/Renko").Plot0[0] > -Dob2

                    )
                    {
                    EnterLong(cnt);

                    }
                    }
                    }

                    Comment


                      #11
                      Hello cesario1234,

                      Thank you for the snippet.

                      Could you please confirm what version of NinjaTrader you are using as well as your data feed?

                      I look forward to assisting further.
                      Chris L.NinjaTrader Customer Service

                      Comment


                        #12
                        I ma using NT8 8.0.8.0 and the FXCM datafeed.

                        Thanks.

                        Comment


                          #13
                          Hello cesario1234,

                          Thank you for your patience on this.

                          The two things that might have happened here are a fault in the SIM101 account, or the market moved the spread far enough to where it invalidated your stop loss.

                          Please take the steps below to update your NinjaTrader installation and repair your database:

                          To upgrade NinjaTrader:
                          1. First, get your license key from NinjaTrader under Help> License Key then exit NinjaTrader
                          2. Click on the link: http://ninjatrader.com/PlatformDirect
                          3. Enter your license key and press Submit
                          4. Select 'NinjaTrader 8'.
                          5. Select 'Download'
                          6. Critical: Before running the installer, ensure NinjaTrader is closed.


                          To repair your database:
                          1. Disconnect NinjaTrader from any open connections via Connections > Disconnect
                          2. From the NinjaTrader Control Center window select the menu Tools > Database
                          3. Press "Repair DB" drop-down menu
                          4. Press the "Repair" button


                          Please let us know if we may be of any further assistance.
                          Chris L.NinjaTrader Customer Service

                          Comment


                            #14
                            I'm experiencing the same error while using ATM Strategy to submit my Order

                            Order '' can't be submit. The OCO ID cannot be reused please use a new OCO ID affected Order Sell Limit, I tried the mentioned solution of repairing the database that didnt work.
                            I'm running NT 8.0.10.0 64-bit and FXCM datafeed.

                            Last edited by psytopy; 11-15-2017, 08:11 PM. Reason: Including NT version

                            Comment


                              #15
                              Hello cesario1234,

                              Thank you for the follow-up.

                              I will need to see your new log and trace files to compare the execution with the bid/ask price at the time the execution occurred.

                              Please follow the same procedure to send me your log and trace files to platformsupport[at]ninjatrader[dot]com.

                              You can do this by going to the Control Center-> Help-> Mail to Platform Support.

                              Please reference the following in the email body: ATTN CHRISL <paste the link to this forum post here>

                              I look forward to assisting further.
                              Chris L.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by adeelshahzad, Today, 03:54 AM
                              5 responses
                              32 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by stafe, 04-15-2024, 08:34 PM
                              7 responses
                              32 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by merzo, 06-25-2023, 02:19 AM
                              10 responses
                              823 views
                              1 like
                              Last Post NinjaTrader_ChristopherJ  
                              Started by frankthearm, Today, 09:08 AM
                              5 responses
                              21 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by jeronymite, 04-12-2024, 04:26 PM
                              3 responses
                              43 views
                              0 likes
                              Last Post jeronymite  
                              Working...
                              X