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

How to Set ATMStrategy Parameters Runtime

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

    How to Set ATMStrategy Parameters Runtime

    Hello Everyone,

    I was needing to use the autotrail feature from my ninja script and just figured out that it wouldn't be possible without using an ATMStrategy. So I'm replacing order entry commands such as EnterLong() by AtmStrategyCreate(). Does that make sense?

    The ATMStrategy is already there, created and setup.

    Ok, if that makes sense, here goes the question: how can I setup some ATMStrategy Parameters on realtime, such as Order Quantity, Instrument and of course, the account, all that in my ninja script in runtime, for instance in Initialize() or even OnBarUpdate.

    Thank you

    Rodrigo

    #2
    Hello,

    Thank you for the question.

    When combining an ATM strategy and a strategy there are some differences such as the ATM strategy its self controls the quantity so this would not be able to be set from the strategy its self. You are essentially just telling the strategy to use an ATM strategy instead of the strategy entry methods.

    To control quantity you have a couple of options:

    you can create multiple ATM strategies with different quantity and call these when you want that quantity.
    you can have the strategy create multiple of the same strategy using different strategy ID's to add quantity using the same template.

    The instrument will be controlled by the chart or instrument you select when you start the strategy up.

    The Account can be choose through the strategy properties dropdown, unfortunately there is no supported way to set this through the script.

    I also wanted to mention the documentation here that lists all the methods you can use for ATM's http://www.ninjatrader.com/support/h...gy_methods.htm


    Please let me know if I may be of additional assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello,

      Thank you for the question.

      When combining an ATM strategy and a strategy there are some differences such as the ATM strategy its self controls the quantity so this would not be able to be set from the strategy its self. You are essentially just telling the strategy to use an ATM strategy instead of the strategy entry methods.

      To control quantity you have a couple of options:

      you can create multiple ATM strategies with different quantity and call these when you want that quantity.
      you can have the strategy create multiple of the same strategy using different strategy ID's to add quantity using the same template.

      The instrument will be controlled by the chart or instrument you select when you start the strategy up.

      The Account can be choose through the strategy properties dropdown, unfortunately there is no supported way to set this through the script.

      I also wanted to mention the documentation here that lists all the methods you can use for ATM's http://www.ninjatrader.com/support/h...gy_methods.htm


      Please let me know if I may be of additional assistance.
      Hello Jesse,

      Sorry the long time in responding back.

      So are you saying that there's no way I can start an ATM strategy via script with no manual intervention at all? My NT is all configured to run during the day without my intervention, but currently all that happens through script.

      Reason why I wanted to leverage the ATM strategy was to take advantage of the auto trail exit stop.

      Please let me know if you think I can make this happen, in other words start the ATM strategy from the script in runtime setting account, instrument and quantity without manual intervention?

      If you think that is not feasible or practical, what would you suggest? How can I simulate the auto trail without using ATM strategy? Is there any way I can do that via script without ATM? Or would you think I should be doing that manually though script , like checking prices on every bar and then taking a decision.

      Thanks,

      Rodrigo

      Comment


        #4
        Hello,

        Thank you for the update.

        I am not sure if I completely understand your question, what I had originally said is that you can use an ATM strategy from within your strategy but would only have limited control on the settings inside the ATM strategy its self from the parent strategy. You would need to use the methods in the help guide to control the ATM strategy and get information from it.


        So are you saying that there's no way I can start an ATM strategy via script with no manual intervention at all? My NT is all configured to run during the day without my intervention, but currently all that happens through script.
        Well this would still require you to initially start your strategy, the strategy will be controlling the ATM strategy as a form of entry logic but you would need to first enable the strategy for it to do anything.

        I believe you are asking if you can set it and forget it, when you are using an ATM strategy Alone, no. If you are controlling ATM strategies using a Strategy then yes, the Strategy will be acting as the brain, the ATM strategy would be working as the action that happens when you submit the order.

        Please let me know if I may be of additional assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Thank you, I think you're gonna have to help me with the details now..

          I'm using this to set instrument and account, on Initialize():
          Strategies.FindById("STOPPADRAO").Instrument = "WIN 02-15";
          Strategies.FindById("STOPPADRAO").Account = "DT-14427";

          Then on OnBarUpdate, when I decide to enter the market either long or short, I'll be using this:

          AtmStrategyCreate(OrderAction.Buy, OrderType.Market, 0, 0, TimeInForce.Day, GetAtmStrategyUniqueId(), "STOPPADRAO", GetAtmStrategyUniqueId());

          Question goes, at what moment do I set the order quantity? On initialize as well? What is the object and property where I can set the quantity?

          This is the last missing piece there, I believe. Please don't send me back to tutorials, the documentation below around this is pretty poor with only one example. I still can't understand why it uses it GetAtmStrategyUniqueId() twice as parameter, what is that really for.




          Please let me know... I appreciate the help.
          Last edited by rgaleote; 12-22-2014, 08:12 PM. Reason: grammar

          Comment


            #6
            Hello,

            Thank you for the reply.

            Question goes, at what moment do I set the order quantity? On initialize as well? What is the object and property where I can set the quantity?
            The supported method would be to set the quantity in the ATM strategy using either a Superdom or chart trader window. There is no supported method to do this via code.


            still can't understand why it uses it GetAtmStrategyUniqueId() twice as parameter, what is that really for.
            If you take a look at the example code you can see it is used twice for two separate variables which are used in the line right after they are assigned. Here is that line:

            Code:
            atmStrategyId = GetAtmStrategyUniqueId();
            orderId = GetAtmStrategyUniqueId();
            AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Limit, Low[0], 0, TimeInForce.Day, [B]orderId[/B], "AtmStrategyTemplate", [B]atmStrategyId[/B]);
            The ATM Strategy has a unique ID by calling GetAtmStrategyUniqueId and also you have created a unique ID for the orderID that is required by the overloads for AtmStrategyCreate

            please let me know if I may be of additional assistance.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by RideMe, 04-07-2024, 04:54 PM
            6 responses
            31 views
            0 likes
            Last Post RideMe
            by RideMe
             
            Started by tkaboris, Today, 05:13 PM
            0 responses
            2 views
            0 likes
            Last Post tkaboris  
            Started by GussJ, 03-04-2020, 03:11 PM
            16 responses
            3,281 views
            0 likes
            Last Post Leafcutter  
            Started by WHICKED, Today, 12:45 PM
            2 responses
            19 views
            0 likes
            Last Post WHICKED
            by WHICKED
             
            Started by Tim-c, Today, 02:10 PM
            1 response
            10 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X