Announcement

Collapse
No announcement yet.

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.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    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
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        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.
            <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

            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.
                <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                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.
                    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by NullPointStrategies, Yesterday, 05:17 AM
                    0 responses
                    64 views
                    0 likes
                    Last Post NullPointStrategies  
                    Started by argusthome, 03-08-2026, 10:06 AM
                    0 responses
                    139 views
                    0 likes
                    Last Post argusthome  
                    Started by NabilKhattabi, 03-06-2026, 11:18 AM
                    0 responses
                    75 views
                    0 likes
                    Last Post NabilKhattabi  
                    Started by Deep42, 03-06-2026, 12:28 AM
                    0 responses
                    45 views
                    0 likes
                    Last Post Deep42
                    by Deep42
                     
                    Started by TheRealMorford, 03-05-2026, 06:15 PM
                    0 responses
                    50 views
                    0 likes
                    Last Post TheRealMorford  
                    Working...
                    X