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

Strategy Order Handling

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

    Strategy Order Handling

    Hey,

    Im looking for some assistance in trying to understand and fix this problem that tends to keep occurring in my strategy :

    The issue is that I had an active strategy going short that had 3 contracts, this current position was supposed to exit fully after reaching the set profit target by submitting 3 buy limit orders. Upon doing so I noticed that an extra entry was logged ( 4 buy to cover orders) so instead of my position being flat as it should have, my current market position has changed to long 1 contact.

    When reading the log I see that at 1:01 pm there was an order submitted under my signal name "TakeProfits" which consisted of 3 buy to cover limit orders at a specified price. The logs shows the history of that order being submitted, accepted, then worked. Upon working it submitted a change to the limit price, which eventually led to this updated order being accepted and worked. The log then shows that order of 3 being partially filled which leads to the execution message saying 2 contracts were executed ( this is execution49400583169_1) . Next message shows an update to my current position now being 1 contract short still. Then after the update of the position, the log then shows the original; order 49400583169 , getting that final fill of 1 buy to cover limit long which shows as a "execution49400583169_2". Next update shows the position as flat which I have highlighted in the screen shot.

    I'm trying to under stand why and how to fix what happens after this, and I think its due to the fact of the order being partially filled at first but im not sure. It submits another buy to cover long entry order under my "TakeProfits" signal name which leaves an open unmanaged position that was not supposed to be executed. Looking at the prints, I can see that the strategy followed all the rules the correct prices, and at the right time, but it keeps opening too many orders. At first I had my "ProfitTake" exit submitting market orders and it was giving me the same issue of too many entries. After some further research of order handling I came across ninja traders "managed approach" which is "Internal Order Handling Rules That Reduce Unwanted Positions". I saw that this managed approach doesn't apply to market orders, so I then changed the exit orders to limit orders, but I still get the same issue of unwanted positions. Please help, thanks

    Click image for larger version

Name:	image.png
Views:	102
Size:	218.6 KB
ID:	1297644

    #2
    I have the same exact ongoing problem. Sometimes the exit order only partially fills, but then I later end up being in opposite position for whatever amount didn't fill. I assume I need to do some sort of logic in "OnExecutionUpdate" to account for the partial filled exit orders and then submit new exit order to close out balance. I am confused why this doesn't happen automatically though. I am using Advanced Managed orders and I cancel any stop or take profit orders before submitting "Exit" orders. I have created an "order" variable called "MyExitOrder" and assigned it to the Exit Order when called, so I should be able to access state to determine if partial filled, etc. I'm just not sure how to process from there. The only examples I can find are for filling buy orders and stop loss/take profit orders if partially filled. This doesn't ever happen in backtesting either, so it's hard to test.
    Thank you,
    Jeremy

    Comment


      #3
      Hello Mikey_

      Thanks for your post.

      What version of NinjaTrader are you using? Please provide the entire version number. This can be found under Help -> About (Example: 8.?.?.?)

      Are you using Exit methods and Set methods for stops/targets in your script?

      How exactly are you submitting the stop/target orders in your NinjaScript strategy?

      Have you added debugging prints to the NinjaScript strategy to understand exactly how the strategy's logic is behaving and placing orders?

      Do you have TraceOrders enabled when running the strategy to help debug how to strategy's orders are behaving?

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


      We look forward to assisting further.
      Brandon H.NinjaTrader Customer Service

      Comment


        #4
        Originally posted by NinjaTrader_BrandonH View Post
        Hello Mikey_

        Thanks for your post.

        What version of NinjaTrader are you using? Please provide the entire version number. This can be found under Help -> About (Example: 8.?.?.?)

        Are you using Exit methods and Set methods for stops/targets in your script?

        How exactly are you submitting the stop/target orders in your NinjaScript strategy?

        Have you added debugging prints to the NinjaScript strategy to understand exactly how the strategy's logic is behaving and placing orders?

        Do you have TraceOrders enabled when running the strategy to help debug how to strategy's orders are behaving?

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


        We look forward to assisting further.
        Thanks for your reply,

        As far as the version that I am using it is Version 8.1.1.7 (i also had this issue using 8.1.2.1)

        I am only using exit methods to exit my position, the reason that I'm not using Set methods is because my stop loss is set up through the strategy builder using trigger variable's. Since this is the case it doesn't allow me to use the "Stops and Targets" tab which would assign those Set methods.

        Since I am using the strategy builder and I did not unlock this code, I currently have a set that uses an if statement to exit my current position once it reaches a set number of ticks. This is also assigned to an entry name. ( I have attached a screenshot)

        I currently have TraceOrders enabled so i can see how the orders are behaving, but I do not have prints added. This problem has been going on for a while within my strategy even before the release of the current Version of the platform. From what I can see and from the research I've done using Ninjatrader's help guides is that the problem is due to partial fills. Using my output window and also my Log it seems that everything works fine until there is a partial fill. This seems to lead to extra order submissions to cover the partial fill, and I cant seem to stop that from happening. To troubleshoot this at first I thought that I would just switch from using market orders as my exit to limit orders since the Managed Approach seemed to be something that might help in stopping the extra orders from being stacked. That didn't work. I also looked into OnOrderUpdate & OnExecution methods, but those are for experienced programmers and require unlocking the script.

        Click image for larger version

