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

AtmStrategyCreate for a given instrument

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

    AtmStrategyCreate for a given instrument

    Hello,

    is it possible to start an ATM Strategy for some instrument B within OnBarUpdate() of instrument A ?

    The method AtmStrategyCreate only offers a an "orderId" parameter, which is - according to the samples - just some unique id without a real order behind.




    Last edited by Derjan; 12-09-2021, 10:36 AM.

    #2
    Hello Derjan,

    Thanks for your post.

    You could add an additional data series to your script using AddDataSeries(). Then you could consider creating a condition that checks the BarsInProgress value of that series to see if that series is processing. Then, you would call your entry order method to place an order.

    For example, if there is 1 added series, you would check if BarsInProgress == 1, then call your entry order method to place an order.

    See the help guide documentation below for more information.
    AddDataSeries(): https://ninjatrader.com/support/help...=adddataseries
    BarsInProgress: https://ninjatrader.com/support/help...inprogress.htm
    Atm Strategy Methods: https://ninjatrader.com/support/help...gy_methods.htm

    Also, see this reference sample that demonstrates submitting orders to different bars object which you may find helpful: https://ninjatrader.com/support/help..._frame_and.htm

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

    Comment


      #3
      Thanks. But if I understand you correctly, the answer to my question is: No ? I can't use AddDataSeries as the instrument is not yet known at startup.

      I also tried

      Order order = Account.CreateOrder(instrumentB,...) and then AtmStrategyCreate(....,order.Order.Id,....)
      however only positions for the primary instrumentA are opened, although I specify instrumentB in CreateOrder

      Also from the docs for Account.CreateOrder for the parameter "name":

      "Note: If using ATM Strategy StartAtmStrategy(), this value MUST be "Entry""

      --> So one should be able to start an AtmStrategy for the specified instruement and the specified order ?

      Or can you attach an AtmStrategy afterwards programmatically, as you can do with a mouse right click on an entry in the "Positions" tab ?
      Last edited by Derjan; 12-09-2021, 12:59 PM.

      Comment


        #4
        Hello Derjan,

        Thanks for your note.

        It is possible to start a strategy on one data series and use AtmStrategyCreate() to place an order on another data series. To do so, you would use AddDataSeries() to add an additional data series to your script. Then you would check if BarsInProgress == 1 and call your Atm Strategy logic to place an order with an Atm Strategy template.

        See the modified version of SampleAtmStrategy attached which demonstrates this.

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

        Comment


          #5
          Ok, but as I wrote: the instrument is not yet known at startup (in OnStateChange), so I can't add the DataSeries in advance.
          So again, the answer to my question remains: No ?

          Then I'll modify my question a bit: Is it possible to programmatically attach an AtmStrategy afterwards to an order created using Account.CreateOrder and Account.Submit(). (It seems you can do this already manually with a mouse right click on an entry in the "Positions" tab)

          Comment


            #6
            Hello Derjan,

            Thanks for your note.

            We do not have any documentation to advise attaching an ATM strategy to an active order programmatically. Something you could consider doing is cancelling and replacing it.

            Let us know if we may assist further.
            Last edited by NinjaTrader_BrandonH; 12-10-2021, 10:41 AM.
            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              While I don't understand your suggestion "Replacing the (Account.CreateOrder) with an order has an ATM strategy", I got another idea which could solve my issue:

              Is it possible to programmatically start a strategy ? From anywhere, an AddIn, whatever.

              Comment


                #8
                Hello Derjan,

                Thanks for your note.

                Strategies cannot be started programmatically. NinjaScript strategies are only able to be started manually from the Strategies tab of the Control Center or from a Chart window.

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

                Comment


                  #9
                  Ok, so limited, but here is another try: Using AddIns:

                  Can I programmatically submit an order with an ATM Strategy attached for any instrument (which is not yet known when the AddIn initializes) from within an AddIn ?

                  Comment


                    #10
                    Hello Derjan,

                    Thanks for your note.

                    You would not be able to submit an order with an ATM strategy attached to an instrument that is not yet known. The instrument that the order is submitted to would need to be known to submit that order to the instrument.

                    Also, note the following from the AddDataSeries() help guide. Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided.

                    AddDataSeries(): https://ninjatrader.com/support/help...dataseries.htm

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

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by PaulMohn, Today, 05:00 AM
                    0 responses
                    7 views
                    0 likes
                    Last Post PaulMohn  
                    Started by ZenCortexAuCost, Today, 04:24 AM
                    0 responses
                    6 views
                    0 likes
                    Last Post ZenCortexAuCost  
                    Started by ZenCortexAuCost, Today, 04:22 AM
                    0 responses
                    3 views
                    0 likes
                    Last Post ZenCortexAuCost  
                    Started by SantoshXX, Today, 03:09 AM
                    0 responses
                    16 views
                    0 likes
                    Last Post SantoshXX  
                    Started by DanielTynera, Today, 01:14 AM
                    0 responses
                    5 views
                    0 likes
                    Last Post DanielTynera  
                    Working...
                    X