Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Customizing the "SampleAtmStrategy"

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

    Customizing the "SampleAtmStrategy"

    I wanted the ability to utilize "Stop strategy" within the "ATM strategy" within my custom strategy and have done so successfully.
    My issue is now that my custom strategy, based on the native "SampleAtmStrategy" fails to allow for unique/multiple entries.

    I copied the following lines from my working multi-entry strategy but this wasn't the solution:

    EntriesPerDirection = 1;
    EntryHandling = EntryHandling.UniqueEntries;
    TimeInForce = TimeInForce.Gtc;
    StopTargetHandling = StopTargetHandling.PerEntryExecution;


    Please advise and thank you,

    #2
    Hello larkmail, thanks for writing in.

    Setting up unique ATM IDs will be more important than the entries per direction property because launching an ATM through a strategy submits the order through the NInjaTrader core. To get multiple entries with ATM strategies you need a unique atmStrategyId and orderId for each entry, then you can partition your entries with the unique variables. I recommend testing your strategy in the Playback Connection. That way you can pause and rewind your entry signal location over and over to test your strategy's behavior.

    Please let me know if I can assist any further.

    Comment


      #3
      Chris,
      That did the trick. Thank you.
      I'm wanting to make sure i understand the functions that occur once implemented; mainly, does the primary strategy, once executed, run independent of the ATM strategy?

      e.g.
      A position or two fill via the primary strategy, thus binding the ATM strategy to each trade executed via the "AtmStrategyCreate" script.
      Can I now close the primary strategy down while the ATM continues independently or must the primary strategy be left running as well?

      Comment


        #4
        Hello, thanks for your reply.

        The ATM does run independently of the strategy. Notice the strategy position stays flat and the strategy goes out of sync when a position with an ATM is submitted. The strategy does not manage that position after that point.

        Kind regards,
        -ChrisL

        Comment


          #5
          Thanks Chris,

          Is there a way to enforce time constraints on the ATM strategies (e.g. production executions between 0930 and 1600, otherwise hold stop-loss, etc. positions)?
          Is there a way to use a stop loss limit within the "Stop strategy" of an "ATM Strategy"?
          If so, is there a way to bind the limit pricing to an indicator?

          Comment


            #6
            Hello larkmail, thanks for your reply.

            There is an example here demonstrating a time filter implementation:

            https://ninjatrader.com/support/help...to_limit_t.htm - Using a time filter to limit trading hours

            https://ninjatrader.com/support/help...the_beginn.htm - Resetting values at the beginning of new trading sessions

            For your other questions:
            Is there a way to use a stop loss limit within the "Stop strategy" of an "ATM Strategy"?
            If so, is there a way to bind the limit pricing to an indicator?

            If you wanted the stop loss order the be of type "stop limit" instead of "stop market", expand the "More" section of the ATM template the strategy is using and select the "Stop limit for stop loss" option then save the template.

            To attach the stop loss order to an indicator, you must use the AtmStrategyChangeStopTarget() method to change the price after the stop and target are submitted.

            Kind regards,
            -ChrisL

            Comment


              #7
              Chris,
              Thanks, as usual.

              I maybe wrong but, isn't the SampleTimeFilter only effecting the core strategy and not the ATM?

              E.g. the strategy is confined to the time constraints for execution but, should it execute and be tied to an ATM, the ATM will proceed to perform (execute "stop loss" targets) outside of the constraints.

              If i'm misunderstanding, apologies. If that's correct, is there a way to slave the ATM to said constraints?

              Comment


                #8
                Hello larkmail, thanks for your reply.

                Please see all of the available ATM strategy methods documented here:
                https://ninjatrader.com/support/help...gy_methods.htm

                To exit the strategy after the time period is passed, you can check the position with GetAtmStrategyMarketPosition() and if it is not flat, use AtmStrategyClose() to exit out of the ATM.

                Please let me know if I can assist any further.

                Comment


                  #9
                  So, I've attempted several different methods of restricting the running "stop strategies" within the running ATM's but can't seems to get a running ATM to abide by any restrictions (e.g. ONLY proceeding with strategies during "US Equites RTH").

                  Is there an example of this anywhere i could review? Not to be confused with "Using a time filter to limit trading hours" which looks to only effect the core NJ Strategies.

                  Thanks,

                  Comment


                    #10
                    Hello larkmail, thanks for your reply.

                    A stop strategy does not have any time restricting properties. The strategy must look at the time stamps coming from the bar series and make trading decisions from there.

                    Please let me know if I can assist any further.

                    Comment


                      #11
                      Would you happen to have or know where to find a scripted example of governing a "stop strategy" via time stamp restrictions?
                      I see and can script/govern the core strategy but see no way of scripting anything regarding the "stop strategy".
                      Only the "ATM Strategy Methods" that you mentioned above and those, from what i understand, only initiate the ATM but the "stop strat" looks to be a sub-function of the ATM.

                      Comment


                        #12
                        Hello larkmail, thanks for your reply.

                        The Stop Strategy is part of the pre-defined ATM template, so it would not be able to get modified within a script. In a strategy script, you can control the time at which ATM strategies are submitted, but changing the template through code is not supported at this time. It would require the use of the XMLDocument class (publicly available link) to change the template within Documents\NinjaTrader 8\templates\AtmStrategy.

                        Kind regards,
                        -ChrisL

                        Comment


                          #13
                          Chris, let me ask you this; any adverse effects from me simply disconnecting data services from the running "stop strategies" in the afternoon and simply reconnecting in the AM or would this break the active stop strats?

                          Comment


                            #14
                            Hello larkmail, thanks for your reply.

                            The orders would still be resting on your account on your broker's end. You could turn off the data source to let your stops sit and then re-activate the data connection to start the stop strategy again. This would not be considered a "common use case", so use at your own risk.

                            Kind regards.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by NullPointStrategies, Today, 05:17 AM
                            0 responses
                            49 views
                            0 likes
                            Last Post NullPointStrategies  
                            Started by argusthome, 03-08-2026, 10:06 AM
                            0 responses
                            126 views
                            0 likes
                            Last Post argusthome  
                            Started by NabilKhattabi, 03-06-2026, 11:18 AM
                            0 responses
                            67 views
                            0 likes
                            Last Post NabilKhattabi  
                            Started by Deep42, 03-06-2026, 12:28 AM
                            0 responses
                            42 views
                            0 likes
                            Last Post Deep42
                            by Deep42
                             
                            Started by TheRealMorford, 03-05-2026, 06:15 PM
                            0 responses
                            46 views
                            0 likes
                            Last Post TheRealMorford  
                            Working...
                            X