Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

onexecution - COBC

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

    onexecution - COBC

    Hello,

    I´m recognizing differences in behavior in OnExecution (if there is no error on my end) depending if I have COBC=false or COBC=true.

    * I want to ask please if there might be a difference depending of COBC in onExecution. (Like eg if(exec.Order!=PartFilled) entryOrder1 = null; is with closeofbar or immediately when filled?)

    * And I want to ask please another question by using a variable to explain what I mean: If eg the Variable is set to 1 with "onexecution" (eg an entryorder) is this value 1 "fixed" as long the enterlong is filled or can its value be changed referring to other conditions (even when long still filled)

    (My issue is that with exitorder the corresponding stop is cancelled (which is correct in my coding) with COBC=false but persists with COBC=true and I can´t find out as the coding of the strategies to test is the same except COBC. As the referring "action" to cancel the stoporder once the exitorder is filled is in onexectuion I´m thinking about behavior there)

    Thanks
    Tony
    Last edited by tonynt; 04-05-2013, 01:46 AM. Reason: typing error - clearify

    #2
    HI Tonynt,

    Thanks for posting.

    Can you provide me some examples of the differences you are seeing with the COBC set to true and false?

    Are you calling any variables in the OnBarUpdate that are updating in the OnExection?

    OnExecution will not be affected by COBC, since it will only be called when an incoming order executions is processed directly from the Broker and SIM engine.

    I look forward to your response.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      I have rebuilt the strategies and changed everything step by step. The problem is not if COBC= true or false.

      I found out that the reason is in the initialize section. With "if (BarsInProgress!=2) return;" it works that once exitOrderXY is filled, then the corresponding stopOrderXY is cancelled. (dataseries 2 I have the entry-conditions)

      But when starting the strategy with if(Historical) return; it doesn´t work, this means that once the exitOrderXY is filled the stopOrderxY is not cancelled and persists. Why?

      For your information the reason why I start the strategy with if(Historical)return; is simple to set a flag to false when starting the strategy and only with certain conditions eg HMA is falling I set the flag on true for longs (as the strategy will go long only when HMA is rising again - the sense is that I want to avoid a "late" entry).

      Nothing exciting in my strategies but I have the problem now that I have to "decide" if my exitOrderXY filled and stopOrderXY cancelled are working correctly (with BarsInProgess2) or that my flag is correct from the moment of starting the strategy (with Historical)

      How can I do please so that both are working, a.) the flag is false when starting (and not set to true because of course there were conditions to set true some moment in the past) and b.) the exits are working correctly with

      if (exitOrderXY != null && exitOrderXY == execution.Order&& execution.Order.OrderState == OrderState.Filled|| execution.Order.OrderState == OrderState.PartFilled)
      {
      CancelOrder(stopOrderXY);
      }

      This seems to be the last - but surprising - problem after 3 years of working with NinjaTrader scripts.

      Thanks for all your support and thanks in advance for clearifying how I can solve this problem finally!


      Thanks
      Tony



      Originally posted by NinjaTrader_Cal View Post
      HI Tonynt,

      Thanks for posting.

      Can you provide me some examples of the differences you are seeing with the COBC set to true and false?

      Are you calling any variables in the OnBarUpdate that are updating in the OnExection?

      OnExecution will not be affected by COBC, since it will only be called when an incoming order executions is processed directly from the Broker and SIM engine.

      I look forward to your response.
      Last edited by tonynt; 04-07-2013, 06:39 AM. Reason: error in translation, sorry

      Comment


        #4
        Hi Tonynt,

        I would suggest create a bool that is set to false once initialized.
        Then have an if statement (historical && //other conditions) set the bool to true.

        Your cancels in the execution should be ok.

        Let me know if you need further assistance.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Hello Cal,

          thank you for your support. This is exactly what I think and I try to do but it doesn´t work as I wrote and tried to explain.

          * With if (Historical) the cancel stopOrder doesn´t work once the exitOrder is done. I don´t know why it doesn´t cancel the stopOrder! The stopOrder is only cancelled with if(BarsInProgress!=0) return; or eg with if (BarsInProgress!=2)return;

          * But when using if(BarsInProgress!=0)return; the initialize bool doesn´t work. I do debug with background coloring and outputwindow and I see that the bool=true since HMA falling in the past.

          This is how I do:

          protected override void Initialize()
          {
          TraceOrders = true;
          tradesactive=false;
          }

          protected override void OnBarUpdate()
          {
          if (BarsInProgress!=3)
          return;

          if( Falling(HMA(BarsArray[5],89)))
          tradesactive=true; Print("tradesactive: " + tradesactive); Print(Time[09);

          Could I explain what I mean, or do I not understand what you suggest maybe(?)


          Thank you for your support!
          Tony

          Originally posted by NinjaTrader_Cal View Post
          Hi Tonynt,

          I would suggest create a bool that is set to false once initialized.
          Then have an if statement (historical && //other conditions) set the bool to true.

          Your cancels in the execution should be ok.

          Let me know if you need further assistance.
          Last edited by tonynt; 04-08-2013, 12:30 PM. Reason: clearify

          Comment


            #6
            Hello Cal,

            you wrote if (Historical &&...)

            and can I assume that you mean - referring the given example - if(!Historical &&...)

            So, is everything correct for NT when I put bool tradesactive=false; into initialize section and then into OnBarUpdate

            if(!Historical&& BarsInProgress==3&&Falling(MACD(BarsArray[8],12,26,9).Avg))
            tradesactive=true;

            Thanks
            Tony

            Comment


              #7
              Tonynt,

              Yes, using the
              Code:
              if(!Historical&& BarsInProgress==3&&Falling(MACD(BarsArray[8],12,26,9).Avg))
              looks correct with using real-time data for your strategy.
              Cal H.NinjaTrader Customer Service

              Comment


                #8
                Thanks, yes it works already!

                Originally posted by NinjaTrader_Cal View Post
                Tonynt,

                Yes, using the
                Code:
                if(!Historical&& BarsInProgress==3&&Falling(MACD(BarsArray[8],12,26,9).Avg))
                looks correct with using real-time data for your strategy.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by XXtrader, Yesterday, 11:30 PM
                2 responses
                11 views
                0 likes
                Last Post XXtrader  
                Started by Waxavi, Today, 02:10 AM
                0 responses
                6 views
                0 likes
                Last Post Waxavi
                by Waxavi
                 
                Started by TradeForge, Today, 02:09 AM
                0 responses
                11 views
                0 likes
                Last Post TradeForge  
                Started by Waxavi, Today, 02:00 AM
                0 responses
                2 views
                0 likes
                Last Post Waxavi
                by Waxavi
                 
                Started by elirion, Today, 01:36 AM
                0 responses
                7 views
                0 likes
                Last Post elirion
                by elirion
                 
                Working...
                X