Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Call ATM in Strategy - working (simple) example needed

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

    Call ATM in Strategy - working (simple) example needed

    Hi,

    I have designed some quite basic strategies with the Strategy Builder. Now I would like to implement an "ATM template" (that has trailing stop and take profit defined) into a strategy.

    I though have no clue howto call the ATM in a strategy that I have built. Could anyone kindly show me an working example with an strategy that uses an ATM inside?

    Thanks in advance!

    br,
    Christian

    #2
    Hello Christian,

    Thanks for your post.

    The strategy builder does not contain an interface to work with ATM strategies.

    To work with an ATM template within a strategy you would need to work directly in Ninjascript code. Here is a link to the methods that are available in Ninjascript for working directly with an ATM template: http://ninjatrader.com/support/helpG...gy_methods.htm

    To further assist, in your NinjaTrader platform is an example strategy that demonstrates the coding needed to use an ATM strategy template. The strategy is named SampleATMstrategy. The sample is documented in the code section to clarify how it all works. To use the example strategy you would need to create a an ATM template called "AtmStrategyTemplate" with profit and stop targets you define. The example only enters long orders and is intended as an example only.

    Comment


      #3
      Hi,

      Thanks for the reply!

      I had a look at the sample last week but I could not understand based on what it will take on a long entry?

      For example, if I had an simple MA cross over strategy, that is takin long position when price crosses over a moving average, how would such a strategy with an ATM look like?

      br,
      Christian

      [EDIT] Found an example here: http://ninjatrader.com/support/helpG...gy_methods.htm

      [EDIT2] I guess the code below will enter long when price cross above MA20 and then use MyTemplate ATM for managing the position?

      Code:
      private string atmStrategyId;
      private string atmStrategyOrderId;
      private bool   isAtmStrategyCreated = false;
       
      protected override void OnBarUpdate()
      {
        if (State < State.Realtime)
            return;
       
        if (Close[0] > SMA(20)[0])
        {
            atmStrategyId = GetAtmStrategyUniqueId();
            atmStrategyOrderId = GetAtmStrategyUniqueId();
       
            AtmStrategyCreate(OrderAction.Buy, OrderType.Market, 0, 0, TimeInForce.Day,
                atmStrategyOrderId, "MyTemplate", atmStrategyId, (atmCallbackErrorCode, atmCallbackId) => {
       
                // checks that the call back is returned for the current atmStrategyId stored
                if (atmCallbackId == atmStrategyId)
                {
                    // check the atm call back for any error codes
                    if (atmCallbackErrorCode == Cbi.ErrorCode.NoError)
                    {
                        // if no error, set private bool to true to indicate the atm strategy is created
                        isAtmStrategyCreated = true;
                    }
                }
            });
        }
       
        if(isAtmStrategyCreated)
        {
            // atm logic
        }
       
        else if(!isAtmStrategyCreated)
        {
            // custom handling for a failed atm Strategy
        }
      }
      Last edited by suroot; 04-10-2017, 07:28 AM.

      Comment


        #4
        Hello Christian,

        Thanks for your reply.

        In the SampleATMStrategy the entry in this condition: if (orderId.Length == 0 && atmStrategyId.Length == 0 && Close[0] > Open[0]) Where it is verifying that any previous order has been reset to 0 and that the entry condition is if the Close is greater than the open, so basically on any upbar. You could replace Close[0] > Open[0] with your specific entry conditions.

        Regarding your edits, yes crossabove SMA(20) is the entry condition and yes it would need an ATM template called MyTemplate to manage the exits.

        Comment


          #5
          Hello, I have a question.
          If I want many entries, at that case, what about this?
          How can it manage them?
          Thanks.

          Comment


            #6
            Hello truepenny,

            Thank you for your inquiry.

            You can manage your entries via the Atm Strategy Monitoring methods, and manage them using the Atm Strategy Management methods, listed on this page:



            All methods take a unique OrderId or AtmStrategyId parameter which can be used to manage and monitor specific orders.

            Please let us know if you have any further questions.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            58 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            133 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            73 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