Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EnterLongLimit()

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

    EnterLongLimit()

    Using
    OnBarUpdate()

    I am placing EnterLongLimit and EnterShortLimit reversing orders.

    Sometimes I get a partial fill.

    #1
    Later the price level changes and the EnterLongLimit() and EnterShortLimit() calls are being placed at different price levels. Could that lead to the orders not being placed and the order that was being placed @ the same price level as the partially filled order being canceled?

    #2
    It seems as though if I get a partial fill and continue to call the EnterLongLimit() or EnterShortLimit() OnBarUpdate() that exactly when a new minute bar gets created the order does get canceled even though I have CalculateOnBarClose set to false. The partial fill happens somewhere in the middle of the older bar let's say 30 seconds into the bar and many barupdate events fire yet the order ONLY gets canceled on the creation of a new bar on the minute exatcly!


    My live strategy keeps going flat that is why I keep asking about the semantics of order canceling and order placement.

    -Lars

    #2
    Lars,

    Someone will follow up later today on this post.
    RayNinjaTrader Customer Service

    Comment


      #3
      More Details on EnterLongLimit() going flat.

      It happens once out of 25 order perhaps.
      And I did track one of the instances just now.

      The order was to EnterLongLimit()
      There were two open orders (generated by the EnterLongLimit()), one to "Close Position" and one to "GoLong" (the name of my entry in the NinjaScript).

      I was short 2 contracts.
      I modified the price of the EnterLongLimit() call and the "Close Position" was modified to a different price than the "GoLong" order.

      The "GoLong" order was filled, the "Close Position" order was canceled.

      The call to modify the two orders @ the eaxchange were sent and accepted within 100ms of each other.

      The "Close Position" order was told to modify to 1258.75 while the "GoLong" order was told to modify to 1259. Both were modified successfully with 100ms of each other.

      The "GoLong" order filled @ the newly modified price of 1259 ... the strategy was flat.

      The "GoLong" order filled at 11:36.14.934983.
      The remaining "Close Position" order was then canceled at 11:37:02.332107 ... very close to the newly created minute.

      The strategy remained flat ... and that was that.

      I have all of these details thanks to the amazing detail the R-Trader interface Mirus futures provides ... it shows the complete history of orders including modifications and executions of past filled and canceled orders.

      Please help me with this ... I hope there is an easy explanation as to why two different prices were used to modify the orders which in essence are the same order. In fact I don't understand why two orders are even used in this case.

      I do use a variable when placing the order and this is what the call looks like:

      Code:
      EnterLongLimit(DefaultQuantity, entryPrice - (TickSize * tickMoves) , "GoLong");
      entryPrice is modified on occasion like such:
      Code:
      entryPrice = Close[0];


      -Lars

      Comment


        #4
        Lars,

        Please use TraceOrders to track your order. With TraceOrders it will give you the exact reason Close position was cancelled for you. You will want to strip your strategy down to bare bones for simplicity when debugging.

        In regards to cancelling at the beginning of a new bar I do suspect this is the case simply because you are not resubmitting the order anymore. Why the Close Position did not fill first is interesting and we would need the TraceOrders log prints to further see the situation.

        If at all possible can you attach a simple as possible strategy that demonstrates the issue you are facing? Thanks.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          TraceOrders ... active strategy one instrument.

          Originally posted by Josh View Post
          Why the Close Position did not fill first is interesting and we would need the TraceOrders log prints to further see the situation.
          Josh,
          I did provide quite detailed information on why one order would get filled over another ... the modify price was different for each!

          The "Close Position" order was told to modify to 1258.75 while the "GoLong" order was told to modify to 1259. Both were modified successfully with 100ms of each other.
          How could that be something that be something that is under my control?
          I call one function that submited two modify requests at different prices.

          I don't mind running TraceOrders in production against my live running account but I don't see how that could provide better details than I already provided. Will it report ... *** sending a modify request for the two seperate orders at different price levels ***?

          I will now list some questsions to better aid me in providing additional information on my problem and bring me towards a resolution.

          #1
          Is there a way to submit a reversing order without having two seperate orders (Closing and reversing order) being generated by NT within NinjaScript?

          #2
          Can the tick stream be so fast that in fact the calls to modify the order(s) are canceled locally if a call to modify is in progress and has not yet been processed?

          #3
          Calls to the broker for modify, cancel etc are they asyncronous, are two change sent to modify both orders at the same time from within the same strategy for the closing and reversing orders?

          #4
          What sort of helpful debugging information can I expect from TraceOrders if implemented?

          #5
          If I have a named entry, A, And I call EnterLongLimit(10,1000,"A")
          It fills 5 contracts at the 1000 price and then I modify the price like such,
          EnterLongLimit(10,999,"A") will this continue to submit an order, this time for 5 contracts since 5 have already filled?

          I did go ahead and make the TraceOrders file as well, it is attached.

          -Lars
          Attached Files
          Last edited by ltemme; 07-23-2008, 08:01 AM. Reason: Adding attachment.

          Comment


            #6
            Getting closer ... I think.

            Code:
             
            7/23/2008 11:35:11 AM Entered internal PlaceOrder() method at 7/23/2008 11:35:11 AM: Action=Buy OrderType=Limit Quantity=2 LimitPrice=113'130 StopPrice=0 SignalName='GoLong' FromEntrySignal=''
            7/23/2008 11:35:11 AM Ignored PlaceOrder() method: Action=Buy OrderType=Limit Quantity=2 LimitPrice=113'130 StopPrice=0 SignalName=GoLong' FromEntrySignal='' Reason='There already is a matching order with same prices and quantity'
            7/23/2008 11:35:12 AM Entered internal PlaceOrder() method at 7/23/2008 11:35:12 AM: Action=Buy OrderType=Limit Quantity=2 LimitPrice=113'130 StopPrice=0 SignalName='GoLong' FromEntrySignal=''
            7/23/2008 11:35:12 AM Ignored PlaceOrder() method at 7/23/2008 11:35:12 AM: Action=Buy OrderType=Limit Quantity=2 LimitPrice=113'130 StopPrice=0 SignalName='GoLong' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
            7/23/2008 11:35:12 AM Entered internal PlaceOrder() method at 7/23/2008 11:35:12 AM: Action=Buy OrderType=Limit Quantity=2 LimitPrice=113'130 StopPrice=0 SignalName='GoLong' FromEntrySignal=''
            7/23/2008 11:35:12 AM Ignored PlaceOrder() method at 7/23/2008 11:35:12 AM: Action=Buy OrderType=Limit Quantity=2 LimitPrice=113'130 StopPrice=0 SignalName='GoLong' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
            7/23/2008 11:35:12 AM Entered internal PlaceOrder() method at 7/23/2008 11:35:12 AM: Action=Buy OrderType=Limit Quantity=2 LimitPrice=113'130 StopPrice=0 SignalName='GoLong' FromEntrySignal=''
            7/23/2008 11:35:12 AM Ignored PlaceOrder() method at 7/23/2008 11:35:12 AM: Action=Buy OrderType=Limit Quantity=2 LimitPrice=113'130 StopPrice=0 SignalName='GoLong' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
            7/23/2008 11:35:13 AM Entered internal PlaceOrder() method at 7/23/2008 11:35:13 AM: Action=Buy OrderType=Limit Quantity=2 LimitPrice=113'130 StopPrice=0 SignalName='GoLong' FromEntrySignal=''
            7/23/2008 11:35:13 AM Ignored PlaceOrder() method at 7/23/2008 11:35:13 AM: Action=Buy OrderType=Limit Quantity=2 LimitPrice=113'130 StopPrice=0 SignalName='GoLong' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
            7/23/2008 11:35:13 AM Entered internal PlaceOrder() method at 7/23/2008 11:35:13 AM: Action=Buy OrderType=Limit Quantity=2 LimitPrice=113'130 StopPrice=0 SignalName='GoLong' FromEntrySignal=''
            7/23/2008 11:35:13 AM Ignored PlaceOrder() method at 7/23/2008 11:35:13 AM: Action=Buy OrderType=Limit Quantity=2 LimitPrice=113'130 StopPrice=0 SignalName='GoLong' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
            7/23/2008 11:35:13 AM Entered internal PlaceOrder() method at 7/23/2008 11:35:13 AM: Action=Buy OrderType=Limit Quantity=2 LimitPrice=113'130 StopPrice=0 SignalName='GoLong' FromEntrySignal=''
            7/23/2008 11:35:13 AM Ignored PlaceOrder() method at 7/23/2008 11:35:13 AM: Action=Buy OrderType=Limit Quantity=2 LimitPrice=113'130 StopPrice=0 SignalName='GoLong' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
            So the highlight is this:
            7/23/2008 11:35:13 AM Ignored PlaceOrder() method at 7/23/2008 11:35:13 AM: Action=Buy OrderType=Limit Quantity=2 LimitPrice=113'130 StopPrice=0 SignalName='GoLong' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'

            So it seems that after a partial fill one is not allowed to resubmit orders beyond the execution of the partial fill and the next tick after the partial fill kills the rest of the open orders.

            Right now I have a strategy that is running two contracts ... reversing. I filled 3 .. then leaving me 1 net in revX direction. and I got the above messages.

            So ... now it is lopsided ... it places orders to reverse the one contract and reverse two which is good, synced to real world fills ... and will self correct itself.

            So the problem with "EntryHandling and EntriesPerDirection properties"

            Should I just do this?
            EntriesPerDirection = DefaultQuantity * 2;
            EntryHandling = EntryHandling.UniqueEntries;

            This will ensure that the strategy can execute partial fills until it is done?

            I was told in the past that partial fills would NOT constitute grounds for order cancelation.

            Let me know,
            -Lars

            Comment


              #7
              #1. No there is no way to submit reversals in that manner.

              #2. Generally not. Once your modify request is sent out it is up in the air after that point to see the response of the exchange.

              #3. They are sent at the same time, but traversal through the internet can cause different behaviors on the two independently of each other.

              #4. TraceOrders provides a detailed step by step printout as to everything your order is doing. From the submission to the fill/reject/or cancel of an order.

              #5. Will need to test.

              From the looks of your last post it would appear that it is not considering your orders as modifying orders. It sees it as a completely new order. Do you have code you could either post or email me with that you are using to achieve this? josh [at] ninjatrader [dot] com.

              I am currently reviewing your other documents you sent over and will let you know what I find.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                EntriesPerDirection ...

                Code:
                 
                EntriesPerDirection = 1;
                EntryHandling = EntryHandling.UniqueEntries;
                It seems that this works when partial fills happen and one continues to submit the order at the same QTY and price level.

                I guess a definitive answer on item 5 would clinch everything for me ... that one is hard to make happen with the sim engine even when I run DefaultOrderQty to 100+

                Since I had many conditions and needed to track many booleans for reversing ... flat vs. long vs. partial ... versus last direction ... there were tristate conditions as well as other complex conditions that most likely led to the non resubmitting of the orders. The inflight order modification is still strange but I think that also has something to do with not resubmiting the orders.

                I will now run production with debugging on .. have coded all day today and used sim heavily ... using the partial fill and other settings to reproduce issues and iron them out.

                -Lars

                Comment


                  #9
                  Lars,

                  It seems you cannot modify entry orders once they become part filled. The workaround is to cancel that order and resubmit one with the proper amount of contracts taking into consideration the amount already filled.

                  Still working on other issues and will let you know.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Lars,

                    What is the code you are using to modify the "Close position" price?

                    #1. If you wanted to manually two step the process you could submit an ExitLong() and then wait for Position.MarketPosition to be flat before submitting your EnterShortLimit(). This approach would introduce some delays in execution speed though.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Fifo.

                      Yeah my trades are close to each other ... being bottom stacked is very important so I do like the current method.

                      The partial fills is a tough issue and will always be a tradeoff depending on how close the trades are to the current market action.

                      Partial fills amount to this:
                      If I have x number of contracts and want to reverse, worse case scenario would be I would fill @ x * 2 price levels prior to reaching the full reversal amount.

                      So it does seem that I will need to use MaxEntries = DefaultQuantity * 2, do you agree with this?

                      It will avoid the ignoring of the subsequent orders.

                      About reversing in one order, I did have some thoughts about using the ADD() command to add additional instruments (really the same instrument as the primary one) issue orders against another instrument ... which is the same instrument and perform buys and sells against these ... work each one against the other ... the internal engine would belive a call to enterlonglimit() on the instrument that is flat would be entered in one order, then perform a entershortlimit() on another instrument that is flat and the order would be sent in one order.

                      What do you think of this approach?

                      My aim is to make reversal orders a single order rather than two orders, which does not make sense to me.

                      -Lars

                      Comment


                        #12
                        It may be usable, but it is not an approach I can vouch for since it is simply sidestepping the underlying issue and may have implications.

                        Lars, I would need you to submit me a simple as possible strategy demonstrating your issues. I need to see the exact implementation you are using to better advise you. If you do not wish to submit it on the forums please email me directly at josh [at] ninjatrader [ dot] com. (Don't send it to support [at] ninjatrader.com) Thanks.

                        In regards to reversal orders, they are always two. Whether you manually exit then enter first or if you let it automatically generate a "Close position" order
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by ltemme View Post
                          Yeah my trades are close to each other ...

                          About reversing in one order, I did have some thoughts about using the ADD() command to add additional instruments (really the same instrument as the primary one) issue orders against another instrument ... which is the same instrument and perform buys and sells against these ... work each one against the other ... the internal engine would belive a call to enterlonglimit() on the instrument that is flat would be entered in one order, then perform a entershortlimit() on another instrument that is flat and the order would be sent in one order.
                          Did anything come of this? Is using ADD a viable solution? This issue is one I'm running up against now. The need to anticipate and nail my entries/reversals.

                          Other than digging into unmanaged order methods, is there a way to make this kind of thing work?

                          Comment


                            #14
                            goldfly,

                            This thread is 2 years old. Please outline what exactly you are trying to do? If you are trying to submit limits to go long and short at the same time you can only do so with Unmanaged orders.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              I want to make a reversal in one action at my price. Not allowing EnterLong() to drop off the existing short position and make an entry where it feels like it. Or having to submit a exit and wait for that to be filled before being able to transmit an entry order

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by judysamnt7, 03-13-2023, 09:11 AM
                              4 responses
                              59 views
                              0 likes
                              Last Post DynamicTest  
                              Started by ScottWalsh, Today, 06:52 PM
                              4 responses
                              36 views
                              0 likes
                              Last Post ScottWalsh  
                              Started by olisav57, Today, 07:39 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post olisav57  
                              Started by trilliantrader, Today, 03:01 PM
                              2 responses
                              21 views
                              0 likes
                              Last Post helpwanted  
                              Started by cre8able, Today, 07:24 PM
                              0 responses
                              10 views
                              0 likes
                              Last Post cre8able  
                              Working...
                              X