Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Delayed Order Submission/Entries for Automated Strategy

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

    Delayed Order Submission/Entries for Automated Strategy

    Hi, I have an automated strategy running for NQ. I found out that sometimes the order is only placed 10 minutes after the code identifies an entry (sometimes it works just fine).

    What I am trying to solve is Why is there a 10 minute delay from code calling enterlongposition, to the actual order submission/fill?



    Below is the log for yesterday.

    4/11/2025 9:27:00 AM: SHORT ENTRY - Entry Price: 18330

    4/11/2025 9:37:00 AM: Order update - Name: Short1, Type: Market, State: Submitted, LimitPrice: 0, StopPrice: 0

    4/11/2025 9:37:00 AM: Order update - Name: Short2, Type: Market, State: Submitted, LimitPrice: 0, StopPrice: 0

    4/11/2025 9:37:00 AM: Order update - Name: Short3, Type: Market, State: Submitted, LimitPrice: 0, StopPrice: 0

    4/11/2025 9:37:00 AM: Order update - Name: Short1, Type: Market, State: Accepted, LimitPrice: 0, StopPrice: 0

    4/11/2025 9:37:00 AM: Order update - Name: Short1, Type: Market, State: Working, LimitPrice: 0, StopPrice: 0

    4/11/2025 9:37:00 AM: Order update - Name: Short1, Type: Market, State: Filled, LimitPrice: 0, StopPrice: 0

    4/11/2025 9:37:00 AM: Trade executed - Short1 at price 18326.5


    As you can see, the code detects a short entry at 09:27AM, but the order is only submitted/executed at 09:37AM. Although the print at 09:37 says it filled at 18,326.5, the actual fill was 18,446 as the price has moved past my entry during the 10 minute delay.



    Below is the part of the code that calls the initial print 4/11/2025 9:27:00 AM: SHORT ENTRY - Entry Price: 18330


    if (!hasPositionInCurrentTrend &&
    Position.MarketPosition == MarketPosition.Flat &&
    hasCrossedThisSession)
    {
    waitCounter++;

    if (waitCounter >= WaitBars)
    {
    if (currentTrend == "LONG")
    {
    // Store entry price BEFORE entering position
    entryPrice = Close[0];
    Print(string.Format("{0}: LONG ENTRY - Entry Price: {1}", Time[0], entryPrice));
    EnterLongPosition();
    }
    else
    {
    // Store entry price BEFORE entering position
    entryPrice = Close[0];
    Print(string.Format("{0}: SHORT ENTRY - Entry Price: {1}", Time[0], entryPrice));
    EnterShortPosition();
    }
    hasPositionInCurrentTrend = true;
    waitCounter = 0;
    }
    }​




    For context:

    Calculate = Calculate.OnBarClose;


    protected override void OnBarUpdate()

    DateTime currentTime = Time[0];

    DateTime currentDate = currentTime.Date;



    // Check if we're within regular trading hours or exactly at the StartTime (06:30)

    bool isRth = IsWithinTradingHours();

    bool isOpeningTime = currentTime.TimeOfDay == StartTime.TimeOfDay;


    Thanks in advance to anyone that could offer some help.


    MK

    #2
    Originally posted by mgkim555 View Post
    Hi, I have an automated strategy running for NQ. I found out that sometimes the order is only placed 10 minutes after the code identifies an entry (sometimes it works just fine).

    What I am trying to solve is Why is there a 10 minute delay from code calling enterlongposition, to the actual order submission/fill?



    Below is the log for yesterday.

    4/11/2025 9:27:00 AM: SHORT ENTRY - Entry Price: 18330

    4/11/2025 9:37:00 AM: Order update - Name: Short1, Type: Market, State: Submitted, LimitPrice: 0, StopPrice: 0

    4/11/2025 9:37:00 AM: Order update - Name: Short2, Type: Market, State: Submitted, LimitPrice: 0, StopPrice: 0

    4/11/2025 9:37:00 AM: Order update - Name: Short3, Type: Market, State: Submitted, LimitPrice: 0, StopPrice: 0

    4/11/2025 9:37:00 AM: Order update - Name: Short1, Type: Market, State: Accepted, LimitPrice: 0, StopPrice: 0

    4/11/2025 9:37:00 AM: Order update - Name: Short1, Type: Market, State: Working, LimitPrice: 0, StopPrice: 0

    4/11/2025 9:37:00 AM: Order update - Name: Short1, Type: Market, State: Filled, LimitPrice: 0, StopPrice: 0

    4/11/2025 9:37:00 AM: Trade executed - Short1 at price 18326.5


    As you can see, the code detects a short entry at 09:27AM, but the order is only submitted/executed at 09:37AM. Although the print at 09:37 says it filled at 18,326.5, the actual fill was 18,446 as the price has moved past my entry during the 10 minute delay.



    Below is the part of the code that calls the initial print 4/11/2025 9:27:00 AM: SHORT ENTRY - Entry Price: 18330


    if (!hasPositionInCurrentTrend &&
    Position.MarketPosition == MarketPosition.Flat &&
    hasCrossedThisSession)
    {
    waitCounter++;

    if (waitCounter >= WaitBars)
    {
    if (currentTrend == "LONG")
    {
    // Store entry price BEFORE entering position
    entryPrice = Close[0];
    Print(string.Format("{0}: LONG ENTRY - Entry Price: {1}", Time[0], entryPrice));
    EnterLongPosition();
    }
    else
    {
    // Store entry price BEFORE entering position
    entryPrice = Close[0];
    Print(string.Format("{0}: SHORT ENTRY - Entry Price: {1}", Time[0], entryPrice));
    EnterShortPosition();
    }
    hasPositionInCurrentTrend = true;
    waitCounter = 0;
    }
    }​




    For context:

    Calculate = Calculate.OnBarClose;


    protected override void OnBarUpdate()

    DateTime currentTime = Time[0];

    DateTime currentDate = currentTime.Date;



    // Check if we're within regular trading hours or exactly at the StartTime (06:30)

    bool isRth = IsWithinTradingHours();

    bool isOpeningTime = currentTime.TimeOfDay == StartTime.TimeOfDay;


    Thanks in advance to anyone that could offer some help.


    MK
    Are you connected to the correct live datafeed and not the simulated data feed?

    Comment


      #3
      Yes I was connected via Tradovate so it should have been the live datafeed.

      Comment


        #4
        Hello mgkim555,

        What is the bar type and interval on the chart?

        With OnBarClose, an order would be submitted after the condition bar closes and would fill with the next bar.
        Note, Time[0] provides the close time of the bar.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi, using regular candle bars on 1 minute timeframe. I'd expect the fill on next minute but sometimes get the 10 minute delay

          Comment


            #6
            Hello mgkim555,

            Do you have subscriptions to real-time data enabled?

            (Data is delayed 10 minutes if there is no subscription)

            Does this also occur in historical?

            Does this also occur when testing on the Playback connection with Market Replay data?

            Does this also occur with the SampleMACrossover?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              I reckon this might have to do with my real time data subscription. I renewed my subscription and seems like its working fine again.

              Thanks all for your advice, will reach out again if the issue persists.

              Thank you!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Today, 05:17 AM
              0 responses
              20 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              119 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              63 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              41 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              45 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X