Name:	image.png
Views:	71
Size:	31.3 KB
ID:	1297829

        Comment


          #5
          Hello Mikey_,

          Thanks for your notes.

          It seems that you are specifying a specific number for the quantity in your Exit order method.

          When a partial fill occurs, you are still in a short market position so the condition might be true and the strategy could be calling the Exit order method to submit an exit order with that same defined quantity.

          Debugging prints would need to be added to the script to understand exactly how the logic is behaving in the strategy when you see the reported behavior occur to confirm.

          Here is a link to a forum thread demonstrating using prints to understand behavior: https://ninjatrader.com/support/foru...121#post791121

          Something you could consider trying is using the strategy's current position size for the quantity of your Exit order method. This would be found in the Strategy folder > Current position size when setting the quantity parameter of the Exit order.
          Brandon H.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_BrandonH View Post
            Hello Mikey_,

            Thanks for your notes.

            It seems that you are specifying a specific number for the quantity in your Exit order method.

            When a partial fill occurs, you are still in a short market position so the condition might be true and the strategy could be calling the Exit order method to submit an exit order with that same defined quantity.

            Debugging prints would need to be added to the script to understand exactly how the logic is behaving in the strategy when you see the reported behavior occur to confirm.

            Here is a link to a forum thread demonstrating using prints to understand behavior: https://ninjatrader.com/support/foru...121#post791121

            Something you could consider trying is using the strategy's current position size for the quantity of your Exit order method. This would be found in the Strategy folder > Current position size when setting the quantity parameter of the Exit order.
            Thanks for your reply,

            Thank you for the tip as well, I will attempt to change the logic for the order quantity and see if that helps.

            As far as adding prints go I'm looking for some guidance. After studying the forum and tutorial videos that were provided, I'm able to understand how to add prints and use them to evaluate whether the set condition is being met in order to trigger an entry or exit.
            Referring to the examples included and dealing with something like a Moving Average Crossover, you would need to know if the specific moving average is greater or less than the current & previous bar... For my strategy I'm not sure how I would go about adding prints to my current set (in the screenshot below) to see why extra orders are being placed. I understand adding a print so that I can view the price that I should be exiting at, but I'm confused on what needs to be looked at and printed in order to view why extra orders are being placed, could you please give some guidance.

            The trace orders in combination with the Log gives me the order time, order status, order type, price, entry/exit signal names, quantity etc.. this is enough to confirm that the if statement is valid at the right prices, but what it doesn't show is why after filling a complete order and making the position flat, that it then chooses to place another of the exact same order. Hopefully you can give me an example of what prints I would need for this. Looking forward to your assistance, thanks

            Click image for larger version

