Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OCO order automatically cancelled

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

    OCO order automatically cancelled

    Hi,

    I created a simple indicator that highlights occurences of double inside bars. It plots this on the chart and also outputs a bool=true when a double inside bar is detected.

    I created a basic strategy to verify the signals reliability. It will create a manual OCO order to capture the breakout after a double inside bar is detected.

    I have two problems that I am struggling with;

    1) One of the OCO orders is automatically thrown out after the first double inside bar is detected. The error message doesnt help me too much and I am not sure where to start looking for a fix. All subsequent OCO orders seem to get created successfully.

    2) The strategy appears to be detecting erroneous occurences of double inside bars. I have added print statements within the indicator and the strategy; the indicator seems to be running OK internally but the strategy looks like it is detecting bool=true on the indicator output. I suspect that the strategy is handling things correctly and that it's the way that my indicator is creating it's bool output that is the problem.

    The OCO order management is still very basic - I am just trying to test the validity of the indicator so please dont laugh

    I appreciate your help and comments.

    Thanks!
    Attached Files

    #2
    Billy, with an approach like this in the managed NT mode you would easily run into the internal order handling rules - http://www.ninjatrader.com/support/h...d_approach.htm (bottom section here). You would need to enable the use of TraceOrders in your strategy (Initialize() TraceOrders = true; ) and then monitor the output window while running the strategy -



    The indicator itself looks fine to - are you running the calling strategy on bar close or updating each tick?

    Thanks,

    Comment


      #3
      Hi Bertrand,

      Thanks for the reply. I will enable TraceOrders and see how I get on.

      In the strategy I have "CalculateOnBarClose = true" and my code is within an OnBarUpdate() section.
      The behaviour is strange and I cant figure it out. The indicator is fairly simple and appears to work as intended. When embedded in my strategy it appears to output erroneous bool outputs.

      Thanks
      Ray

      Comment


        #4
        Ray, I'm seeing the same here on my end - will look into - btw: on which version are of NT are you currently working?

        You can check it under Help > About.

        Thanks,

        Comment


          #5
          Ray, here the cause - you need to reposition the set to false in the indicator - otherwise it's not reset as needed staying in 'true'.

          Code:
          	
          if (CurrentBar == 0)
          {
          dIB.Set(false);
          }
          
          if (CurrentBar > 3)
          {
          if ((High[0] <= High[1]) && (High[1] <= High[2]) && (Low[0] >= Low[1]) && (Low[1] >= Low[2]))
          
          {
          DrawLine("upper" + CurrentBar,false,2,High[2],0,High[0],Color.Red,DashStyle.Solid,3);
          DrawLine("lower" + CurrentBar,false,2,Low[2],0,Low[0],Color.Red,DashStyle.Solid,3);
          dIB.Set(true);
          //Print(Time[0] + " Indicator = true");
          }
          else
          dIB.Set(false);
          }

          Comment


            #6
            D'Oh, schoolboy error

            Thanks again Bertrand!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            630 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            364 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            105 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            566 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            568 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X