Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Non unique OCO problem

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

    Non unique OCO problem

    Hi,
    I am using Unmanaged mode to submit a pair of breakout orders. These are intended to be OCO.

    Because the GetAtmStrategyUniqueId() doesn't work historically, I am using System.Guid.NewGuid() to generate OCO ids. Example of an OCO from this is 07b3efe27009250433008906709f03d05009f01602a

    This works fine on historical charts. But live in Market Replay even the first orders sent in realtime generate a rejection, because of a non-unique OCO. But it IS unique - at least it has not been used before.
    Is there a problem with placing a bracket of entry orders with an OCO?

    Here is the entry code:


    string oco = GetGuid();

    LE1 = SubmitOrderUnmanaged(tbip,OrderAction.Buy, (rnd(GetCurrentAsk()) >= longEntryPrice ? OrderType.Market : OrderType.StopLimit),
    positionSize,rnd(longEntryPrice+stopLimitOrderWidt h*TickSize),longEntryPrice,oco,"LE1");
    SE1 = SubmitOrderUnmanaged(tbip,OrderAction.SellShort, (rnd(GetCurrentBid()) <= shortEntryPrice ? OrderType.Market : OrderType.StopLimit),
    positionSize,rnd(shortEntryPrice-stopLimitOrderWidth*TickSize),shortEntryPrice,oco, "SE1");

    By the way, when this happens it seems to blow up something inside Ninja. I have to quit it and restart, sometimes restarting the computer because it says the DLL is being used by another process.

    Thanks,
    saltminer
    Last edited by saltminer; 03-27-2018, 07:40 PM.

    #2
    Hello,

    Thank you for the question.

    Have you at this point tried to use the State object to switch from using GUID to GetAtmStrategyUniqueId() in realtime? That is likely what I would suggest as that is the most simple solution.

    Code:
    string oco = GetGuid();
    if(State == State.Realtime) oco =  GetAtmStrategyUniqueId();
    Could you try this and see if this solves the problem?

    I look forward to being of further assistance.

    Comment


      #3
      Hi,
      yes, trouble exists even when switching to GetAtmStrategyUniqueId() at realtime.

      saltminer

      Comment


        #4
        Still having trouble with this.

        Here is my GetGuid() method. It used to be simpler but in this version I am getting a long hexadecimal string for the System.Guid.


        Code:
        		private string GetGuid()
        		{
        			string g = "";
        			if (State != State.Realtime)
        				g= System.Guid.NewGuid().ToString("X").Replace("-","").Replace("{","").Replace("}","").Replace(",","").Replace("x",""); //.Substring(0,28); //+(DateTime.Now.Second.ToString("00"))+(DateTime.Now.Millsecond).ToString("000");
        			else
        				g= GetAtmStrategyUniqueId();
        			Print("UniqueId = '"+g+"'");
        			return g;
        		}
        saltminer

        Comment


          #5
          Hello,

          Thank you for the reply.

          Would you be able to provide the test script you are using to see this? I would like to test what you are using the syntax you currently are.

          I look forward to being of further assistance.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          43 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          124 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          65 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          42 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X