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

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.
    JesseNinjaTrader Customer Service

    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.
          JesseNinjaTrader 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
          21 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