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 overide DefaultQuantity in ATM template

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

    How to overide DefaultQuantity in ATM template

    How do I change the DefaultQuantity when using AtmStrategyCreate and an ATM template?
    I tried adjusting it in Initialize(), but that didn't work.
    My adjusted value does show in a Print() statement, though.
    I tried altering UI "set order quantity" to default quantity and that didn't work.
    Is there some combination of settings I missed?
    The current ATM template has the Order Qty value of 100, but I always want to change it prior to ATMStrategyCreate().
    I would also like to change the stop and target values, similarly.
    I am only using STOP1 and TARGET1
    The NinjaTrader help file implies that this variable can be adjusted from within a strategy
    "An order size variable that can be set either programmatically or overriden via the Strategy that determines the quantity of an entry order."
    But the suggested fix didn't work when i used my desired value.
    protected override void Initialize()
    {
    DefaultQuantity = 1;
    }

    #2
    Hello roland_nt,

    Thanks for your post.

    Regrettably you cannot change the default quantity in an ATM strategy from an automated strategy in Ninjascript. The method you referenced (DefaultQuantity) would be applicable only to non ATM based strategies. There are other methods that also do not apply when using ATM strategies though Ninjascript, please review: http://ninjatrader.com/support/helpG...strategies.htm

    To change the stop and/or profit targets, you would use the method: AtmStrategyChangeStopTarget() please see description here: http://ninjatrader.com/support/helpG...stoptarget.htm

    Syntax: AtmStrategyChangeStopTarget(double limitPrice, double stopPrice, string orderName, string AtmStrategyId)

    Here is an example of changing a stop:
    AtmStrategyChangeStopTarget(0, Low[0] - 8 * TickSize, "Stop1", atmStrategyId);

    Here is an example of changing a profit target:
    AtmStrategyChangeStopTarget(High[0] +2 * TickSize, 0, "Target1", atmStrategyId);
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi Roland, did you ever find a way to change the ATM strtegy quantity? I found a way but requires changing the values in the template file, but i do not how to do it with Ninjascripting, so if you could help me i will really appreciate it.
      First i created a template file with three targets and saved it. In the template file you only need to put the numbers you want. Example, if only need one target, set the quantity of the other two to zero. There you can change the stop loss and take profit. See the image file i uploaded.
      Attached Files

      Comment


        #4
        Workaround to override the ATM Strategy Quantity by RoBott

        Here is my solution to override the quantity of an ATM Strategy: Upload the code and modify according to your strategy.

        I used a code i downloaded from this forum (LONGSHORTToolbarButtonsB9) as a base for this workaround, and so here i'm paying back with it.

        The workaround requires an ATM Template named "ATM3Targets.txt" (attached here, together with the code) in my case i located it into the documents folder.

        The script will use this template and replace the TAGS for TARGET1's QUANTITY1, STOPLOSS1, TAKEPROFIT1 (and so on for targets 2 and 3). Once replaced this tags with the appropriate values, it will create/replace a template file with the same name (but with extension xml) in the ATMStrategy folder where NinjaTrader 8 expects it.

        Fortunately for all of us needing this solution, NinjaTrader 8 reads the ATM template files each time it is called from within the ninjascript strategy.

        I hope you like it and find it useful.

        I'm not a programmer so you will find my coding very basic and will appreciate it if you can improve it and upload it here.

        Best regards,

        RoBott.
        Attached Files

        Comment


          #5
          Code to stop ATM the strategy with the Exit buttons

          Originally posted by robott View Post
          Here is my solution to override the quantity of an ATM Strategy: Upload the code and modify according to your strategy.

          I used a code i downloaded from this forum (LONGSHORTToolbarButtonsB9) as a base for this workaround, and so here i'm paying back with it.

          The workaround requires an ATM Template named "ATM3Targets.txt" (attached here, together with the code) in my case i located it into the documents folder.

          The script will use this template and replace the TAGS for TARGET1's QUANTITY1, STOPLOSS1, TAKEPROFIT1 (and so on for targets 2 and 3). Once replaced this tags with the appropriate values, it will create/replace a template file with the same name (but with extension xml) in the ATMStrategy folder where NinjaTrader 8 expects it.

          Fortunately for all of us needing this solution, NinjaTrader 8 reads the ATM template files each time it is called from within the ninjascript strategy.

          I hope you like it and find it useful.

          I'm not a programmer so you will find my coding very basic and will appreciate it if you can improve it and upload it here.

          Best regards,

          RoBott.
          If somebody can please help me with the code i would need so when i click on the appropriate exit button, it cancels the ATM Strategy without stopping the automated strategy (like usinf stop with middle/wheel button in the mouse in chart trader), i will really appreciate it.

          Comment


            #6
            Hello robott,

            Thanks for your posts and welcome to the NinjaTrader forums.

            To close an ATM you can use AtmStrategyClose(string AtmStrategyId).

            Reference: https://ninjatrader.com/support/help...ategyclose.htm
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Thank you Paul, my test strategy is working, now i will work to complete my project.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by jclose, Today, 09:37 PM
              0 responses
              5 views
              0 likes
              Last Post jclose
              by jclose
               
              Started by WeyldFalcon, 08-07-2020, 06:13 AM
              10 responses
              1,414 views
              0 likes
              Last Post Traderontheroad  
              Started by firefoxforum12, Today, 08:53 PM
              0 responses
              11 views
              0 likes
              Last Post firefoxforum12  
              Started by stafe, Today, 08:34 PM
              0 responses
              11 views
              0 likes
              Last Post stafe
              by stafe
               
              Started by sastrades, 01-31-2024, 10:19 PM
              11 responses
              169 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Working...
              X