Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

cancel order with mutile additional data series

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

    cancel order with mutile additional data series

    Hi, I am using two additional data series in my strategy. And when I am using CancelOrder(entryOrder), sometimes it cancels, sometimes it does not. logic is, if (entryOrder != null) {CancelOrder(entryOrder)}. Do I have to take additional measure to use this? I have already used if(BarsInProgress == 0) check before executing that cancel order logic.

    #2
    Hello asmmbillah,

    Thank you for your post.

    Please see the notes section and the warning section of the help guide documentation linked below.
    CancelOrder - https://ninjatrader.com/support/help...ancelorder.htm

    As the help guide states, 'this method sends a cancel request to the broker and does not guarantee that an order is completely cancelled. Most of the time you can expect your order to come back 100% cancelled.'

    Note that if you have existing historical order references which have transitioned to real-time, you MUST update the order object reference to the newly submitted real-time order; otherwise, errors may occur as you attempt to cancel the order.

    Also, see the example script in this help guide link for using CancelOrder() to cancel an order.


    Ultimately, to understand why the script is behaving as it is, such as placing orders or not placing orders or drawing objects when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

    In the strategy add prints (outside of any conditions) that print the values of every variable used in every condition that places an order along with the time of that bar. Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

    Below is a link to a forum post that demonstrates using prints to understand behavior and including a link to a video recorded using the Strategy Builder.
    https://ninjatrader.com/support/foru...121#post791121

    Please let me know if I may further assist
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      thanks, but none of what you said in above post applies to this instance. However I am using the below and placing unmanaged orders inside and when I am printing BarsInProgess, it prints 2.
      ChartControl.Dispatcher.InvokeAsync((Action)(() =>
      {}));
      can you advise?

      Comment


        #4
        Hello asmmbillah.

        Thank you for your note.

        Could you provide more details on what you made or how the provided information does not apply to your situation? The ChartControl code you provided would not be needed for placing unmanaged orders. If you have a special use case please provide more clear details so that we can assist.

        I look forward to assisting further.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          thanks for your reply. I am using ChartControl code becuase bool becomes true by clicking a button and when then bool is true, it start the process to place orders or cancel order. Do you need more info?

          Comment


            #6
            I have also made a sample startegy which places unmanaged order with click on chart to send you as it will show that order does not get canceled sometimes.
            Attached Files

            Comment


              #7
              Hello asmmbillah,

              Thank you for that information.

              It seems that you are trying to submit an order at the same time the strategy cancels the order.

              Unfortunately, in the support department at NinjaTrader it is against our policy to create, debug, or modify, code or logic for our clients. Further, we do not provide C# programming education services in our support. This is so that we can maintain a high level of service for all of our clients as well as our partners.

              If the expected trade(s) are not canceling, this would indicate that the condition to cancel the order is not evaluating as true or the order is being ignored for other reasons. You would need to debug your script to determine why the order is not being canceled.

              To understand why the script is behaving as it is, such as placing orders or not placing orders or not canceling orders when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

              In the strategy add prints (outside of any conditions) that print the values of every variable used in every condition that places an order along with the time of that bar.
              Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

              Below is a link to a forum post that demonstrates using prints to understand behavior and including a link to a video recorded using the Strategy Builder.
              https://ninjatrader.com/support/foru...121#post791121

              Please let me know if I may further assist
              <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

              Comment


                #8
                This is very unfortunate that you simply ignored the issue labelling it as debugging some script. I have read thie same template you have used in other posts. A person comes to you for support after doing all the debugging and prints which you should understand, there is no point coming to you wihout doing those tests as it consumes time to get your response. However, I thought in this case you will be helpful as it something related to ninjascript. i don't even see anything to your post reply that even that you have checked the sample script I have attached above. Very appalling.
                Last edited by asmmbillah; 02-12-2021, 11:00 AM.

                Comment


                  #9
                  Hello asmmbillah,

                  Thank you for your note.

                  I did test the script and saw the behavior you are reporting. The script is trying to place an order and cancel an order in the same condition and the 'click' variable is not being reset. After your if (entryOrder != null) condition you would need to add an 'else' statement that calls SubmitOrderUnmanaged. After the if-else condition, you would need to reset the 'click' variable by flipping it to false.

                  See the attached example script that demonstrates this.

                  Let us know if we may assist further.
                  Attached Files
                  <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                  Comment


                    #10
                    good to see that now you have tried to help. but you did not get the whole point of the cancel order issue. according to your suggestion, it will cancel and then next next bar it will submit unmanaged order. The entire cancel order issue is, when the bar starts, it will check and if entryorder exit, it will cancel the order and submit order. these are two separate independent operation. It cannot be separate with else, then the whole issue I had been trying to tell you misunderstool. Same bar, cancel if order exist and immediately after canceling submit order. I hope you have understool the issue now.

                    Comment


                      #11
                      Hello asmmbillah,

                      Thank you for your note.

                      To clarify, are you wanting to place an entry order when clicking on the chart and have the same order canceled on the same bar?

                      If so, you would need to run the strategy attached in my previous reply with a Calculate mode of OnEachTick. This will allow you to place an entry order by clicking on the chart and cancel the order on the same bar when clicking the chart again.

                      See the attached video below that demonstrates this.
                      World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.


                      Let us know if we may assist further.
                      <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by NullPointStrategies, Yesterday, 05:17 AM
                      0 responses
                      62 views
                      0 likes
                      Last Post NullPointStrategies  
                      Started by argusthome, 03-08-2026, 10:06 AM
                      0 responses
                      134 views
                      0 likes
                      Last Post argusthome  
                      Started by NabilKhattabi, 03-06-2026, 11:18 AM
                      0 responses
                      75 views
                      0 likes
                      Last Post NabilKhattabi  
                      Started by Deep42, 03-06-2026, 12:28 AM
                      0 responses
                      45 views
                      0 likes
                      Last Post Deep42
                      by Deep42
                       
                      Started by TheRealMorford, 03-05-2026, 06:15 PM
                      0 responses
                      50 views
                      0 likes
                      Last Post TheRealMorford  
                      Working...
                      X