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

2 entry orders help!

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

    Hello PaulMohn,

    for (int index = 0; index < quantitySelector.Value; index++)

    Using quantitySelector.Value for the max size of the index does not make sense.

    The index must be less than the size of the collection. It must be less than submitTargetsOrdersList.Count().

    To save output from the output window, right-click the NinjaScript Output window -> select Save As.. Then you can attach the output text file to your posts.

    Print the order object for all orders to see when orders are being updated.

    To confirm, no orders are being modified, not even the first two in the list? No error is appearing in the NinjaScript Output window or on the Log tab of the Control Center?
    You somewhere else are checking the OrderState of the orders to be OrderState.Working or .Accepted to ensure they can be modified?
    May we have the output showing the orderstate of the orders you are trying to modify?
    Chelsea B.NinjaTrader Customer Service

    Comment


      Hello Chelsea,

      Here a demo

      Attached the indicator with prints and latest modifications

      Here a download link for the output txt (2.59mb, with preliminary OnBarUpdate not useful prints) of the demo

      As seen in demo, the Target orders of the 1 NumPad7 press (1st entry) do move freely.
      But, upon the 2 NumPad7 press (2nd entry), only one set of Target orders move up,
      and only on the 1st press (no further move upon subsequent presses).

      NumPad7 + Ctrl does move back all orders but also only once
      (when multiple moves are expected and working in when only a single entry is the case).

      Thank you for your tests and recommendations!
      Attached Files
      Last edited by PaulMohn; 06-28-2022, 12:54 PM.

      Comment


        Hello PaulMohn,

        OnBarUpdate SNIPPETS entryBuyMar****rder==null : True entrySellMar****rder==null : True profitTargetOrder==null : True stopLossOrder==null : True multiOrders.Count : 0 submitTargetsOrdersList.Count : 0 submitStopLossesOrdersList.Count : 0

        Is this from Account_OrderUpdate() or is this OnBarUpdate()?

        Is this from the code where you are pressing the keys an investigating the behavior?

        Have you pressed the keys a few thousand times?


        Are you printing the orderstate of each order to ensure this is working or accepted and the current price of the order and comparing this to the new price you are submitting the order to?

        Then the order object from the OrderUpdate event would show the orders either being updated or not updated to the change price..
        Chelsea B.NinjaTrader Customer Service

        Comment


          It's the OnBarUpdate prints for about 4 minutes.
          The demo is loaded.

          I'll print the order state now.

          What order states you suggest printing?

          Print("profitTargetOrder.OrderState == OrderState.Filled : " + (profitTargetOrder.OrderState == OrderState.Filled));
          Print("profitTargetOrder.OrderState == OrderState.Cancelled: " + (profitTargetOrder.OrderState == OrderState.Cancelled));
          Print("profitTargetOrder.OrderState == OrderState.Rejected: " + (profitTargetOrder.OrderState == OrderState.Rejected));

          What new price to compare to do you have in mind? Any sample? Thanks!
          Last edited by PaulMohn; 06-28-2022, 01:24 PM.

          Comment


            New output txt attached (without the OnbarUpdate prints)

            New Demo

            I printed the order states

            PHP Code:
            entryBuyMar****rder Snippet
            Buy
            entryBuyMar
            ****rder orderId='652bbdb8c0e841da8e211bcbcc086078' account='Sim101' name='Entry' orderState=Submitted instrument='CL 08-22' orderAction=Buy orderType='Market' limitPrice=0 stopPrice=0 quantity=1 tif=Day oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=2147 time='2022-06-28 21:28:38' gtd='2099-12-01' statementDate='2022-06-28'
            multiOrders.Count 2

            Account_OrderUpdate SNIPPETS
            submitTargetsOrdersList
            .Count 1
            profitTargetOrder
            .OrderState == OrderState.Filled False
            profitTargetOrder
            .OrderState == OrderState.CancelledFalse
            profitTargetOrder
            .OrderState == OrderState.RejectedFalse

            Account_OrderUpdate SNIPPETS
            submitTargetsOrdersList
            .Count 2
            profitTargetOrder
            .OrderState == OrderState.Filled False
            profitTargetOrder
            .OrderState == OrderState.CancelledFalse
            profitTargetOrder
            .OrderState == OrderState.RejectedFalse

            ChartControl_PreviewKeyDown MOVE UP Target SNIPPETS
            submitTargetsOrdersList
            .Count 2
            profitTargetOrder
            .OrderState == OrderState.Filled False
            profitTargetOrder
            .OrderState == OrderState.CancelledFalse
            profitTargetOrder
            .OrderState == OrderState.RejectedFalse

            ChartControl_PreviewKeyDown MOVE UP Target SNIPPETS
            submitTargetsOrdersList
            .Count 2
            profitTargetOrder
            .OrderState == OrderState.Filled False
            profitTargetOrder
            .OrderState == OrderState.CancelledFalse
            profitTargetOrder
            .OrderState == OrderState.RejectedFalse

            ChartControl_PreviewKeyDown MOVE UP Target SNIPPETS
            submitTargetsOrdersList
            .Count 2
            profitTargetOrder
            .OrderState == OrderState.Filled False
            profitTargetOrder
            .OrderState == OrderState.CancelledFalse
            profitTargetOrder
            .OrderState == OrderState.RejectedFalse

            entryBuyMar
            ****rder Snippet
            Buy
            entryBuyMar
            ****rder orderId='6a965a84f8c34947bf2adec8fc5384be' account='Sim101' name='Entry' orderState=Submitted instrument='CL 08-22' orderAction=Buy orderType='Market' limitPrice=0 stopPrice=0 quantity=1 tif=Day oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=2154 time='2022-06-28 21:28:54' gtd='2099-12-01' statementDate='2022-06-28'
            multiOrders.Count 5

            Account_OrderUpdate SNIPPETS
            submitTargetsOrdersList
            .Count 3
            profitTargetOrder
            .OrderState == OrderState.Filled False
            profitTargetOrder
            .OrderState == OrderState.CancelledFalse
            profitTargetOrder
            .OrderState == OrderState.RejectedFalse

            Account_OrderUpdate SNIPPETS
            submitTargetsOrdersList
            .Count 4
            profitTargetOrder
            .OrderState == OrderState.Filled False
            profitTargetOrder
            .OrderState == OrderState.CancelledFalse
            profitTargetOrder
            .OrderState == OrderState.RejectedFalse

            Account_OrderUpdate SNIPPETS
            submitTargetsOrdersList
            .Count 5
            profitTargetOrder
            .OrderState == OrderState.Filled False
            profitTargetOrder
            .OrderState == OrderState.CancelledFalse
            profitTargetOrder
            .OrderState == OrderState.RejectedFalse

            ChartControl_PreviewKeyDown MOVE UP Target SNIPPETS
            submitTargetsOrdersList
            .Count 5
            profitTargetOrder
            .OrderState == OrderState.Filled False
            profitTargetOrder
            .OrderState == OrderState.CancelledFalse
            profitTargetOrder
            .OrderState == OrderState.RejectedFalse

            ChartControl_PreviewKeyDown MOVE UP Target SNIPPETS
            submitTargetsOrdersList
            .Count 5
            profitTargetOrder
            .OrderState == OrderState.Filled False
            profitTargetOrder
            .OrderState == OrderState.CancelledFalse
            profitTargetOrder
            .OrderState == OrderState.RejectedFalse

            ChartControl_PreviewKeyDown MOVE UP Target SNIPPETS
            submitTargetsOrdersList
            .Count 5
            profitTargetOrder
            .OrderState == OrderState.Filled False
            profitTargetOrder
            .OrderState == OrderState.CancelledFalse
            profitTargetOrder
            .OrderState == OrderState.RejectedFalse

            ChartControl_PreviewKeyDown MOVE UP Target SNIPPETS
            submitTargetsOrdersList
            .Count 5
            profitTargetOrder
            .OrderState == OrderState.Filled False
            profitTargetOrder
            .OrderState == OrderState.CancelledFalse
            profitTargetOrder
            .OrderState == OrderState.RejectedFalse

            ChartControl_PreviewKeyDown MOVE UP Target SNIPPETS
            submitTargetsOrdersList
            .Count 5
            profitTargetOrder
            .OrderState == OrderState.Filled False
            profitTargetOrder
            .OrderState == OrderState.CancelledFalse
            profitTargetOrder
            .OrderState == OrderState.RejectedFalse

            ChartControl_PreviewKeyDown MOVE UP Target SNIPPETS
            submitTargetsOrdersList
            .Count 5
            profitTargetOrder
            .OrderState == OrderState.Filled False
            profitTargetOrder
            .OrderState == OrderState.CancelledFalse
            profitTargetOrder
            .OrderState == OrderState.RejectedFalse 

            All false

            Can you please inform on what the comparison with price you suggest should be from the demo? Thanks!
            Attached Files

            Comment


              Hello PaulMohn,

              Your inquiry has been about modifying orders on a keypress, is this not what you are trying to do?

              The code itself where the orders are modified is in the handler method for the keypress, is this also not correct?
              Is this not where you are currently investigating?

              The code in Account_OrderUpdate is for submitting the stop and limit and adding these orders to a list, correct?

              At the top of the Account_OrderUpdate method to print the order to know information about the order updating:

              Print(string.Format("{0} | Account_OrderUpdate | order.ToString(): {1}", orderUpdateArgs.Time, orderUpdateArgs.Order.ToString());

              In the keypress where are you investigating modify the orders (ChartControl_PreviewKeyDown). To Print the orders information:

              for (int index = 0; index < submitTargetsOrdersList.Count; index++)
              {
              Print(string.Format("{0} | index: {1}, order.OrderState: {2}, order.LimitPrice: {3}, currentPTPrice", submitTargetsOrdersList[index].Time, index, submitTargetsOrdersList[index].OrderState, submitTargetsOrdersList[index].LimitPrice, currentPTPrice));
              }


              Unrelated, TriggerCustomEvent() is used to synchronize a Series from a non-data-driven event. If the code is not using Series information, this does not need to be called.
              Last edited by NinjaTrader_ChelseaB; 06-28-2022, 02:03 PM.
              Chelsea B.NinjaTrader Customer Service

              Comment


                Thanks Chelsea. Ah yes I had forgotten about the NumPad7 order states in the conditions.

                Here's the prints for
                1st order
                NumPad7 press and NumPad7+Ctrl press
                2nd Order
                NumPad7 press and NumPad7+Ctrl press

                Demo

                Prints (with attached txt)
                NinjaScript Output 29_06_2022 00_06.txt


                Into a spreadsheet
                https://docs.google.com/spreadsheets...gid=1827034770

                Simplified spreadsheet
                https://docs.google.com/spreadsheets...gid=2001827143

                Using the Simplified Spreadsheet for below research:

                1st POSITION (1st and 2nd orders/Contracts):

                NumPad.Multiply:

                Rows 1 to 10:
                Entries of 1st and 2nd LONG Orders
                and
                Rows 11 to 24:
                Targets and StopLosses placements


                NumPad7 / [MOVE UP 1st and 2nd Orders]:

                Rows 25 to 26:
                Initial currentPTPrice values (.91) (before NumPad7 1st Press) [MOVE UP 1st and 2nd Orders]
                index: 0, order.OrderState: Working, order.LimitPrice: 111.91, currentPTPrice
                index: 1, order.OrderState: Working, order.LimitPrice: 111.91, currentPTPrice

                Rows 27 to 34:
                1st NumPad7 Keypress = 1st and 2nd orders 1st Move (.91 to .92)

                Rows 35 to 36:
                2nd currentPTPrice values (.91 to .92) (after NumPad7 1st Press)
                index: 0, order.OrderState: Working, order.LimitPrice: 111.92, currentPTPrice
                index: 1, order.OrderState: Working, order.LimitPrice: 111.92, currentPTPrice
                Rows 37 to 44:
                2nd NumPad7 Keypress = 1st and 2nd orders 2nd Move (.92 to .93)


                Ctrl+NumPad7 / [MOVE DOWN 1st and 2nd Orders]:

                Rows 45 to 52:
                1st Ctrl+NumPad7 Keypresses = 1st and 2nd orders 1st Move Back (.93 to .92)

                Rows 53 to 60:
                2nd Ctrl+NumPad7 Keypresses = 1st and 2nd orders 2nd Move Back (.92 to .91)








                2nd POSITION (3rd and 4th and 5th orders/Contracts):

                NumPad.Multiply:

                Rows 61 to 75:
                Entries of 3rd, 4th and 5th LONG Orders
                and
                Rows 76 to 96:
                Targets and StopLosses placements

                Rows 97 to 99:
                2nd currentPTPrice values (.91 to .92) (before NumPad7 2nd Press) [MOVE UP 1st, 2nd and 3rd INSTEAD OF 3rd, 4th and 5th Orders]
                index: 0, order.OrderState: Working, order.LimitPrice: 111.91, currentPTPrice
                index: 1, order.OrderState: Working, order.LimitPrice: 111.91, currentPTPrice
                index: 2, order.OrderState: Working, order.LimitPrice: 111.93, currentPTPrice


                NumPad7 / [MOVE UP 1st, 2nd and 3rd INSTEAD OF 3rd, 4th and 5th Orders]:

                1st NumPad7 Keypress =
                Rows 100 to 109:
                1st and 2nd orders 3rd Move Up (.91 to .94)
                and
                Rows 106 to 111:
                3rd order 1st Move Up (.91 to .94)

                Rows 112 to 114:
                3rd currentPTPrice values (.91/.93 to .94) (After NumPad7 2nd Press) [NEW VALUES FOR 1st, 2nd and 3rd INSTEAD OF 3rd, 4th and 5th Orders]
                index: 0, order.OrderState: Working, order.LimitPrice: 111.94, currentPTPrice
                index: 1, order.OrderState: Working, order.LimitPrice: 111.94, currentPTPrice
                index: 2, order.OrderState: Working, order.LimitPrice: 111.94, currentPTPrice


                2nd (and subsequent multiple others) NumPad7 Keypress =
                ????? (not accounted for in the prints)


                Ctrl+NumPad7 / [MOVE DOWN of 1st, 2nd and 3rd INSTEAD OF 3rd, 4th and 5th Orders]:

                Rows 115 to 126 (1st and 2nd target Orders) / 122 to 126 (3rd Target order):
                1st, 2nd and 3rd orders 3rd Move Down (1st and 2nd orders : .94 to .92 ; 3rd order : .94 to .92)
                and
                Rows 127 to 129:
                4th currentPTPrice values (.94 to .92) (After Ctrl+NumPad7 1st Press) [NEW VALUES FOR 1st, 2nd and 3rd INSTEAD OF 3rd, 4th and 5th Orders]
                index: 0, order.OrderState: Working, order.LimitPrice: 111.92, currentPTPrice
                index: 1, order.OrderState: Working, order.LimitPrice: 111.92, currentPTPrice
                index: 2, order.OrderState: Working, order.LimitPrice: 111.92, currentPTPrice


                NEW NumPad7 / [MOVE UP 1st, 2nd and 3rd INSTEAD OF 3rd, 4th and 5th Orders]:

                Rows 130 to 141 (1st and 2nd target Orders) / 136 to 141 (3rd Target order):
                1st, 2nd and 3rd orders (1st and 2nd orders 3rd Move Up : .92 to .94 ; 3rd order 2nf Move Up : .92 to .94)
                and
                Rows 142 to 144:
                5th currentPTPrice values (.92 to .94) (After NumPad7 nth Press / 1st Press after Ctrl+NumPad7) [NEW VALUES FOR 1st, 2nd and 3rd INSTEAD OF 3rd, 4th and 5th Orders]
                index: 0, order.OrderState: Working, order.LimitPrice: 111.94, currentPTPrice
                index: 1, order.OrderState: Working, order.LimitPrice: 111.94, currentPTPrice
                index: 2, order.OrderState: Working, order.LimitPrice: 111.94, currentPTPrice




                1st problem, the prints don't account for multiple NumPad7 presses rows 100 to 129.
                They only show the actual move, but not the missed attempts to move prints.
                How to get them to keep moving the target orders upon multiple NumPad7 keypresses with multiple entries orders?




                I still don't see how to derive the solution from the prints.

                2nd problem, the Target Orders are moved from the list 1st element (i.e 1st, 2nd, 3rd etc not the most recent ones backward, i.e. 5th, 4th, 3rd etc.), and somehow they stop at the 3rd element.
                I think the cause is the quantity.Value value of 3 for the 2nd Entry.
                How would you get it to add the remainder elements in the list too? Thanks!




                I still don't see how to derive the solution from the prints.

                2nd prints (without separators)
                NinjaScript Output 29_06_2022 01_53.txt
                Attached Files
                Last edited by PaulMohn; 06-29-2022, 07:20 AM.

                Comment


                  Ah, I think I got the solution to 1st problem
                  PHP Code:
                  for (int index 0index < ((submitTargetsOrdersList.Count 0) ?
                  submitTargetsOrdersList.Count quantitySelector.Value); index++) 
                  Working script
                  Last edited by PaulMohn; 06-29-2022, 09:53 AM.

                  Comment


                    Hello PaulMohn,

                    ???

                    Why are you using quantitySelector.Value (which is a number of contracts) as the max size for the index? This doesn't make sense.

                    Are you trying Math.Min() to take whichever is smaller? Why are you using quantitySelector.Value here at all?

                    Further, reduce the output in your post. What is the one set of output from the print loop showing the orderstate, order price, and the new price it's about to be set to?

                    I see:

                    ChartControl_PreviewKeyDown MOVE UP Target SNIPPETS
                    29/06/2022 00:06:00 | index: 0, order.OrderState: Working, order.LimitPrice: 111.92, currentPTPrice

                    ChartControl_PreviewKeyDown MOVE UP Target SNIPPETS
                    29/06/2022 00:06:00 | index: 1, order.OrderState: Working, order.LimitPrice: 111.92, currentPTPrice

                    This is troublesome.. It looks like you pressed the key once, and it printed index 0, then you pressed the key a second time and this printed index 1. It should have printed both indexes 0 and 1 after pressing the key once..

                    Did you modify the print loop and add this other print? Or this print appearing outside of the loop when pressing the key?

                    This might part of the issue. Maybe the loop you showed us is not the actual code you have. Because it's not looping through the entire list. Maybe it's because your index is incorrect.


                    That said, currentPTPrice has a label and no value. What are we comparing the limit price to?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      Originally posted by NinjaTrader_ChelseaB View Post
                      Hello PaulMohn,

                      ???

                      Why are you using quantitySelector.Value (which is a number of contracts) as the max size for the index? This doesn't make sense.

                      Are you trying Math.Min() to take whichever is smaller? Why are you using quantitySelector.Value here at all?

                      Further, reduce the output in your post. What is the one set of output from the print loop showing the orderstate, order price, and the new price it's about to be set to?

                      I see:

                      ChartControl_PreviewKeyDown MOVE UP Target SNIPPETS
                      29/06/2022 00:06:00 | index: 0, order.OrderState: Working, order.LimitPrice: 111.92, currentPTPrice

                      ChartControl_PreviewKeyDown MOVE UP Target SNIPPETS
                      29/06/2022 00:06:00 | index: 1, order.OrderState: Working, order.LimitPrice: 111.92, currentPTPrice

                      This is troublesome.. It looks like you pressed the key once, and it printed index 0, then you pressed the key a second time and this printed index 1. It should have printed both indexes 0 and 1 after pressing the key once..

                      Did you modify the print loop and add this other print? Or this print appearing outside of the loop when pressing the key?

                      This might part of the issue. Maybe the loop you showed us is not the actual code you have. Because it's not looping through the entire list. Maybe it's because your index is incorrect.


                      That said, currentPTPrice has a label and no value. What are we comparing the limit price to?


                      Working script link


                      I'll test next moving targets from elements in the list. Thanks!

                      Did you look at the simplified spreadsheet research?

                      Simplified spreadsheet
                      https://docs.google.com/spreadsheets...gid=2001827143

                      What tool do you use to simplify prints reading? Can you share it? And demo it in your video sessions? Thanks!
                      Last edited by PaulMohn; 06-29-2022, 10:01 AM.

                      Comment


                        From this insight

                        What's the best way to do a backwards loop in C/C#/C++?

                        I've formulated this
                        PHP Code:
                        for (int index = ((submitTargetsOrdersList.Count 0) ?
                               
                        submitTargetsOrdersList.Count quantitySelector.Value); index 0index--)
                        {
                         
                        submitTargetsOrdersList[index].LimitPriceChanged currentPTPrice;


                        to loop/move Target orders from the latest occurrences in the list first and backward.

                        How would you simplestwise suggest retrieving the groups the targets were originally submitted in (i.e. according to the entry orders order) Thanks!


                        I'd expect a way to do it like so

                        Hotkey X
                        index > (1st Latest entry group count);

                        Hotkey Y
                        index > (2nd Latest entry group count);

                        etc.

                        How do you recommend formulating 1st Latest entry group count, 2nd Latest entry group count etc. ? Thanks!


                        Last edited by PaulMohn; 06-29-2022, 12:31 PM.

                        Comment


                          Hello PaulMohn,

                          As a heads up, I am not debugging for you.

                          The spreadsheet appears to be same output from the output window? Can you just provide the text from the output window?
                          This spreadsheet also does not any value for currentPTPrice.
                          What are comparing the limit price to?

                          "What tool do you use to simplify prints reading? Can you share it? And demo it in your video sessions?"

                          I'm not understanding this question. I type the print and I use string.Format() to add the time and labels to each value I am printing.

                          Below is a link to a forum post that has a video how I add prints.
                          Please watch the video linked under the label 'Below I am providing a link to videos that demonstrate adding prints to a script to get further information about the behavior of the script.'.
                          https://ninjatrader.com/support/foru...121#post791121

                          Are you asking how to use a time filter to reduce prints to a certain time frame to reduce the number of prints?
                          https://ninjatrader.com/support/help...to_limit_t.htm


                          From the spreadsheet: (can we just the have the ouput text file please ?)

                          29/06/2022 12:06:23 AM | Account_OrderUpdate | order.ToString(): orderId='fb03b5847268468faeeaaac97d51e2ec' account='Sim101' name='Profit Target' averageFillPrice=0 quantity=1 limitPrice=111.92 orderState=ChangePending id=2214 instrument='CL 08-22' orderAction=Sell orderType='Limit' stopPrice=0 tif=Day oco='afc3202fc183432e8abd5a2f48c331770' filled=0 onBehalfOf='' time='2022-06-29 00:06:23' gtd='2099-12-01' statementDate='2022-06-29'

                          29/06/2022 12:06:23 AM | Account_OrderUpdate | order.ToString(): orderId='51f99fd4737948808eb3e6aa1dd6fe8c' account='Sim101' name='Profit Target' averageFillPrice=0 quantity=1 limitPrice=111.92 orderState=ChangePending id=2215 instrument='CL 08-22' orderAction=Sell orderType='Limit' stopPrice=0 tif=Day oco='afc3202fc183432e8abd5a2f48c331771' filled=0 onBehalfOf='' time='2022-06-29 00:06:23' gtd='2099-12-01' statementDate='2022-06-29'

                          29/06/2022 12:06:23 AM | Account_OrderUpdate | order.ToString(): orderId='98752e68016a4a75b8f31d249b38daa2' account='Sim101' name='Profit Target' averageFillPrice=0 quantity=1 limitPrice=111.92 orderState=ChangePending id=2221 instrument='CL 08-22' orderAction=Sell orderType='Limit' stopPrice=0 tif=Day oco='201208ff2f2b4384a5a32e11ce00a3930' filled=0 onBehalfOf='' time='2022-06-29 00:06:23' gtd='2099-12-01' statementDate='2022-06-29'

                          When the orders are working, it looks like there are 3 orders being changed. How many orders are you are you expecting to be changed?

                          What is the value of currentPTPrice?

                          With the script you posted, are you 100% certain this is the script with prints added to it?
                          I'm not seeing prints or the loop in the script you just posted. These all appears to be commented out. Are you running a different copy of this script?
                          Where is the print that I suggested you add in post #111?

                          I see now that you previously added more prints to the inside of the loop which was causing the previous confusion. The extra prints do not need to be added. Just print the order information for each order in the loop and nothing else.


                          You can start your loop index at the max value and use -- to decrement just as you have suggested.

                          Using quantitySelector.Value in your loop does not make sense to me.

                          "How would you simplestwise suggest retrieving the groups the targets were originally submitted in (i.e. according to the entry orders order) Thanks!"

                          Saving the first set of orders in an Order[] array (if fixed size) or a List<Order> and a second set in another object of the same type would likely work.
                          The first hotkey press would loop through the first collection of orders. The second hotkey press would loop through the other collection.
                          Any loop would index from 0 to (less than) the list.Count (and nothing else). I would suggest using some arbitrary value from the UI for the index in a loop over a collection. The loop should be over the size of the collection.

                          That said, the custom logic is completely up to you.

                          I am directing you to use prints to understand the behavior.

                          You are saying the code doesn't work, print the values to the output window and share the text file with output. Include labels for each value in the output.

                          Print what you are investigating. If you are using indexes, print the index and the size of the collection.

                          If you are modifying an order, print the current order information and print the values you are changing it to, print the order object as it updates in the OrderUpdate event to confirm the changes.

                          Reduce and simplify. Test one thing at a time. Make a new simple test script if you need to test a small piece of code like a loop.
                          When inquiring some else, I highly recommend you reduce your inquiry to be very specific to the line or few lines code.
                          When analyzing the output we'll ask: What is the expected output? What is the actual output?
                          Last edited by NinjaTrader_ChelseaB; 06-29-2022, 11:09 AM.
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            The spreadsheet appears to be same output from the output window? Can you just provide the text from the output window?
                            Yes it is the same. I just removed the prints separators and split (=Split(CELLSWITHCONTENT, " ")) by blank in Google Sheets.
                            The 2nd attached txt from post #112 is similar to the spreadsheet (I removed the separators before printing so each printed line has no title nor blank line below it.).

                            What are comparing the limit price to?
                            Column M and Columns H-I in the Spreadsheet.
                            I figured out in the spreadsheet (post #112 research) the Target prices movements. See post #112 research.
                            The prints don't show when NumPad7 is pressed but no movement occurs, which doesn't help ( rows 100 to 129 in the spreadsheet - there should be orders state rejected or something for when the NumPad7 is pressed but no movement occurs, instead nothing is there in the prints, only when actual order movement occur does it prints).


                            I'm not understanding this question. I type the print and I use string.Format() to add the time and labels to each value I am printing.

                            Are you asking how to use a time filter to reduce prints to a certain time frame to reduce the number of prints?
                            I'd have thought you had some template to ease the reading.
                            In the Spreadsheet we can use filters by value (for example by orders ID etc. that's how I colored semi-automatedly the cells).
                            But that's semi-automated. I'd thought you had an automated way to do it. Do you? Would you share it? Thanks!

                            The problems anterior to post #116 are all solved now thanks to the ternary operator statement use shared in post #113.

                            Here a short demo showing the previous problems solved.

                            You could also test it that way
                            using the working script link



                            As shown in the demo,
                            with the working script indicator loaded on your chart
                            and the cursor focused anywhere on the chart (ChartControl)

                            Press Numpad.Add
                            then
                            Press NumPad2
                            then
                            Press NumPad.Multiply

                            A 2 contracts/2 Orders position is submitted.

                            Then
                            Press Numpad.Add
                            then
                            Press NumPad3
                            then
                            Press NumPad.Multiply

                            An additional 3 contracts/3 Orders position is submitted.

                            Then
                            Press NumPad7 multiple times

                            You see all 5 Target orders (List Count) move together each time Up.


                            That's the working proof I was after.


                            The new order entry groups issue is the only one remaining. Thanks! I'll test your recommendations for that issue and be back asa. Thanks!
                            Last edited by PaulMohn; 06-29-2022, 12:02 PM.

                            Comment


                              Hello PaulMohn,

                              I do not have an automated way of adding prints. Prints need to be added specifically to what you are testing and comparing.

                              The output from the output window is enough. You can use find to go to a specific time in the output file. You should only be printing the information that you are investigating. If you are adding too many prints, this will just be confusing. Print the time, print all of the values with labels, print labels all comparison operators. That should be all that is printed. Each part will be necessary information.

                              Please watch the video I have provided you a link to.


                              With your reply it sounds like you are no longer having an issue. Is that the case. You have added a lot information here, but I'm not sure if it's an inquiry about something not working?
                              Is the sequence of you pressing keys that you are sharing what you are investigating? Is not orders being added to a list and then looping through that list?

                              Have you printed currentPTPrice to the output window?

                              There were orders printed in the loop. Were you expecting 5 orders at that time? Is this the issue?
                              Last edited by NinjaTrader_ChelseaB; 06-29-2022, 12:09 PM.
                              Chelsea B.NinjaTrader Customer Service

                              Comment


                                Originally posted by NinjaTrader_ChelseaB View Post
                                Hello Andrea,

                                To clarify your original question, you are wanting to have opposing orders working at the same time, is this correct?

                                I have an example that you may find helpful that uses the unmanaged approach to submit a pair of opposing orders using oco (One Cancels Other) I've made for NinjaTrader 7.

                                I've ported this to NT8 for you and I'm attaching both versions so you can compare.

                                Below are links to the help guide on using the unmanaged approach.
                                https://ninjatrader.com/support/help...d_approach.htm
                                https://ninjatrader.com/support/help...runmanaged.htm

                                These examples are designed to place orders in real-time so that you can see the orders appear and try and cancel one to see the behavior.
                                Unmanaged orders can also be submitted in historical data and be backtested by removing the check for real-time.

                                (Updated July 17th, 2018 - corrected assigning the variables to null when the exit on close occurs. Also corrected preventing orders after the exit on close until the new session)

                                UnmanagedOCOBracketExample_NT8.zip
                                UnmanagedOCOBracketExample_NT7.zip
                                Hello,

                                What changes have to be done to the NT8 example to place OCO orders exactly at any given time, say for example, "place an oco order if time is 9:38 AM"?

                                Thank you.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by ETFVoyageur, Yesterday, 06:05 PM
                                4 responses
                                31 views
                                0 likes
                                Last Post ETFVoyageur  
                                Started by BIOK.NT, Today, 01:56 PM
                                1 response
                                4 views
                                0 likes
                                Last Post NinjaTrader_ChelseaB  
                                Started by cmtjoancolmenero, 04-29-2024, 03:40 PM
                                12 responses
                                38 views
                                0 likes
                                Last Post cmtjoancolmenero  
                                Started by gwenael, 04-27-2024, 09:29 AM
                                3 responses
                                32 views
                                0 likes
                                Last Post NinjaTrader_Eduardo  
                                Started by ETFVoyageur, Today, 02:08 AM
                                5 responses
                                37 views
                                0 likes
                                Last Post ETFVoyageur  
                                Working...
                                X