Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order Pending Order Cancelled

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

    Order Pending Order Cancelled

    I have a problem when running a strategy in a simulated account I have created.
    I connect to Kinetick and to my simulated account. And when a position is about to open (because I have limit orders) it says "Order pending" and then when it opens the position, it quickly says "Order Cancelled".

    I attach a control center graph.

    Sincerely
    Attached Files

    #2
    Hello,

    Thanks for the note.

    This most likely is a strategy code error. What method are you using to submit the entry order? Are you aware you must continue to call this for it to continue to remain live? I suspect that you have calculate on bar close = false and as soon as the next tick comes in since your no longer calling EnterLongLimit() for example the order is then instantly cancelled.

    I look forward to assisting you further.

    Comment


      #3
      Yes, I have "calculate on bar close = false"

      And how can I continue to call EnterLong or EnterShort for it to continue to remain live?

      This is the code:
      In Initialize I have:

      Add(PeriodType.Tick, 1);

      And in OnBarUpdate:

      if (BarsInProgress == 0)
      My conditions and then:
      if (Close [0] > entrada) EnterLongLimit(entrada);
      else if (Close [0] < entrada) EnterShortLimit(entrada);

      if (BarsInProgress == 1)
      {
      return;
      }

      Thanks

      Comment


        #4
        Hello,

        Here is the piece you need to look into:

        if (Close [0] > entrada) EnterLongLimit(entrada);

        Is Close[0] ticks above entrada price then order will submit. If it ticks below this price without getting filled the order is cancelled. The order only exists if the price is above entrada.

        Therefor what you will need to do is relax your entry variable up. Add a few ticks or subtract a few ticks here then your entended entry so that you give yourself some breathing room so the entry order does not cancel.

        Or use these conditions to set a flag to true. Then with the flag do your EnterLong. Then create code that will switch the flag to false when you no longer want to go long and the entry is not valid. This is how I would do it in my code.

        Let me know if I can be of further assistance.

        Comment


          #5
          Not sure if I understood well, Can you please give me an example of that?

          Thanks

          Comment


            #6
            Hello,


            Sorry no example available other then what I provided. This would simply be logic that you would need to think through in your strategy to make sure you continue to call enter long limit when you want.

            Right now you have a flaw in your thinking with your code in that you only submit the order if its above the entry price. However what happens when you dont get filled and it goes below the entry price? EnterLongLimit is no longer called is what happens and the order is then cancelled. So you need to code something in so that you continue to call EnterLongLimit based on what you want to do with the strategy. There is no sample as this depends completly on you and what you want to do in your strategy.

            Let me know if I can be of further assistance.

            Comment


              #7
              Thank you Brett, I´ve got he idea now.

              Sincerely

              Comment


                #8
                Hi Brett,

                I tried to do what you suggested and I added in "Region Variables"
                private bool entrar = false

                and then my conditions and this:

                if (Close [0] > entrada) Entrar= true;
                if (Entrar == true)EnterLongLimit(entrada);
                else if (Close [0] < entrada)Entrar = true;
                if (Entrar == true)EnterShortLimit(entrada);
                if (Position.MarketPosition==MarketPosition.Flat) Entrar= false;

                I still have the same problem, any other idea of what can I do?

                Sincerely

                Comment


                  #9
                  dvercher,

                  I do not believe the logic in that code snippet would work. Your Entrar would be true and it would try to EnterLongLimit and EnterShortLimit at the same time.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Ok, I changed to:

                    private bool entrarlargo = false
                    private bool entrarcorto = false

                    and then my conditions and this:

                    if (Close [0] > entrada) Entrarlargo= true;
                    if (Entrarlargo == true)EnterLongLimit(entrada);
                    else if (Close [0] < entrada)Entrarcorto = true;
                    if (Entrarcorto == true)EnterShortLimit(entrada);
                    if (Position.MarketPosition==MarketPosition.Flat) Entrarlargo= false;
                    if (Position.MarketPosition==MarketPosition.Flat) Entrarcorto= false;

                    Now it makes no trades, I guess something is wrong now

                    Sincerely

                    Comment


                      #11
                      Forget my last post, it is working now in backtest. I will see if it works in real time because originally the problems I had were when I was running the strategy in real time.

                      With these changes:
                      private bool entrarlargo = false
                      private bool entrarcorto = false

                      and then my conditions and this:

                      if (Close [0] > entrada) Entrarlargo= true;
                      if (Entrarlargo == true)EnterLongLimit(entrada);
                      else if (Close [0] < entrada)Entrarcorto = true;
                      if (Entrarcorto == true)EnterShortLimit(entrada);
                      if (Position.MarketPosition==MarketPosition.Flat) Entrarlargo= false;
                      if (Position.MarketPosition==MarketPosition.Flat) Entrarcorto= false;

                      I will let you know if it's working or not in real time

                      Sincerely

                      Comment


                        #12
                        Not working in real time yet. I have the same problem, it says order pending order cancelled.
                        This is what I have:

                        With these changes:
                        private bool entrarlargo = false
                        private bool entrarcorto = false

                        and then my conditions and this:

                        if (Close [0] > entrada) Entrarlargo= true;
                        if (Entrarlargo == true)EnterLongLimit(entrada);
                        else if (Close [0] < entrada)Entrarcorto = true;
                        if (Entrarcorto == true)EnterShortLimit(entrada);
                        if (Position.MarketPosition==MarketPosition.Flat) Entrarlargo= false;
                        if (Position.MarketPosition==MarketPosition.Flat) Entrarcorto= false;

                        Any idea?

                        Sincerely

                        Comment


                          #13
                          else if (Close [0] < entrada)Entrarcorto = true;

                          Comment out or delete this line here. Does it still happen?

                          Comment


                            #14
                            This line is for Entershort, it is necessary in my code. Anyway I deleted it and it still happens

                            Sincerely

                            Comment


                              #15
                              Hello,

                              Ok np, you can add it back in now. What we are doing is process of elimination.

                              if (Position.MarketPosition==MarketPosition.Flat) Entrarlargo= false;

                              now, this line must be the culprit.

                              Heres what is occurring. You put in the EnterLongLimit. It does not get filled yet, MarketPosition is still flat, EntrarLargo gets set back to false and EnterLongLimit is no longer called. Which then causes the order to be cancelled.

                              You must call EnterLongLimit every OnBarUpdate to keep it active. Therefor you will need to only set your enter long limit calls back to false when you want to no longer go long. Not when flat.

                              Let me know if I can be of further assistance.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by samish18, Today, 06:16 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post samish18  
                              Started by rezamerik, 08-23-2023, 10:33 AM
                              10 responses
                              1,594 views
                              0 likes
                              Last Post mfzillln  
                              Started by giogio1, 12-02-2024, 03:18 AM
                              6 responses
                              39 views
                              0 likes
                              Last Post giogio1
                              by giogio1
                               
                              Started by Blaze212, Yesterday, 10:05 PM
                              0 responses
                              12 views
                              0 likes
                              Last Post Blaze212  
                              Started by ntbone, 07-18-2019, 12:15 PM
                              14 responses
                              254 views
                              0 likes
                              Last Post BarzTrading  
                              Working...
                              X