Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to cancel the order if the buy order can't make in on the next few bar.

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

    How to cancel the order if the buy order can't make in on the next few bar.

    From the picture, Bar 68 fulfill the buy order requirement, then it make a buy order on next bar which is bar 69.

    And then at the bar 69, it also fulfill the buy order, but it make in on bar 121.

    ** From what i noticed, is there is no bar that fulfill the Close[0] for bar 69, so it wait until bar 121 then only make order.

    Can i know my observation is true ??
    And how to solve it ??

    #2
    Hello soon123, thanks for your post.

    You can save the CurrentBar value right after you call the EnterLongLimit() method to save the current bar you submit the order upon, then if(CurrentBar - SavedCurrentBar > 2) you can cancel the order at that point. Note that we also have the OnOrderUpdate event method where you can get an event update when the order gets submitted as well.

    Please let me know if I can assist any further.
    Last edited by NinjaTrader_ChrisL; 09-07-2020, 01:36 PM.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Following. Tried to accomplish this several months ago with no success.

      Comment


        #4
        I understood your idea.
        and i give a try, it works.
        Thanks.

        Comment


          #5
          Originally posted by soon123 View Post
          I understood your idea.
          and i give a try, it works.
          Thanks.
          can you post a code where you were able to do it successfully?

          Comment


            #6
            Originally posted by UltraNIX View Post

            can you post a code where you were able to do it successfully?

            I didnt actually fully implement the idea from chris. But what Chris suggest is to defiend a variable first (Let called it as BarWhichEnterLong).
            ** From Chris's suggestion is to used SavedCurrentBar (VARAIBLE'SNAME)

            So everytime you submit the long order, you have to increase it by 1. Then now you have to set the STOP Condition which maybe you only want to wait for 5 bar which execute long only. then you have to set BarWhichEnterLong > 5.

            Once condition is fulfill, you make cancel the order, so that it wont bring forward to continuous trade.



            HOWEVER


            But what i did was to cancel the order.

            Due to my code is more than thousand of line and many condition, it will be difficult for me to write it down here. So i just share my idea here.

            Basically, entryLong is an order.

            Code:
            if(entryLong!=null && (entryLong.OrderState==OrderState.Filled || entryLong.OrderState==OrderState.Working ) )
            {
            CancelOrder(entryLong);
            entryLong = null;
            }

            I think what you need to do is cancel the order.
            If you have did it, maybe you can start by checking back which part of order you didn't cancel.
            Last edited by soon123; 09-08-2020, 12:22 AM.

            Comment


              #7
              wow, thousand line. Would you mind sharing what's included? Not necessarily line-by-line, but the main concept - why do you need such a lengthy script?

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Negustrader, Today, 01:01 AM
              1 response
              15 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by soon123, Yesterday, 10:50 PM
              1 response
              9 views
              0 likes
              Last Post NinjaTrader_ChrisL  
              Started by liadmz, Yesterday, 03:39 PM
              1 response
              13 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by pyraxic, Yesterday, 06:22 PM
              1 response
              18 views
              0 likes
              Last Post NinjaTrader_PaulH  
              Started by b16_aln, Today, 06:12 AM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_Jim  
              Working...
              X