Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

modifying or canceling limit orders with time variable

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

    modifying or canceling limit orders with time variable

    Hello,

    I'd like my strategy to place limit orders and then let them sit there for a given amount of time (if not filled instantly) and then cancel them and immediatley place a market order.

    something like this:

    if(xxx)
    { EnterLongLimit(Enterlongsize,GetCurrentBid(), "1st entry"); "let this order sit here for x amount of time( i'd like it to be seconds or a percentage of the current bar) and then cancel if not filled and then do the following"
    }
    else
    {else(EnterLong();

    thanks.

    #2
    Hello wahooj,

    Welcome to our forums.

    By default, unfilled orders will cancel at the end of the bar. To change this, you will have to work with liveUntilCanceled property that is available with the advanced order submission overloads. You can read more information at the link below.


    Using this approach, you will have to work with IOrder objects. You can send CancelOrder() commands to a specific IOrder object when conditions for canceling are met.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Ryan,

      i saw on another post that this type of order strategy is possible by changing the ATI setting from the options tab. However, it's under the Tradestation settings. Does that setting require me to be trading via Tradestation? My broker is IB.
      Thanks

      Comment


        #4
        wahooj, which post are you referring to please? You're trading via a NinjaScript strategy here, so the ATI / TradeStation external order execution settings would not apply.

        Comment


          #5

          -this is post i'm referring to.


          Is there a similar setting for NinjaScript Strategies?

          Comment


            #6
            Hi wahooj,

            Unfortunately there is not an equivalent setting for NinjaScript. The section you're viewing is for the Automated Trading Interface (ATI). In NinjaScript you will have to code your conditions for canceling.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              yeah i figured it was a long shot....

              Well. I have this so far but I seem to be not canceling my original limit order after waiting 1 second for it to get filled, before placing my market order. This is what i've come up with. I assume there is something wrong with the way I'm scripting the timer syntax. any comments would be appreciated.

              if (Close[0] > XXXXXX )

              {

              myOrderShort = EnterShortLimit(ENT1,GetCurrentAsk(),"SHORT LIMIT 1");
              Timer.AddSeconds(DateTime.Now.Second);

              if(Timer.Second > DateTime.Now.Second - 1)
              {
              CancelOrder(myOrderShort);
              EnterShort(ENT1,"MARKET 1");


              }

              Comment


                #8
                Hello Wahooj,

                You should understand that working with timers won't work in Backtesting. The Times used is not the same as your current time.

                The following article may help working with DateTime objects, but keep in mind a lot of what you're doing is related to C# related and we will be unable to assist.
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  Ryan,
                  In regards to Timers not working during back testing, is that only true for running strategy analyzers or does that apply to running market replay as well? I've got a couple solutions but no luck getting them to operate correctly during market replay. They will cancel and amend the original limit order but not adhere to the time functions, they amend/cancel immediately. Here's what I've tried.

                  #1
                  if (Close[0] > XXXXXX )
                  {
                  MyOrderShort = EnterShortLimit(0, true, ENT1,GetCurrentAsk(),"SHORT LIMIT 1");

                  if(Bars.PercentComplete <= .9)
                  {
                  EnterShortLimit( ENT1,GetCurrentBid(),"SHORT LIMIT 1");
                  CancelOrder(myOrderShort);

                  }

                  #2
                  if (Close[0] > XXXXXX )
                  {
                  MyOrderShort = EnterShortLimit(0, true, ENT1,GetCurrentAsk(),"SHORT LIMIT 1");

                  if(Bars.Period.Id == PeriodType.Sedond && BarsPeriod.Value <= 57)
                  {
                  EnterShortLimit( ENT1,GetCurrentBid(),"SHORT LIMIT 1");
                  CancelOrder(myOrderShort);

                  }

                  Thanks
                  Last edited by wahooj; 04-06-2010, 08:22 AM. Reason: modifying post

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  656 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  371 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  109 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  574 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  579 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X