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

OnBarUpdate sample and null reset orders

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

    #16
    Hello,

    So, sometimes execution is called before OBU send the order, as you can see in prints attached. Strategy runs OnEachTick and print OBU is Time[1
    The previous prints you highlighted show that there was an execution filled and then the entryLongOrder gets set to null. OBU happened after and the cycle repeated to submit a new entry. OBU is called after OEU in the highlighted prints because the fill of the order happened first and the condition in OBU prevented the print before the order was null. The fill happened because there was an order submitted prior to that.

    Are you seeing that the orders are incorrectly reset when using the SampleOnOrderUpdate from the help guide? While I cannot debug your strategy for you I can try to address the question with our existing sample.

    I look forward to being of further assistance.

    JesseNinjaTrader Customer Service

    Comment


      #17
      Hello Jesse

      No, Jesse.

      OBU print happened after but it is not to submit a new entry, it is the same that was executed in previous print.

      I don´t want you debug my strategy, that is something I can do. What I need is to know what can be wrong in this handful of lines. Or maybe we have found a new bug in platform...

      Please, I repeat... OBU print happened after but it is not to submit a new entry, it is the same that was executed in previous print. Randomly executions prints are before order entry OBU prints. So, order cannot return to null after execution...

      Sincerely,

      Comment


        #18
        Hello Rosario,

        OBU print happened after but it is not to submit a new entry, it is the same that was executed in previous print.
        The print you highlighted is the one for the entry when its sent, I am not sure what you mean by its the same that was executed.

        OEU1/5/2021 4:05:46 PM START TRADE L1
        OEU1/5/2021 4:05:46 PM execution.Order.OrderState == OrderState.Filled && sumLongFilled == execution.Order.Filled || 1
        OEU1/5/2021 4:05:46 PM execution.Order.OrderState != OrderState.PartFilled && sumLongFilled == execution.Order.Filled || 1
        entryLongOrder set to NULL
        ================================================== ========
        OBU || LightCode V 1 || SENT L1 30225 || contracts: 1

        The order OEU prints happened, the order null print happened, the order was null when OBU was called here, this is what you highlighted so if that is not what you are referring to please be more specific.


        Code:
        I don´t want you debug my strategy, that is something I can do. What I need is to know what can be wrong in this handful of lines. Or maybe we have found a new bug in platform...
        To know that you would need to debug your strategy.

        From the prints you highlighted it appears the prints happened in the correct order, if you are going by the Times you are printing I would suggest to just remove the times to help clarify the order of the prints. The time of the bar is not relevant to the time of the execution, you are printing an arbitrarily bar tick time opposed to the time the execution event happened.

        I would otherwise suggest using the sample that we provide to demonstrate the problem if you feel something is happening incorrectly. That would be so we don't need to look through your custom logic and are using a known script for testing. The sample has not been reported to have issues in resetting the variables used so that would be a good first step or confirming if the order is reset to null correctly in that use case. If you need to make small changes for quantities for part fills that is fine but I would not suggest adding other items like custom indicators or extra series.

        Please let me know if I may be of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #19
          Hello Jesse

          I attach chart with more information and output to clarify and help other users and Ninjatrader development team to solve this issue.

          Please, leave this post open in case any other user have more interest and is able to give advise. Thanks

          1/5/2021 4:05:46 PM Strategy 'LightCode V 1/224952884': Entered internal SubmitOrderManaged() method at 1/5/2021 4:05:46 PM: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=1 LimitPrice=30225 StopPrice=0 SignalName='L1' FromEntrySignal=''
          OOU print
          Submitted
          OOU print
          Accepted
          OOU print
          Working
          OOU print
          Filled

          OEU print
          1/5/2021 4:05:46 PM Strategy 'LightCode V 1/224952884': Entered internal SubmitOrderManaged() method at 1/5/2021 4:05:46 PM: BarsInProgress=0 Action=Sell OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=30205 SignalName='Stop L1' FromEntrySignal='L1'
          1/5/2021 4:05:46 PM Strategy 'LightCode V 1/224952884': Entered internal SubmitOrderManaged() method at 1/5/2021 4:05:46 PM: BarsInProgress=0 Action=Sell OrderType=Limit Quantity=1 LimitPrice=30250 StopPrice=0 SignalName='Target L1' FromEntrySignal='L1'
          OEU execution.Order.OrderState == OrderState.Filled && sumLongFilled == execution.Order.Filled
          OEU execution.Order.OrderState != OrderState.PartFilled && sumLongFilled == execution.Order.Filled
          entryLongOrder set to NULL

          ================================================== ========
          OBU print
          LightCode V 1 || - entryLongOrder != null

          1/5/2021 4:06:11 PM Strategy '224952884/LightCode V 1: Cancelled pending exit order, since associated position is closed, orderId='64b584d8ac9a4eacbd1e58847cb380aa' account='Playback101' name='Target L1' orderState=Working instrument='YM 03-21' orderAction=Sell orderType='Limit' limitPrice=30250 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=57 time='2021-01-05 16:05:46' gtd='2099-12-01' statementDate='2021-01-05'
          END TRADE L1
          ================================================== ========
          LightCode V 1 || - entryLongOrder != null
          LightCode V 1 || - entryLongOrder != null
          LightCode V 1 || - entryLongOrder != null
          LightCode V 1 || - entryLongOrder != null
          LightCode V 1 || - entryLongOrder != null
          LightCode V 1 || - entryLongOrder != null
          LightCode V 1 || - entryLongOrder != null
          LightCode V 1 || - entryLongOrder != null


          Click image for larger version

Name:	NT8 bug.jpg
Views:	120
Size:	96.9 KB
ID:	1142125

          Comment


            #20
            Hello Rosario,

            Thanks for the additional details however you would need to continue to debug your script if it is not working correctly. Our support team cannot debug the script you provided, if that is not resetting the variable or working as expected I would suggest trying to recreate the problem using our existing working sample. If you are able to see the problem in the more simple help guide sample we could use that as a basis for a report to development assuming there is a problem that needs reported. If you cannot recreate the problem in that simple context you could use it for comparison against the script you provided here to find the problem.


            Please let me know if I may be of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #21
              Hello Jesse

              I have read a lot of post in this amazing forum, and I have realized that most platform bugs have been found thanks to users that carry on trying to know the reason behind any issue... Platform team should be grateful of this, because it is a big waste of time for users of a not-cheap platform.

              Obviously help guide sample does not have this problem, it runs OnBarClose, uses market orders and only one data serie. I wish you have opened strategy script at least. Maybe it gives you a clue for next releases.

              Sincerely,

              Comment


                #22
                Hello Rosario,

                I did review the sample you provided.

                If the help guide sample works that would help to know the problem relates to something you are doing in your logic. While we do take input for bug reports at this time I could not say what you are encountering is a bug because that would require knowing what part of your custom logic is not working and also what specific code/steps are required to see the problem.

                If the sample works but yours does not that gives you a way to debug the situation further by means of reduction. You can find specifically what code/steps are needed to see what you described by slowly adding parts back to the sample to see if it causes the problem. Once you know code is needed to modify the sample to display the problem we could compare that against the base sample to see exactly what was changed to better understand whats happening.


                Please let me know if I may be of further assistance.
                JesseNinjaTrader Customer Service

                Comment


                  #23
                  Hello

                  In case there is someone interested in this issue, I have solved it changing one line

                  EnterLongLimit(0, true, lotSizeEntryOne, entryLongPrice, @"L1");

                  instead of

                  entryLongOrder = EnterLongLimit(0, true, lotSizeEntryOne, entryLongPrice, @"L1");

                  Maybe this issue is connected with post #16 but I am not sure. Probably support can shed light on this.

                  Sincerely,

                  Comment


                    #24
                    Hello Rosario,

                    Thanks for updating the post and letting us know you have resolved the question. If the only change was removing the assignment that would be fine, assigning the objects generally happens from the OnExecutionUpdate override. Some samples still reflect the NT7 style which had the assignment with the entry method, that s not necessary to do in nt8 and you can exclusively use the order events.

                    Please let me know if I may be of further assistance.
                    JesseNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by ttodua, 06-18-2024, 12:33 PM
                    4 responses
                    13 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by lepticellreviews, Today, 05:12 AM
                    0 responses
                    8 views
                    0 likes
                    Last Post lepticellreviews  
                    Started by lepticellreviews, Today, 05:10 AM
                    0 responses
                    3 views
                    0 likes
                    Last Post lepticellreviews  
                    Started by AcidaBurnCA, Today, 04:54 AM
                    0 responses
                    2 views
                    0 likes
                    Last Post AcidaBurnCA  
                    Started by TanyaD, 06-17-2024, 10:07 AM
                    5 responses
                    22 views
                    0 likes
                    Last Post TanyaD
                    by TanyaD
                     
                    Working...
                    X