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

NT8 OnExecution Status

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

    NT8 OnExecution Status

    Hello,

    I need to catch status of marketposition outside onbarupdate. When I had a short script and a long script this was working fine in OnExecution because when flat then I could reset everything.
    Now I need to have short and long trades in one script and this doesn work. How can I reset variables in OnExecution (or OnOrderupdate) when long position is flattened or short position is flattened. Couldn´t get it.

    Thank you!
    Tony

    #2
    Hello tonynt,

    Thank you for the post.

    You noted that when you tried to reset variables in OnExecution, but you couldn't get it. What did you try that was not working?

    I am not sure what you are intending to reset, but generally, if you are using OnExecution you would need to observe the order that filled and its other values. Are you trying to reset an Order object or do some other kind of action? If you are trying to reset an order object upon it filling, we have a sample that shows that type of logic here: https://ninjatrader.com/support/help...ub=onexecution

    // Resets the entryOrder object to null after the order has been filled
    if (execution.Order.OrderState != OrderState.PartFilled)
    entryOrder = null;


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Post appeared 2 times, sorry. Deleted here.
      Last edited by tonynt; 02-04-2019, 11:39 AM.

      Comment


        #4
        Hello again,

        after posting the reply I got an idea now that with an additional bool it could work in OnExecution like:
        if(shorttrade==true && Position.MarketPosition!=MarketPositioni.Short) (then do reset my buttons and variables)

        This should work without issues because the bool is true from the trade, and when from OnExecution its flat then do....

        Would you confirm this? Or is there another way as well?

        Thank you!
        Tony

        Comment


          #5
          Hello tonynt,

          I am not certain what the overall goal is here or what existing logic you have used to answer this with any accuracy.

          My best suggestion would be to just try it and see what the result is on your end. The worst case will be that it does not work as you expect and you need to rethink the approach. If it does not work, I would likely need to see what code you used to better understand what needs reset at what time.

          If the bool you created is being set when the order is submitted and not reset until after the order fills, it is likely this could work. You can always use Prints to confirm the conditions you create work as expected also.


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

          Comment


            #6
            Hello,

            I think I forgot an important information why I need OnExecution (or OnOrderUpdate). I want to have the scripts running on COBCtrue (often frozen in NT7, so I switched from COCfalse to COBCtrue). Therefore I need outside onbarupdate the code to work fast before bars are closed. I want to reset the trade buttons and variables immediately with final target or stop. Maybe this information gives you the reason.

            Best regards
            Tony

            Comment


              #7
              Hello tonynt,

              The COBC setting would only matter if you are using OnBarUpdate but you have already noted you wanted to avoid using OnBarUpdate and wanted to use OnExecution instead.

              I want to reset the trade buttons and variables immediately with final target or stop
              OnExecution would be the best location for this type of logic as you have already concluded. Testing and using Prints will be most helpful for this question, seeing the direct outcome of your test will be able to answer if the changes you had proposed will work or not in contrast to the logic you have now. The sample I provided in post #2 would be a good point to do a reset upon an entry fill, you could recreate the same kind of logic but instead looking for the target/stop if you wanted.

              Additionally I see you have now mentioned NT7 but we are in the NT8 forum, which version of the platform are you asking about?

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

              Comment


                #8
                Hello,

                I refer to NT8 with "NT8 OnExecution status" because in NT7 it was frozen often.

                Thank you for your support!
                Tony

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by algospoke, Yesterday, 06:40 PM
                2 responses
                20 views
                0 likes
                Last Post algospoke  
                Started by ghoul, Today, 06:02 PM
                3 responses
                14 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by jeronymite, 04-12-2024, 04:26 PM
                3 responses
                45 views
                0 likes
                Last Post jeronymite  
                Started by Barry Milan, Yesterday, 10:35 PM
                7 responses
                21 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by AttiM, 02-14-2024, 05:20 PM
                10 responses
                181 views
                0 likes
                Last Post jeronymite  
                Working...
                X