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

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,
    BertrandNinjaTrader Customer Service

    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,
        BertrandNinjaTrader Customer Service

        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);
          }
          BertrandNinjaTrader Customer Service

          Comment


            #6
            D'Oh, schoolboy error

            Thanks again Bertrand!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by geddyisodin, Yesterday, 05:20 AM
            7 responses
            45 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by gbourque, Today, 06:39 AM
            2 responses
            5 views
            0 likes
            Last Post gbourque  
            Started by cre8able, Yesterday, 07:24 PM
            1 response
            13 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by cocoescala, 10-12-2018, 11:02 PM
            6 responses
            939 views
            0 likes
            Last Post Jquiroz1975  
            Started by cmtjoancolmenero, Yesterday, 03:58 PM
            1 response
            17 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X