Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Question on strategy generated orders

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

    Question on strategy generated orders

    Let's assume I am setting a stop loss, profit target and then placing an entry limit order, all in that order, under the OnBarUpdate section.

    OK, conditions are met and the order has been placed.

    Let's also say the next bar arrives and the order didn't fill (limit price not met).

    The order is automatically cancelled, correct?

    Ok.

    But let's also say there is logic in the strategy that looks to enter a new trade on the bar update that just cancelled that existing order.

    I was just running a new strategy today that failed to create the new order.

    If an existing order is cancelled by a strategy on an OnBarUpdate, does that mean any potential new entry orders, that should occur on that same bar update, do not get processed?

    Hope I've explained it well enough.

    Thanks.
    Last edited by Mike0405; 03-17-2020, 02:28 PM.

    #2
    Hello Mike0405,

    In the managed approach, if an order is working with isLiveUntilCancelled as false (or not used which defaults to false), and the entry method is called again with the same signal name and same order type, then the order is not cancelled. It remains working, and if the order method call has a new price, there is a change order request to change the price of the order to the new price.

    If the order is getting cancelled, then there wasn't a method call with the same signal name and order type to keep it alive.

    Below is a link to an example script made with the strategy builder that keeps exit orders alive on new bars by resubmitting them.



    An order being cancelled does not prevent new orders from being submitted.

    An order being alive, could prevent a new order from being submitted. Please see the internal handling rules below for more about that.


    If you want to know what is happening to your script, use prints and TraceOrders.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      No, there wasn't a method call with the same signal name and order type...that's why it was cancelled, which is fine. I'm ok with that.

      I'm just trying to figure out why a new order wasn't generated (with a different signal name) at the same time the original order was cancelled.

      Comment


        #4
        PS. I just verified that my code is correct by placing some PRINT statements right above where I expected an order to be submitted, and they appeared in the script output window, indicating to me my signal code is working as expected. However, during real time trading, the order was not generated.....hmmmm....

        And nothing was generated in my log file before or after the log of the cancelled order.
        Last edited by Mike0405; 03-17-2020, 03:47 PM.

        Comment


          #5
          And now I just ran it again through market replay playback....and the print statements again appeared as expected in the output window, but the order is never generated. Now I'm completely baffled.

          The code for the SetStopLoss, SetProfitTarget and EnterShortStopLimit directly follows those print statements I temporarily put in there. So if the strategy is getting to those print statements, how is it not generating the order that immediately follows?

          It's all encased in an "if" statement...so if it triggers the print statement, how is it not triggering the order?

          Unless it has something to do with the cancelled order? You already stated a cancelled order does not prevent new orders being submitted (on the SAME bar update I hope).

          Scratching head.
          Last edited by Mike0405; 03-17-2020, 04:10 PM.

          Comment


            #6
            Hello Mike0405,

            If an entry method is called and there is no order, the TraceOrders tells you why (like an order ignored due to violating the internal order handling rules).

            Did you enable TraceOrders?

            Can you provide the TraceOrders information from the output window?

            What date and time is the condition evaluating as true and triggering the entry method call?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              I set TraceOrders= true; in OnStateChange defaults but I am not seeing anything in the output window (except my print statements). The first order is submitted correctly using the Playback101 and it shows up under orders....but I get no additional info in the output window. Then the order is cancelled, the print statements show up in the output window, and then that's it.

              Nothing order related is showing up in the output window with trace enabled...

              Comment


                #8
                OK, I actually noticed something this time in my logs...I didn't pay attention to it before because the timestamp is way off.
                But directly after the 1st order is cancelled, I see an error message.

                An Enter() method to submit an entry order at "3/19/2019 12:52:00 PM" has been ignored. Please search on the term blah blah blah

                I have zero clue why I would be getting that message, considering I was doing a market replay of today (3/17/20) and my trade was occurring at 4:02pm ET (the one that was actually submitted) and 4:03pm ET (the one that is ignored / not generated) on the chart.

                I do have a year's worth of data loaded on this particular chart where i have the strategy in question running.

                So now I'm really baffled.

                Comment


                  #9
                  OK, so I found a way to make it work. Apparently, setting "Entries Per Direction" to 2 instead of 1 allowed that second entry to go through. I'm not sure if this is the correct thing to do, but at least it actually did what I expected it to do...during market playback, it cancelled the first order and entered the new limit order...

                  Something tells me this puts me at slight risk of having both entries filled???

                  If so, how to mitigate against this?

                  let me know...thanks!
                  Last edited by Mike0405; 03-17-2020, 10:25 PM.

                  Comment


                    #10
                    Actually, setting EntryHandling.UniqueEntries also works...without having to set entries per direction to 2....maybe this is the best way?

                    Comment


                      #11
                      Hello Mike0405,

                      Defaults for properties set in State.SetDefaults are only pulled when adding a new instance of a script. The defaults will not override the users changes and will not be pulled after the strategy has been added.
                      Have you removed and re-added the instance of the script so the defaults are pulled?

                      Set TraceOrders = true; in State.Configure to ensure this is for sure enabled without having to remove and add a new instance.

                      What is the full message? The message is telling you the issue.

                      Below is a link to the internal order handling rules for the managed approach.


                      And a link to the help guide on EntriesPerDirection and EntryHandling.



                      To know how to help you, you need to provide information about what the issue is.


                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        This is the full message:

                        3/17/2020 4:03:01 PM Strategy 'aaa/195570114': Ignored SubmitOrderManaged() method at 3/17/2020 4:03:01 PM: BarsInProgress=0 Action=SellShort OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=2496.50 SignalName='4BS' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'


                        So if I set EntryHandling to UNIQUE ENTRIES, is that an acceptable solution to my problem? Because that seems to work, but I don't want to set myself up for any surprises.

                        Comment


                          #13
                          Hello Mike0405,

                          With Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties', this means there was a working order.

                          My guess is that there is another order that was submitted before this that is still in a working state when this order is submitted. The cancellation is probably just being requested and the order has not yet fully entered a cancelled state.

                          The script would need to wait until the other order is fully cancelled before another is placed.

                          Allowing unique entries would allow for unique signal names for each order to be placed at the same time. And yes, if you are wanting both entry orders working at the same time this can be a solution. (Or setting EntryHandling to 2)

                          Print the order object from OnOrderUpdate() to confirm this by looking at the sequence of events for submissions and order updates.
                          https://ninjatrader.com/support/foru...121#post791121
                          Chelsea B.NinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by NullPointStrategies, Today, 05:17 AM
                          0 responses
                          23 views
                          0 likes
                          Last Post NullPointStrategies  
                          Started by argusthome, 03-08-2026, 10:06 AM
                          0 responses
                          120 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