Name:	image.png
Views:	74
Size:	29.3 KB
ID:	1297978

            Comment


              #7
              Hello Mikey_,

              Thanks for your notes.

              I see that you have changed the ExitShortLimit() method to an ExitShort() method in the script.

              After making this change and testing the strategy, do you still see the same behavior occurring?

              Do you have multiple Exit orders for the same Entry order in your script or do you only have this one Exit order?

              If your strategy places Long orders as well, are you using the same Signal Name for the Exit order method for your Long positions? Note that each Exit order should have a unique Signal Name, such as "TakeProfitsShort" for short Exit orders and "TakeProfitLong" for long Exit orders.

              Are you running multiple strategies on the same account/instrument combination?

              For the screenshot you shared, outside the Set (in a separate Set) you would add prints to the script that print out Position.MarketPosition and the values being used for the less than condition (GetCurrentAsk() and Position.AveragePrice + (80 TickSize)) to see if those values in the conditions are becoming true multiple times.

              You could also add a print to Set in the screenshot you shared that prints something like "Set 8 triggered, conditions true" and print out Position.Quantity in that Set to confirm the condition in that Set became true, the logic was triggered, and what Position.Quantity evaluates to.
              Brandon H.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_BrandonH View Post
                Hello Mikey_,

                Thanks for your notes.

                I see that you have changed the ExitShortLimit() method to an ExitShort() method in the script.

                After making this change and testing the strategy, do you still see the same behavior occurring?

                Do you have multiple Exit orders for the same Entry order in your script or do you only have this one Exit order?

                If your strategy places Long orders as well, are you using the same Signal Name for the Exit order method for your Long positions? Note that each Exit order should have a unique Signal Name, such as "TakeProfitsShort" for short Exit orders and "TakeProfitLong" for long Exit orders.

                Are you running multiple strategies on the same account/instrument combination?

                For the screenshot you shared, outside the Set (in a separate Set) you would add prints to the script that print out Position.MarketPosition and the values being used for the less than condition (GetCurrentAsk() and Position.AveragePrice + (80 TickSize)) to see if those values in the conditions are becoming true multiple times.

                You could also add a print to Set in the screenshot you shared that prints something like "Set 8 triggered, conditions true" and print out Position.Quantity in that Set to confirm the condition in that Set became true, the logic was triggered, and what Position.Quantity evaluates to.
                Thanks again for you reply,

                "I see that you have changed the ExitShortLimit() method to an ExitShort() method in the script."
                "After making this change and testing the strategy, do you still see the same behavior occurring?"


                I can appreciate your attention to detail, thank you for catching that exit limit/market change. In order to troubleshoot, I duplicate the original strategy and save it under a new name so that I can troubleshoot one thing at a time, the original strategy uses market orders and at the time of the screenshot I did not adjust that part, but I was sure to before testing the strategy Live. Its hard to test this strategy because everything works perfect during a back test or in the playback, I only get the extra order issue when running it in the Live markets. To answer the question, I changed one part of the strategy today and that was just the quantity part. I changed it from using my user input to "Current Position Size".
                The problem that this creates is that now when submitting my "TakeProfit" exit, the order includes the entire position even though its linked to one entry signal. (shown in the screenshot below)
                Both entries submit 3 orders each totaling in 6 orders under two different entry names. Using "Current Position Size" as an exit seems to include all 6 contracts in this scenario instead of the 3 tied to the entry signal that I chose for this exit. This order of 6 got partial fills as you can see in the log below, but actively watching the strategy, I was able to see the 3 other limit orders sitting on the exchange. So this doesn't work. Idk what else to try

                "Do you have multiple Exit orders for the same Entry order in your script or do you only have this one Exit order?"

                The only possible exit orders for this entry "ScaleShort" would be the exit limit order that's attached to set 8 under the name "TakeProfit", as well as my stop loss built in for the strategy. This exit is a stop market order placed immediately upon entry to my set number of ticks and runs on a trigger state variable.

                "If your strategy places Long orders as well, are you using the same Signal Name for the Exit order method for your Long positions? Note that each Exit order should have a unique Signal Name, such as "TakeProfitsShort" for short Exit orders and "TakeProfitLong" for long Exit orders."
                "Are you running multiple strategies on the same account/instrument combination?"


                My strategy does take long orders as well, Its the same conditions as the short side just flipped and adjusted accordingly to account for the market moving up instead of down. The entries have different names,( ScaleLong & LongEntry) but the take profit exit has the same signal name. I used a similar signal name because if the market is long it automatically invalidates the if statements that are necessary for the short conditions to be true to where it would take action.
                To answer the next question, I am only running this one strategy on this instrument and on this account.

                "For the screenshot you shared, outside the Set (in a separate Set) you would add prints to the script that print out Position.MarketPosition and the values being used for the less than condition (GetCurrentAsk() and Position.AveragePrice + (80 TickSize)) to see if those values in the conditions are becoming true multiple times."
                "You could also add a print to Set in the screenshot you shared that prints something like "Set 8 triggered, conditions true" and print out Position.Quantity in that Set to confirm the condition in that Set became true, the logic was triggered, and what Position.Quantity evaluates to.​"


                Since I know that using Position.Quantity doesn't work, I am going to go back to market orders and add the prints so that I can test it tomorrow. Thanks


                The top screenshot starting at my highlighted selection shows my two separate entries under different signals names being executed properly, then you can see the stop market orders "NotFlat" being placed as well right after​

                The bottom screen shot starting at my highlighted selection shows the strategy submitting the exit order for the full position size (6 contracts) instead of just the 3 linked to the one entry signal

                Click image for larger version

