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

Trying to close multiple ATM strategies.

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

    Trying to close multiple ATM strategies.

    Hi there,

    I have developed strategy that draws buttons on Chart Trader and those buttons all buttons works fine now.
    Currently when I click on buy or sell buttons and open market position it closes all other positions and also deletes all pending orders.(code line: 821-882)
    But my issue is that when I place Limit or Stop orders and when it is executed I want same behavior from bot as when clicking on buy or sell orders.(code line: 884-996)
    I know that issues is in strategy IDs but I couldn't found fix for it so if anybody can help me and edit my code that will be wonderful.

    P.S. in code I have created region called: NEED HELP on line 819 so you can easily find part what requires fix.

    Thanks in advanced.
    Attached Files

    #2
    Hello Revazi123,

    Thank you for your post.

    Please provide a brief description of what is specifically not working in your script.

    Is there a collection you are trying to get a value from and the value is not in the collection?

    Is an order being submitted at an unexpected time?

    Is an order being cancelled at an unexpected time?

    What specific object, method, or property are you stuck with?

    Thanks in advance, I look forward to further assisting.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_BrandonH View Post
      Hello Revazi123,

      Thank you for your post.

      Please provide a brief description of what is specifically not working in your script.

      Is there a collection you are trying to get a value from and the value is not in the collection?

      Is an order being submitted at an unexpected time?

      Is an order being cancelled at an unexpected time?

      What specific object, method, or property are you stuck with?

      Thanks in advance, I look forward to further assisting.
      Hi thanks for your reply,

      As I have explained above my issues is then when some pending order is that buystop, sellstop, buylimit or selllimit is executed I want all positions closed(if exists) and all pending orders deleted(if exists).
      I mean for example I have Buy position currently and have places 2 pending orders buy stop and sell stop. after some time one of those stop orders got executed(price hits it) for example Buy Stop order got executed I want previous buy market order to be closed and pending sell stop order to be deleted. Thats my issue.
      Current code works fine with market orders I mean for example I have 1 Buy position and 2 pending orders Buy stop and sell stop if I click on for example buy button to open buy market position this code deletes previos buy position and also deletes both pending orders.

      Waiting for your reply.
      Thanks you.

      Comment


        #4
        Hello Revazi123,

        Thank you for that information.

        Something you could do is subscribe to Account OrderUpdate events to see when one of the orders fills. If you are tracking all of the ATM strategy IDs you create, you could loop through your list and call AtmStrategyClose on those ATM strategies.

        If you are wanting to cancel an entry order, you could use AtmStrategyCancelEntryOrder. Please note that the order ID's would have to be tracked for those entry orders.

        See the help guide links below for more information.

        Account OrderUpdate events - https://ninjatrader.com/support/help...rderupdate.htm
        AtmStrategyClose - https://ninjatrader.com/support/help...ategyclose.htm
        AtmStrategyCancelEntryOrders - https://ninjatrader.com/support/help...ategyclose.htm

        Let us know if we may further assist.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_BrandonH View Post
          Hello Revazi123,

          Thank you for that information.

          Something you could do is subscribe to Account OrderUpdate events to see when one of the orders fills. If you are tracking all of the ATM strategy IDs you create, you could loop through your list and call AtmStrategyClose on those ATM strategies.

          If you are wanting to cancel an entry order, you could use AtmStrategyCancelEntryOrder. Please note that the order ID's would have to be tracked for those entry orders.

          See the help guide links below for more information.

          Account OrderUpdate events - https://ninjatrader.com/support/help...rderupdate.htm
          AtmStrategyClose - https://ninjatrader.com/support/help...ategyclose.htm
          AtmStrategyCancelEntryOrders - https://ninjatrader.com/support/help...ategyclose.htm

          Let us know if we may further assist.
          Hi again,

          I asked to help with code. I have read those posts and tried to make change but couldn't do If you can please help me and check my code.

          Thanks and waiting for your reply. I you can't help let me know that too. Thanks again

          Comment


            #6
            Okay if editing my code is to big work for you and it is of course as code is big can you please make very simple example ATM strategy which will work like this:
            open 1 market position for example buy and place 2 pending positions for example buystop and sellstop. and when one of those pending order will be executed then close previous buy position and delete remaining stop order. Just this please and I will then read your code understand it and fix my bug.

            Thank you and I am waiting for your reply. Thanks again

            Comment


              #7
              Hello Revazi123,

              Thank you for your note.

              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.

              That said, I am happy to answer any specific questions you may have. For example, do you have a proposed solution after exploring the problem and don't understand how to get there? What is happening in the script that shouldn't be or what isn't happening that should be?

              Please let us know if we may assist further.
              Brandon H.NinjaTrader Customer Service

              Comment


                #8
                Lots of time i and many begginers get such support. Even yesterday one of your support team member gave me small code example about different issue. I am not asking you to fix my code I ask you make very simple example ATM strategy which will work like this:
                open 1 market position for example buy and place 2 pending positions for example buystop and sellstop. and when one of those pending order will be executed then close previous buy position and delete remaining stop order. Just this please and I will then read your code understand it and fix my bug.

                Comment


                  #9
                  So please help me I am asking small simple script. Please

                  Comment


                    #10
                    Hello Revazi123,

                    Thank you for your note.

                    See the attached example script which demonstrates entering a long position followed by placing a buy stop limit order and a sell stop limit order. When one of the stop limit orders are hit, the other is canceled.

                    Please note that the AtmStrategy methods are very limited and rely on the ATM Strategy templates being used. If the template doesn't accomplish your goal, I suggest using the managed or unmanaged approach instead.

                    Let us know if we may assist further.
                    Attached Files
                    Brandon H.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by helpwanted, Today, 03:06 AM
                    1 response
                    10 views
                    0 likes
                    Last Post sarafuenonly123  
                    Started by Brevo, Today, 01:45 AM
                    0 responses
                    9 views
                    0 likes
                    Last Post Brevo
                    by Brevo
                     
                    Started by aussugardefender, Today, 01:07 AM
                    0 responses
                    5 views
                    0 likes
                    Last Post aussugardefender  
                    Started by pvincent, 06-23-2022, 12:53 PM
                    14 responses
                    242 views
                    0 likes
                    Last Post Nyman
                    by Nyman
                     
                    Started by TraderG23, 12-08-2023, 07:56 AM
                    9 responses
                    387 views
                    1 like
                    Last Post Gavini
                    by Gavini
                     
                    Working...
                    X