Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Mutiple entries not working in strategy develpment

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

    #16
    Hello im197,

    So.. Is the order submitted at 11:00 or 13:00?

    Are you asking about the ignored message?

    5/23/2019 1:00:00 PM Strategy 'ATRTrailStrat/-1': Ignored SubmitOrderManaged() method at 5/23/2019 1:00:00 PM: BarsInProgress=0 Action=SellShort OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3325 SignalName='Short 1' FromEntrySignal='' Reason='Invalid order price, please see log tab'
    Chelsea B.NinjaTrader Customer Service

    Comment


      #17
      Hi Chelsea,

      the order @ 13:00 on 5/23/2019 was rejected because the price is no longer applicable.

      The candle that ends at 13:00 closed lower than the stop price that was submitted @ 23:00 the previous night.

      The order was a sell short on stop @ 3325 and was not executed.

      5/22/2019 11:00:00 PM Strategy 'ATRTrailStrat/-1': Entered internal SubmitOrderManaged() method at 5/22/2019 11:00:00 PM: BarsInProgress=0 Action=SellShort OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3325 SignalName='Short 1' FromEntrySignal=''
      Market going up, trail stop @ 3325

      I am asking why it was not executed.



      Comment


        #18
        Hello im197,

        What is the high and low of the 11:01 PM bar (or whatever the next bar is)?

        What happens to the order in the prints to the output window of the order object or on the Orders display in the Strategy Analyzer?

        To save the output from the output window, right-click the output window -> select Save As.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #19
          Hello again,

          The bar on 5/22/2019 @ 23:00 has high 3366 and low 3359 the position is 1+1 long and the order is to sell short 1 lot on stop @ 3325

          The bar om 5/23/2019 @ 11:00 has high 3348 and low 3306. For some reason the position is kept as is. Of course the order to sell on stop @ 3325 after this bar is rejected as the close of the bar is 3312.

          I attach the save of the output window and a photo of the skip
          Attached Files
          Last edited by im197; 10-02-2019, 10:58 AM.

          Comment


            #20
            Hello im197,

            Print the order object in OnOrderUpdate().


            This would let us see what happens to this order.

            Below is a link to a forum post that demonstrates how to use prints to understand behavior.


            What is the bar after 5/22 at 11:00?

            What is the high and low of that bar?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #21
              I cannot print the orders in OnBarUpdate - because when one is rejected I get

              Strategy 'ATRTrailStrat/-1': An Enter() method to submit an entry order at '2/12/2019 5:00:00 PM' has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.
              Market going up, trail stop @ 3037
              Strategy 'ATRTrailStrat': Error on calling 'OnBarUpdate' method on bar 117: Object reference not set to an instance of an object.

              So the analyzer stops.

              If I print only when order != null I get the msg working

              2/11/2019 11:00:00 PM Strategy 'ATRTrailStrat/-1': Entered internal SubmitOrderManaged() method at 2/11/2019 11:00:00 PM: BarsInProgress=0 Action=Buy OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3100 SignalName='Long 1' FromEntrySignal=''
              2/11/2019 11:00:00 PM Strategy 'ATRTrailStrat/-1': Amended open order at 2/11/2019 11:00:00 PM: BarsInProgress=0 Action=Buy OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3100 SignalName='Long 1' FromEntrySignal=''
              Market going down, trail stop @ 3100
              Long Stop Order is: Working

              The problem is why is the stop order not obeyed at all times?

              Please have a look at my code and tell me if you see something that is wrong and that I need to alter.

              Comment


                #22
                Hello again,

                I used OnOrderUpdate and this is what I get

                5/22/2019 9:00:00 PM Strategy 'ATRTrailStrat/-1': Entered internal SubmitOrderManaged() method at 5/22/2019 9:00:00 PM: BarsInProgress=0 Action=SellShort OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3325 SignalName='Short 1' FromEntrySignal=''
                Market going up, trail stop @ 3325
                5/22/2019 11:00:00 PM Strategy 'ATRTrailStrat/-1': Entered internal SubmitOrderManaged() method at 5/22/2019 11:00:00 PM: BarsInProgress=0 Action=SellShort OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3325 SignalName='Short 1' FromEntrySignal=''
                Market going up, trail stop @ 3325
                5/23/2019 1:00:00 PM Strategy 'ATRTrailStrat/-1': Entered internal SubmitOrderManaged() method at 5/23/2019 1:00:00 PM: BarsInProgress=0 Action=SellShort OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3325 SignalName='Short 1' FromEntrySignal=''
                5/23/2019 1:00:00 PM Strategy 'ATRTrailStrat/-1': Ignored SubmitOrderManaged() method at 5/23/2019 1:00:00 PM: BarsInProgress=0 Action=SellShort OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3325 SignalName='Short 1' FromEntrySignal='' Reason='Invalid order price, please see log tab'
                Market going up, trail stop @ 3325
                6/4/2019 9:00:00 PM Strategy 'ATRTrailStrat/-1': Entered internal SubmitOrderManaged() method at 6/4/2019 9:00:00 PM: BarsInProgress=0 Action=SellShort OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3242 SignalName='Short 1' FromEntrySignal=''
                Market going up, trail stop @ 3242

                After 5/23, the next order is 6/4 !!!

                Comment


                  #23
                  Hello im197,

                  There is no order object in OnBarUpdate().

                  Print the order object in OnOrderUpdate().


                  To answer your question, a stop will not be executed if the order is cancelled or if the price does touch the order.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #24
                    I attach my code with the latest additions
                    Attached Files

                    Comment


                      #25
                      I used OnOrderUpdate. Please see my previous post

                      Comment


                        #26
                        Hello im197,

                        Print the order object from OnOrderUpdate() outside of any conditions.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #27
                          Hello,

                          this is the print without any conditions

                          5/22/2019 5:00:00 PM Strategy 'ATRTrailStrat/-1': Entered internal SubmitOrderManaged() method at 5/22/2019 5:00:00 PM: BarsInProgress=0 Action=SellShort OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3325 SignalName='Short 1' FromEntrySignal=''
                          5/22/2019 9:00:00 PM Strategy 'ATRTrailStrat/-1': Entered internal SubmitOrderManaged() method at 5/22/2019 9:00:00 PM: BarsInProgress=0 Action=SellShort OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3325 SignalName='Short 1' FromEntrySignal=''
                          5/22/2019 11:00:00 PM Strategy 'ATRTrailStrat/-1': Entered internal SubmitOrderManaged() method at 5/22/2019 11:00:00 PM: BarsInProgress=0 Action=SellShort OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3325 SignalName='Short 1' FromEntrySignal=''
                          5/23/2019 1:00:00 PM Strategy 'ATRTrailStrat/-1': Entered internal SubmitOrderManaged() method at 5/23/2019 1:00:00 PM: BarsInProgress=0 Action=SellShort OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3325 SignalName='Short 1' FromEntrySignal=''
                          5/23/2019 1:00:00 PM Strategy 'ATRTrailStrat/-1': Ignored SubmitOrderManaged() method at 5/23/2019 1:00:00 PM: BarsInProgress=0 Action=SellShort OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3325 SignalName='Short 1' FromEntrySignal='' Reason='Invalid order price, please see log tab'
                          6/4/2019 9:00:00 PM Strategy 'ATRTrailStrat/-1': Entered internal SubmitOrderManaged() method at 6/4/2019 9:00:00 PM: BarsInProgress=0 Action=SellShort OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3242 SignalName='Short 1' FromEntrySignal='

                          I attach the save from the output
                          Attached Files

                          Comment


                            #28
                            Hello im197,

                            It looks like the position might be long and there is a working order named 'MyTarget' and this order would be taking the position short (into the opposite direction).

                            orderId='NT-00026-6647' account='Backtest' name='MyTarget' orderState=Working instrument='FESX 12-19' orderAction=Sell orderType='Limit' limitPrice=3439 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-05-16 13:00:00' gtd='2099-12-01' statementDate='2019-10-02'

                            If that is the case, this would violate the internal order handling rules for managed strategies.
                            "Methods that generate orders to enter a position will be ignored if
                            A position is open and an order submitted by a non market order exit method (ExitLongLimit() for example) is active and the order is used to open a position in the opposite direction"
                            https://ninjatrader.com/support/help...antedPositions

                            What is the position when this occurs?
                            Is the position long?
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #29
                              Hi Chelsea,

                              You are right that there was indeed a typo in the in the Target order. Once I fixed the typo the strategy would keep the initial position and would not reverse at all - so I removed all target orders.

                              As it stands now the strategy submits 1 order on stop and the 2nd order on confirmation of the 1st order - both on long and on short with no targets.

                              I again see skips when testing the strategy.

                              Here are the order prints


                              9/25/2019 9:00:00 PM Strategy 'ATRTrailStrat/-1': Entered internal SubmitOrderManaged() method at 9/25/2019 9:00:00 PM: BarsInProgress=0 Action=Buy OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3538 SignalName='Long 1' FromEntrySignal=''
                              9/25/2019 9:00:00 PM Strategy 'ATRTrailStrat/-1': Ignored SubmitOrderManaged() method at 9/25/2019 9:00:00 PM: BarsInProgress=0 Action=Buy OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3538 SignalName='Long 1' FromEntrySignal='' Reason='Order already has this stop price/limit price/quantity'
                              9/25/2019 11:00:00 PM Strategy 'ATRTrailStrat/-1': Entered internal SubmitOrderManaged() method at 9/25/2019 11:00:00 PM: BarsInProgress=0 Action=Buy OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3537 SignalName='Long 1' FromEntrySignal=''
                              orderId='NT-00062-10545' account='Backtest' name='Close position' orderState=ChangePending instrument='FESX 12-19' orderAction=BuyToCover orderType='Stop Market' limitPrice=0 stopPrice=3537 quantity=2 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-09-23 17:00:00' gtd='2099-12-01' statementDate='2019-10-03'
                              orderId='NT-00062-10545' account='Backtest' name='Close position' orderState=ChangeSubmitted instrument='FESX 12-19' orderAction=BuyToCover orderType='Stop Market' limitPrice=0 stopPrice=3537 quantity=2 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-09-23 17:00:00' gtd='2099-12-01' statementDate='2019-10-03'
                              orderId='NT-00062-10545' account='Backtest' name='Close position' orderState=Accepted instrument='FESX 12-19' orderAction=BuyToCover orderType='Stop Market' limitPrice=0 stopPrice=3537 quantity=2 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-09-23 17:00:00' gtd='2099-12-01' statementDate='2019-10-03'
                              orderId='NT-00062-10545' account='Backtest' name='Close position' orderState=Working instrument='FESX 12-19' orderAction=BuyToCover orderType='Stop Market' limitPrice=0 stopPrice=3537 quantity=2 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-09-23 17:00:00' gtd='2099-12-01' statementDate='2019-10-03'
                              orderId='NT-00063-10545' account='Backtest' name='Long 1' orderState=ChangePending instrument='FESX 12-19' orderAction=Buy orderType='Stop Market' limitPrice=0 stopPrice=3537 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-09-23 17:00:00' gtd='2099-12-01' statementDate='2019-10-03'
                              orderId='NT-00063-10545' account='Backtest' name='Long 1' orderState=ChangeSubmitted instrument='FESX 12-19' orderAction=Buy orderType='Stop Market' limitPrice=0 stopPrice=3537 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-09-23 17:00:00' gtd='2099-12-01' statementDate='2019-10-03'
                              orderId='NT-00063-10545' account='Backtest' name='Long 1' orderState=Accepted instrument='FESX 12-19' orderAction=Buy orderType='Stop Market' limitPrice=0 stopPrice=3537 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-09-23 17:00:00' gtd='2099-12-01' statementDate='2019-10-03'
                              orderId='NT-00063-10545' account='Backtest' name='Long 1' orderState=Working instrument='FESX 12-19' orderAction=Buy orderType='Stop Market' limitPrice=0 stopPrice=3537 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-09-23 17:00:00' gtd='2099-12-01' statementDate='2019-10-03'
                              9/25/2019 11:00:00 PM Strategy 'ATRTrailStrat/-1': Amended open order at 9/25/2019 11:00:00 PM: BarsInProgress=0 Action=Buy OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3537 SignalName='Long 1' FromEntrySignal=''
                              9/26/2019 1:00:00 PM Strategy 'ATRTrailStrat/-1': Entered internal SubmitOrderManaged() method at 9/26/2019 1:00:00 PM: BarsInProgress=0 Action=Buy OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3537 SignalName='Long 1' FromEntrySignal=''
                              9/26/2019 1:00:00 PM Strategy 'ATRTrailStrat/-1': Ignored SubmitOrderManaged() method at 9/26/2019 1:00:00 PM: BarsInProgress=0 Action=Buy OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3537 SignalName='Long 1' FromEntrySignal='' Reason='Order already has this stop price/limit price/quantity'
                              9/26/2019 5:00:00 PM Strategy 'ATRTrailStrat/-1': Entered internal SubmitOrderManaged() method at 9/26/2019 5:00:00 PM: BarsInProgress=0 Action=Buy OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3537 SignalName='Long 1' FromEntrySignal=''
                              9/26/2019 5:00:00 PM Strategy 'ATRTrailStrat/-1': Ignored SubmitOrderManaged() method at 9/26/2019 5:00:00 PM: BarsInProgress=0 Action=Buy OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3537 SignalName='Long 1' FromEntrySignal='' Reason='Order already has this stop price/limit price/quantity'
                              9/26/2019 9:00:00 PM Strategy 'ATRTrailStrat/-1': Entered internal SubmitOrderManaged() method at 9/26/2019 9:00:00 PM: BarsInProgress=0 Action=Buy OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3537 SignalName='Long 1' FromEntrySignal=''
                              9/26/2019 9:00:00 PM Strategy 'ATRTrailStrat/-1': Ignored SubmitOrderManaged() method at 9/26/2019 9:00:00 PM: BarsInProgress=0 Action=Buy OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3537 SignalName='Long 1' FromEntrySignal='' Reason='Order already has this stop price/limit price/quantity'
                              9/26/2019 11:00:00 PM Strategy 'ATRTrailStrat/-1': Cancelled expired order: BarsInProgress=0, orderId='NT-00062-10545' account='Backtest' name='Close position' orderState=Working instrument='FESX 12-19' orderAction=BuyToCover orderType='Stop Market' limitPrice=0 stopPrice=3537 quantity=2 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-09-23 17:00:00' gtd='2099-12-01' statementDate='2019-10-03'
                              orderId='NT-00062-10545' account='Backtest' name='Close position' orderState=CancelPending instrument='FESX 12-19' orderAction=BuyToCover orderType='Stop Market' limitPrice=0 stopPrice=3537 quantity=2 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-09-23 17:00:00' gtd='2099-12-01' statementDate='2019-10-03'
                              orderId='NT-00062-10545' account='Backtest' name='Close position' orderState=CancelSubmitted instrument='FESX 12-19' orderAction=BuyToCover orderType='Stop Market' limitPrice=0 stopPrice=3537 quantity=2 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-09-23 17:00:00' gtd='2099-12-01' statementDate='2019-10-03'
                              orderId='NT-00062-10545' account='Backtest' name='Close position' orderState=Cancelled instrument='FESX 12-19' orderAction=BuyToCover orderType='Stop Market' limitPrice=0 stopPrice=3537 quantity=2 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-09-23 17:00:00' gtd='2099-12-01' statementDate='2019-10-03'
                              9/26/2019 11:00:00 PM Strategy 'ATRTrailStrat/-1': Cancelled expired order: BarsInProgress=0, orderId='NT-00063-10545' account='Backtest' name='Long 1' orderState=Working instrument='FESX 12-19' orderAction=Buy orderType='Stop Market' limitPrice=0 stopPrice=3537 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-09-23 17:00:00' gtd='2099-12-01' statementDate='2019-10-03'
                              orderId='NT-00063-10545' account='Backtest' name='Long 1' orderState=CancelPending instrument='FESX 12-19' orderAction=Buy orderType='Stop Market' limitPrice=0 stopPrice=3537 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-09-23 17:00:00' gtd='2099-12-01' statementDate='2019-10-03'
                              orderId='NT-00063-10545' account='Backtest' name='Long 1' orderState=CancelSubmitted instrument='FESX 12-19' orderAction=Buy orderType='Stop Market' limitPrice=0 stopPrice=3537 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-09-23 17:00:00' gtd='2099-12-01' statementDate='2019-10-03'
                              orderId='NT-00063-10545' account='Backtest' name='Long 1' orderState=Cancelled instrument='FESX 12-19' orderAction=Buy orderType='Stop Market' limitPrice=0 stopPrice=3537 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-09-23 17:00:00' gtd='2099-12-01' statementDate='2019-10-03'
                              orderId='NT-00064-10545' account='Backtest' name='Exit on session close' orderState=Submitted instrument='FESX 12-19' orderAction=BuyToCover orderType='Market' limitPrice=0 stopPrice=0 quantity=2 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-10-01 23:00:00' gtd='2099-12-01' statementDate='2019-10-03'
                              orderId='NT-00064-10545' account='Backtest' name='Exit on session close' orderState=Accepted instrument='FESX 12-19' orderAction=BuyToCover orderType='Market' limitPrice=0 stopPrice=0 quantity=2 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-10-01 23:00:00' gtd='2099-12-01' statementDate='2019-10-03'
                              orderId='NT-00064-10545' account='Backtest' name='Exit on session close' orderState=Working instrument='FESX 12-19' orderAction=BuyToCover orderType='Market' limitPrice=0 stopPrice=0 quantity=2 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-10-01 23:00:00' gtd='2099-12-01' statementDate='2019-10-03'
                              orderId='NT-00064-10545' account='Backtest' name='Exit on session close' orderState=Filled instrument='FESX 12-19' orderAction=BuyToCover orderType='Market' limitPrice=0 stopPrice=0 quantity=2 tif=Gtc oco='' filled=2 averageFillPrice=3500 onBehalfOf='' id=-1 time='2019-10-01 23:00:00' gtd='2099-12-01' statementDate='2019-10-03'

                              Attached Files

                              Comment


                                #30
                                Hello im197,

                                Are we still looking for 5/22 at 11:00?

                                What was skipped?

                                Is this the complete output?

                                As a heads up, when orders are ignored for violating the internal order handling rules, only the first order to violate the rules will show a trace orders message.

                                In the previous ouput file provided, this was on 2/12 at 17:00.

                                2/12/2019 5:00:00 PM Strategy 'ATRTrailStrat/-1': Ignored SubmitOrderManaged() method at 2/12/2019 5:00:00 PM: BarsInProgress=0 Action=SellShort OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3037 SignalName='Short 1' FromEntrySignal='' Reason='An Enter() method to submit an entry order has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.'

                                Many orders after this also are violating the rules, but these do not show the message as it has already appeared once.

                                Chelsea B.NinjaTrader Customer Service

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Kensonprib, 04-28-2021, 10:11 AM
                                5 responses
                                191 views
                                0 likes
                                Last Post Hasadafa  
                                Started by GussJ, 03-04-2020, 03:11 PM
                                11 responses
                                3,230 views
                                0 likes
                                Last Post xiinteractive  
                                Started by andrewtrades, Today, 04:57 PM
                                1 response
                                14 views
                                0 likes
                                Last Post NinjaTrader_Manfred  
                                Started by chbruno, Today, 04:10 PM
                                0 responses
                                7 views
                                0 likes
                                Last Post chbruno
                                by chbruno
                                 
                                Started by josh18955, 03-25-2023, 11:16 AM
                                6 responses
                                441 views
                                0 likes
                                Last Post Delerium  
                                Working...
                                X