Name:	image.png
Views:	46
Size:	264.0 KB
ID:	1298175

                Click image for larger version

Name:	image.png
Views:	78
Size:	212.3 KB
ID:	1298174

                Comment


                  #9
                  Hello Mikey_,

                  Thanks for your notes.

                  To clarify, in the script you are testing are you using ExitShort() or are you using ExitShortLimit()?

                  "The only possible exit orders for this entry "ScaleShort" would be the exit limit order that's attached to set 8 under the name "TakeProfit", as well as my stop loss built in for the strategy."

                  From my understanding, you have two Exit orders in the script for the single Entry order method. Is that correct?

                  It could be that the Exit market order and the Exit stop loss order are both being filled, causing the script to reverse to a long position instead of a flat position.

                  " the take profit exit has the same signal name."

                  You should make sure that you are using a unique signal name for the Exit orders for your Long and Short positions in the script. For example, use "TakeProfitLong" for long exit orders and use "TakeProfitShort" for short exit orders.

                  If possible, please share with us an exported copy of your strategy (with prints added) so that we may take a look and see if anything specific stands out in the code.

                  To export a script go to Tools > Export > NinjaScript AddOn.

                  Exporting: https://ninjatrader.com/support/helpGuides/nt8/index.html?export.htm#ExportingninjascriptAsSource Files
                  Last edited by NinjaTrader_BrandonH; 04-03-2024, 08:20 AM.
                  Brandon H.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_BrandonH View Post
                    Hello Mikey_,

                    Thanks for your notes.

                    To clarify, in the script you are testing are you using ExitShort() or are you using ExitShortLimit()?

                    "The only possible exit orders for this entry "ScaleShort" would be the exit limit order that's attached to set 8 under the name "TakeProfit", as well as my stop loss built in for the strategy."

                    From my understanding, you have two Exit orders in the script for the single Entry order method. Is that correct?

                    It could be that the Exit market order and the Exit stop loss order are both being filled, causing the script to reverse to a long position instead of a flat position.

                    " the take profit exit has the same signal name."

                    You should make sure that you are using a unique signal name for the Exit orders for your Long and Short positions in the script. For example, use "TakeProfitLong" for long exit orders and use "TakeProfitShort" for short exit orders.

                    If possible, please share with us an exported copy of your strategy (with prints added) so that we may take a look and see if anything specific stands out in the code.

                    To export a script go to Tools > Export > NinjaScript AddOn.

                    Exporting: https://ninjatrader.com/support/helpGuides/nt8/index.html?export.htm#ExportingninjascriptAsSource Files
                    Thanks for your reply,

                    "To clarify, in the script you are testing are you using ExitShort() or are you using ExitShortLimit()?"

                    In my script I am using ExitShort() as i prefer market orders because they are more likely to get filled. The only reason I switched to limit orders was because it was a form of trouble shooting just in case the market orders were stacking. But since limit orders didn't fix the issue I returned to my preference of market orders.

                    "From my understanding, you have two Exit orders in the script for the single Entry order method. Is that correct?"

                    I do apologize, I was not clear as i didn't think about all my entries and exits. But to confirm I have 4 possible exits to my entry which include:
                    1. my built in trail stop loss which is exit stop market order
                    2. my "TakeProfits" exit which is a exit market order
                    3. my crossover exit which is a exit market order
                    4. my end of day exit which is a exit market order

                    "It could be that the Exit market order and the Exit stop loss order are both being filled, causing the script to reverse to a long position instead of a flat position."

                    I considered this at one point, but the log is pretty clear on what orders are placed,worked,cancelled, accepted, and filled while also including quantity as well signal names. The only problem that I can see is that it places too many orders of the same signal name, but I can't understand why. For example, if i have my short entry "ScaleShort" with 3 contracts and it reaches a "TakeProfitsShort" exit of 3 contracts after going a set amount of ticks in my favor, the log shows me that the strategy places and fills the "TakeProfits" exit orders as well as cancels the stop market exit orders attached to this entry. So it works fine with keeping the entries and exits separate, the only problem is that the strategy will sometimes show too many order submissions under the same signal name. For some reason the same if condition is validating as true more than once.

                    "You should make sure that you are using a unique signal name for the Exit orders for your Long and Short positions in the script. For example, use "TakeProfitLong" for long exit orders and use "TakeProfitShort" for short exit orders."

                    I ensured that this was the case today. I updated all entries and exits so that they had their own unique signal name. Still had too many positions opened.

                    "If possible, please share with us an exported copy of your strategy (with prints added) so that we may take a look and see if anything specific stands out in the code."

                    I am attaching a zip file to this reply. I added prints to both the "TakeProfitsLong" and "TakeProfitsShort". The extra orders issue can randomly happen to all my entries and exits besides my stop loss, my hope is that understanding why this is happening with the TakeProfits exit that is can provide me with the fix for all. And just to clarify.. the strategy runs perfect in a backtest as well as playback mode, the issue only arises in Live market conditions.
                    Thanks for the help, looking forward to your reply
                    Last edited by Mikey_; 04-04-2024, 12:46 PM.

                    Comment


                      #11
                      Hello Mikey_,

                      Thanks for your notes.

                      When testing your strategy on the MNQ 06-24 instrument, I am not able to reproduce the behavior when running the strategy on real-time data on the Sim101 account.

                      To investigate the cause of the behavior further, we would need specific steps to reproduce the behavior so that we can see the behavior occurring when testing the script.

                      If you have specific settings used to test the strategy to reproduce the behavior with the script you shared, please provide the steps and settings used to reproduce the behavior.

                      I would recommend separating the Exit methods in Set 1 so that you are checking for the Time comparion and checking if you are in a Short market position. Then, call ExitShort() in that Set. In a separate Set, check for the Time comparison condition and check if you are in a Long market position and call ExitLong() in that Set.

                      If you are wanting to only have the ExitLong()/ExitShort() exit for a certain position, such as for "ScaleLong", and not for the full position quantity, you should change Position.Quantity to the number of contracts the Enter method is submitting.

                      Further debugging prints should also be added to the script to pinpoint the exact section of code causing the behavior. Add prints to the script that print out all the values used in the all conditions to place Exit orders and add prints within each condition that places Exit orders to see how/when those conditions are triggering.

                      You could also create a copy of the script by navigating to the 'Welcome' screen of the Strategy Builder, hovering your mouse over the strategy, and clicking 'Save as'. Then reduce the code of the copy by removing code in the script to see if the behavior persists. If at any point you see the behavior stop, the code last removed is likely causing the behavior to occur.

                      If you would like us to review your Log and Trace files to investigate the matter further, please write in to support[at]ninjatrader[dot]com to send us your Log and Trace files along with the date and time the behavior occurred. In the subject of the email include 'Attn BrandonH' and in the body of the email include a link to this forum thread.

                      Sending Log and Trace Files to NinjaTrader: https://support.ninjatrader.com/s/ar...to-NinjaTrader
                      Last edited by NinjaTrader_BrandonH; 04-04-2024, 11:22 AM.
                      Brandon H.NinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by NinjaTrader_BrandonH View Post
                        Hello Mikey_,

                        Thanks for your notes.

                        When testing your strategy on the MNQ 06-24 instrument, I am not able to reproduce the behavior when running the strategy on real-time data on the Sim101 account.

                        To investigate the cause of the behavior further, we would need specific steps to reproduce the behavior so that we can see the behavior occurring when testing the script.

                        If you have specific settings used to test the strategy to reproduce the behavior with the script you shared, please provide the steps and settings used to reproduce the behavior.

                        I would recommend separating the Exit methods in Set 1 so that you are checking for the Time comparion and checking if you are in a Short market position. Then, call ExitShort() in that Set. In a separate Set, check for the Time comparison condition and check if you are in a Long market position and call ExitLong() in that Set.

                        If you are wanting to only have the ExitLong()/ExitShort() exit for a certain position, such as for "ScaleLong", and not for the full position quantity, you should change Position.Quantity to the number of contracts the Enter method is submitting.

                        Further debugging prints should also be added to the script to pinpoint the exact section of code causing the behavior. Add prints to the script that print out all the values used in the all conditions to place Exit orders and add prints within each condition that places Exit orders to see how/when those conditions are triggering.

                        You could also create a copy of the script by navigating to the 'Welcome' screen of the Strategy Builder, hovering your mouse over the strategy, and clicking 'Save as'. Then reduce the code of the copy by removing code in the script to see if the behavior persists. If at any point you see the behavior stop, the code last removed is likely causing the behavior to occur.

                        If you would like us to review your Log and Trace files to investigate the matter further, please write in to support[at]ninjatrader[dot]com to send us your Log and Trace files along with the date and time the behavior occurred. In the subject of the email include 'Attn BrandonH' and in the body of the email include a link to this forum thread.

                        Sending Log and Trace Files to NinjaTrader: https://support.ninjatrader.com/s/ar...to-NinjaTrader
                        Thanks Brandon for the reply,

                        "When testing your strategy on the MNQ 06-24 instrument, I am not able to reproduce the behavior when running the strategy on real-time data on the Sim101 account."
                        "To investigate the cause of the behavior further, we would need specific steps to reproduce the behavior so that we can see the behavior occurring when testing the script."
                        "If you have specific settings used to test the strategy to reproduce the behavior with the script you shared, please provide the steps and settings used to reproduce the behavior.​"


                        Specific steps, properties/parameters I use when adding the strategy:
                        (Same for either instrument I run it on mnq or NQ, only difference is that MNQ 6-24 would be on a 5min chart whereas NQ 6-24 would be on a 1,000 volume chart)
                        -Within the control center, I click on the “strategies tab” then click “new strategy”. I then select this specific strategy and input the parameters as shown in the screenshot below. I also then select the account I am testing the strategy on. After clicking “OK” I then proceed to left-click on “enabled” to activate the strategy.

                        Strange that you did not get the same behavior as I did, but you can see that its a reoccurring issue for me as I have already shared a ton of my log screenshots with you.

                        "
                        I would recommend separating the Exit methods in Set 1 so that you are checking for the Time comparion and checking if you are in a Short market position. Then, call ExitShort() in that Set. In a separate Set, check for the Time comparison condition and check if you are in a Long market position and call ExitLong() in that Set."
                        "If you are wanting to only have the ExitLong()/ExitShort() exit for a certain position, such as for "ScaleLong", and not for the full position quantity, you should change Position.Quantity to the number of contracts the Enter method is submitting.​"


                        I am going to go ahead and add prints to all my exit conditions. I will also split up the first set and have both sets check the current position for the exit as well as the time comparison to see it that helps, as you have suggested. thanks for the tip.
                        A far as changing Position.Quantity to a specific number of contracts, that was my original idea. I had the quantity set to the same "NumOfContracts" user input which was already set at "3" in this example. I used that input for determining the quantity of both the entry and the exit. I only had the option of my user input, position.quantity, or DefaultQuantity.

                        "If you would like us to review your Log and Trace files to investigate the matter further, please write in to support[at]ninjatrader[dot]com to send us your Log and Trace files along with the date and time the behavior occurred. In the subject of the email include 'Attn BrandonH' and in the body of the email include a link to this forum thread."

                        I went ahead and sent an email to the support team with the all the information listed as well as your name attached to the subject line, thanks

                        Screenshot of my specific steps,inputs,parameters,properties:




                        Comment


                          #13
                          Hello Mikey_,

                          Thanks for your notes.

                          I have reviewed the Log and Trace files youl shared and emailed you back regarding the behavior seen in the Log and Trace files.

                          Please see the email sent to you for a breakdown of what occurred and reply to that email with any further questions you may have.
                          Brandon H.NinjaTrader Customer Service

                          Comment


                            #14
                            Just jumping in here as I fought through this and Mikey_ Reached out to ask how I solved it. Figured it could help a few others.

                            I see you are using the GUI. I don't use that. Not sure if there is a way to do this with that.

                            Ultimately, You need to focus on building logic in OnOrderUpdate. I'm using market orders so none of this will work super well without more thoughts for other order types but it should still work.

                            1. Check in OnOrderUpdate that you assign an order variable when the orders you are concerned with get submitted. if Order.Ordername == "[insert]": myOrder = Order for all of them. That way you can monitor this later. You'll want to null this once the order is filled.

                            2.in OnBarUpdate or similar:

                            - OrderState: make it true only when each orderstate you are concerned with is true. You can set it specifically for the order you want or just any orders. I'm not concerned about partial fills but I see that is a concern for you so double check if it works.


                            3. Check the logic: You can then make sure before any trade logic you check to make sure the isOrderSubmitted is false otherwise.. do something else? (I do nothing/return)

                            4. Then also in OnOrderUpdate:> isOrderSubmitted = false: When Order.orderState is filled OR the order.filled == 1 (same thing different way but I use both just to be certain as sometimes the strategy can TRY to do things but not complete them), you reset isOrderSubmitted to False.

                            I have a couple other layers about how this works for me but this is the gist.

                            Hope this helps.
                            Tony


                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Haiasi, 04-25-2024, 06:53 PM
                            2 responses
                            16 views
                            0 likes
                            Last Post Massinisa  
                            Started by Creamers, Today, 05:32 AM
                            0 responses
                            4 views
                            0 likes
                            Last Post Creamers  
                            Started by Segwin, 05-07-2018, 02:15 PM
                            12 responses
                            1,785 views
                            0 likes
                            Last Post Leafcutter  
                            Started by poplagelu, Today, 05:00 AM
                            0 responses
                            3 views
                            0 likes
                            Last Post poplagelu  
                            Started by fx.practic, 10-15-2013, 12:53 AM
                            5 responses
                            5,407 views
                            0 likes
                            Last Post Bidder
                            by Bidder
                             
                            Working...
                            X