Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Limit Orders Pile Up In Real Time

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

    Limit Orders Pile Up In Real Time

    Under certain conditions, my strategy will place a limit order on a five minute chart. If the order is not filled, it will cancel the order and place a new one. This works fine in back testing, but in real time, the new order is placed at the new price, but the old order is left working.

    Today, an "exitshortlimit" order was not filled during the first five minutes. A new "exitshortlimit" was placed, but the old one was not cancelled and both were filled leaving me long instead of out. What can I do to fix this?

    Thanks,

    John

    #2
    Can you paste in the code that generates these orders?
    RayNinjaTrader Customer Service

    Comment


      #3
      Code

      Thanks for the quick respose!

      {

      if (ToTime(Time[0]) >= ToTime(10, 00, 0)
      && ToTime(Time[0]) < ToTime(14, 00, 0)
      && MYBUYPRICE[0] > MYBUYCONDITION[0])
      {
      EnterLongLimit(DefaultQuantity, MYBUYPRICE[0], "BUY LOW");
      }
      if (MYEXITLONGPRICE[0] <= MYEXITLONGCONDITION[0])
      {
      ExitLongLimit(DefaultQuantity, MYEXITLONGPRICE[0], "EXIT LONG","BUY LOW");
      }
      if (ToTime(Time[0]) >= ToTime(14, 00, 0))
      {
      ExitLongLimit(DefaultQuantity, MYEXITLONGPRICE[0], "TIMED OUT","BUY LOW");
      }


      if (ToTime(Time[0]) >= ToTime(10, 00, 0)
      && ToTime(Time[0]) < ToTime(14, 00, 0)
      && MYSELLPRICE[0] < MYSELLCONDITION[0])
      {
      EnterShortLimit(DefaultQuantity, MYSELLPRICE[0], "SELL HIGH");
      }
      if (MYEXITSHORTPRICE[0] >= MYEXITSHORTCONDITION[0])
      {
      ExitShortLimit(DefaultQuantity, MYEXITSHORTPRICE[0], "EXIT SHORT","SELL HIGH");
      }
      if (ToTime(Time[0]) >= ToTime(14, 00, 0))
      {
      ExitShortLimit(DefaultQuantity, MYEXITSHORTPRICE[0], "TIMED OUT","SELL HIGH");
      }

      }

      Comment


        #4
        When you run your strategy, can you ensure that "Entries per direction" is set to a value of 1. This may be the problem.
        RayNinjaTrader Customer Service

        Comment


          #5
          Settings attached

          Ray,

          The attached jpg shows my settings. I am just trading a simulated account for now, but will be trading a Zen-Fire account as soon my account is approved and funded.

          I'll try again tomorrow and see how it goes.

          Thanks,

          John
          Attached Files

          Comment


            #6
            I think I need to add a time constraint to both exits...

            Ray,

            I was looking at my orders and the cancel and replace wasn't the problem. The strategy did exactly what I told it to. By a strange coincidence, the exit bar fullfilled the conditions of both exit strategies simultaneously and placed both orders. My bad.

            If I add the same time conditions from the entry to the first exit, the exits can't fire at the same time.

            Sorry to trouble you. I have been writing Easy Language for 20 years and C# for 1 week. There is a huge difference, but even after a week, I can see C# blows away Easy Language!

            Thanks again,

            John
            Attached Files

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by pechtri, 06-22-2023, 02:31 AM
            9 responses
            122 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by frankthearm, 04-18-2024, 09:08 AM
            16 responses
            66 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by habeebft, Today, 01:18 PM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by benmarkal, Today, 12:52 PM
            2 responses
            15 views
            0 likes
            Last Post benmarkal  
            Started by f.saeidi, Today, 01:38 PM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Working...
            X