Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time Limit on order.

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

    Time Limit on order.

    Is there a way to limit the time an order is active in a automated ATM Strategy like the SampleAtmStrategy you guys created? I was wondering if it is possible to place an order based on a 1 min. bar chart but have it canceled if not filled after 10 seconds and then reset for the next 1 min. bar? I hope that make sense. I have it so that it cancels and places a new order every minute on a 1 min chart but it would be nice to have the option to have the order cancel earlier if not filled within a certain amount of time like say 10 sec. Thanks for your help.

    #2
    cre8it8, this could be custom coded to cancel the order then after the 10 secs have passed after placement, for this just save the order placement time to variable and then cancel the order if the current time is greater than this + your 10 sec offset.

    Comment


      #3
      Thanks for getting back to me.

      So if I have a variable labeled; TimeofOrderEntry= placed at the end of the order entry


      {
      atmStrategyId = GetAtmStrategyUniqueId();
      orderId = GetAtmStrategyUniqueId();
      AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Limit, Low[0], 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId);
      TimeofOrderEntry=
      }

      What would I put after the = to get the current time?

      Then do I insert the TimeofOrderEntry here

      if(TimeofOrderEntry< ?&& (status[2] == "Accepted" || status[2] == "Working" || status[2] == "Pending"))
      {
      AtmStrategyCancelEntryOrder(orderId);
      atmStrategyId = string.Empty;
      orderId = string.Empty;
      }
      and then how would I write the code to be the current time +the 10 sec offset. I know how to do tick offsets but I am not sure on the time offsets. Am I even close on any of this? Also do I need to put something like this private DateTime lastTimePlot = Cbi.Globals.MinDate; in variables to be able to access time?

      I know I ask a lot but your help is much appreciated.

      Comment


        #4
        Hello cre8it8,

        You can use DateTime.Now to capture the current time.
        TimeofOrderEntry = DateTime.Now;


        You can add 10 seconds to this time and make a comparison to current time. You need to use ToTime() to convert the date time format to an integer.


        if (ToTime(DateTime.Now) >= ToTime(TimeofOrderEntry.AddSeconds(10))

        This reference sample can help with manipulating date time objects:
        Manipulating DateTime objects
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Very Cool! Great data. I will give this a shot.
          Thanks!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by cmoran13, Yesterday, 01:02 PM
          0 responses
          27 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          18 views
          0 likes
          Last Post PaulMohn  
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          160 views
          1 like
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          95 views
          1 like
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          148 views
          2 likes
          Last Post CaptainJack  
          Working...
          X