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 cmtjoancolmenero, Yesterday, 03:58 PM
            1 response
            17 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by benmarkal, Yesterday, 12:52 PM
            3 responses
            23 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by helpwanted, Today, 03:06 AM
            1 response
            20 views
            0 likes
            Last Post sarafuenonly123  
            Started by Brevo, Today, 01:45 AM
            0 responses
            11 views
            0 likes
            Last Post Brevo
            by Brevo
             
            Started by pvincent, 06-23-2022, 12:53 PM
            14 responses
            244 views
            0 likes
            Last Post Nyman
            by Nyman
             
            Working...
            X