Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Position not being closed in strategy analyzer

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

    #16
    Hello tkaboris,

    Can you print the time and the high and low of each bar to confirm the price was hit while the position was open and this order was working?

    That should be the first line in OnOrderUpdate(). No this would be placed after an order.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #17
      i am confused about print order line. Is it after onbarupdate or after i place an entry
      Click image for larger version  Name:	image.png Views:	0 Size:	525.3 KB ID:	1259410

      Comment


        #18
        Hello tkaboris,

        You have placed this in OnBarUpdate(). You need to place this in OnOrderUpdate().

        The order object is a parameter of the OnOrderUpdate() method call.

        protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string comment)
        Chelsea B.NinjaTrader Customer Service

        Comment


          #19
          ok i printed as directed

          Comment


            #20
            i posted my code in #15... can you help to place this line correctly?
            protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string comment)​

            Comment


              #21
              Hello tkaboris,

              Copy and paste the order method call from the Syntax section in the help guide.

              Place this is the scope of the class. (For example below OnBarUpdate())
              Chelsea B.NinjaTrader Customer Service

              Comment


                #22
                I tried putting this line everywhere but I get errors. thats why i asked if you can help
                Click image for larger version

Name:	image.png
Views:	76
Size:	608.8 KB
ID:	1259427

                Comment


                  #23
                  Hello tkaboris,

                  This is again placed in the scope of OnBarUpdate(). This not supposed be in the scope of OnBarUpdate(). OnBarUpdate(), OnStateChange() are methods that are in the scope of the class.

                  Try placing the entire method declaration below the action block of OnBarUpdate().

                  If you are unfamiliar with scope in C#, I am referring to the curly braces. Anything between a set of curly braces is inside the scope of that method or class. Place this below the closing curly brace of OnBarUpdate().

                  Below is a link to an example script that has the declaration for OnOrderUpdate() implemented.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #24
                    Ok I was able to include that override method and i wanted to copy wahts in the output
                    i am getting
                    ou have reached the maximum threshold of the NinjaScript Output window. and window is blank now
                    ​​

                    Comment


                      #25
                      here is a file
                      https://drive.google.com/file/d/15ts...ew?usp=sharing

                      chart looks like this


                      Please help
                      Click image for larger version

Name:	image.png
Views:	76
Size:	906.8 KB
ID:	1259439

                      Comment


                        #26
                        Hello tkaboris,

                        I'm still not seeing the print of the order object.. Have you compiled, cleared the output window, and re-run the script after making the changes?

                        Also, I am not seeing in the output where the high rose to 15250.5.
                        6/13/2023 4:59:59 PM Strategy 'Stoch Algo Trader/-1': Amended parabolic stop order orderId='NT-00006-14208' account='Backtest' name='Parabolic stop' orderState=Working instrument='MNQ 09-23' orderAction=BuyToCover orderType='Stop Market' limitPrice=0 stopPrice=15250.5 quantity=1 tif=Gtc oco='NT-00004-14208' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2023-06-12 19:05:25' gtd='2099-12-01' statementDate='2023-07-07' stopPriceChanged=15250.5

                        As we verified SetParabolicStop is being set and amended, you can temporarily disable TraceOrders to reduce the number of prints.

                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #27
                          ​I disabled trace orders but still getting lots of prints. Should I comment out this line? Print(order.ToString());
                          i did recompiled it several times... and ran several times after that..

                          Click image for larger version

Name:	image.png
Views:	68
Size:	1,003.0 KB
ID:	1259443

                          Comment


                            #28
                            strategy just in case
                            Attached Files

                            Comment


                              #29
                              Hello tkaboris,

                              This is the output we want to see. Along with the high and low of the bar to verify that price crossed above the stop price of the working parabolic stop order.

                              At what time does the market price rise past 15250?

                              Be sure to save the output to a text file and include this with your post.
                              Chelsea B.NinjaTrader Customer Service

                              Comment


                                #30
                                I am lost. I understand what you want to see but these prints with orderid flooding the output...

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by NullPointStrategies, 03-13-2026, 05:17 AM
                                0 responses
                                87 views
                                0 likes
                                Last Post NullPointStrategies  
                                Started by argusthome, 03-08-2026, 10:06 AM
                                0 responses
                                151 views
                                0 likes
                                Last Post argusthome  
                                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                                0 responses
                                80 views
                                0 likes
                                Last Post NabilKhattabi  
                                Started by Deep42, 03-06-2026, 12:28 AM
                                0 responses
                                53 views
                                0 likes
                                Last Post Deep42
                                by Deep42
                                 
                                Started by TheRealMorford, 03-05-2026, 06:15 PM
                                0 responses
                                62 views
                                0 likes
                                Last Post TheRealMorford  
                                Working...
                                X