Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

defaulting strategy setup parameters in code

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

    defaulting strategy setup parameters in code

    Is there a way to define the "order properties" of a strategy in the code of that strategy ; when starting a new strategy, I have to manually set order properties to "by default quantity", it would be nice if that setting could be defaulted in the strategy-code. I know this can be done for "Calculate on bar close" but is it also possible for order properties in the strategy configuration window ?
    If yes, how can this be achieved ?

    Marco

    #2
    Marco, what you could do is set the default quantity in the strategy Initialize() - http://www.ninjatrader-support.com/H...tQuantity.html

    Comment


      #3
      Bertrand,

      I put
      Code:
       
      DefaultQuantity = 1;
      in the strategy Initialize() but unfortunately it doesn't seem to work.

      When I start the strategy and look under "Order Properties" in the setup window, I still see "Set order quantity: by strategy" in that field.
      I would like this field in default to be "Set order quantity: by default quantity" and "default quantity = 1 "

      Reason for this is that each time I start the strategy I have to alter these Order Properties settings by hand (and yes, sometimes forget to do so..). It would be very usefull to set and fixate the Order Properties from within the strategy code. Can this be done ?

      Marco

      Comment


        #4
        Hello Marcow,

        Unfortunately hard coding this value is not supported. You will have to change through the GUI.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          ahh, now I get it....

          in the variables section of the code I define a variable Contracts = 1
          And then in the Initialize() section defaultQuantity = Contracts

          When starting the strategy the variable Contracts will default at 1 as defined in the code, but still can be changed as desired.
          Order Properties field can now remain the default " by strategy" because DefaultQuantity is now set via the Contracts variable.

          thank you.
          Last edited by marcow; 05-16-2010, 12:48 PM.

          Comment


            #6
            Thanks for sharing a work-around to this, marcow! Glad you were able to get it sorted.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              wait !...

              after reading post #18 in this thread
              Support for the development of custom automated trading strategies using NinjaScript.


              I found a much more elegant solution using "QuantityType = QuantityType.DefaultQuantity" which is exactly what I was looking for

              Code:
              protected override void Initialize()
              {
              DefaultQuantity = 1;
              QuantityType = QuantityType.DefaultQuantity;
              TimeInForce = Cbi.TimeInForce.Day;
              }
              Marco

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              661 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              375 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              110 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              574 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              579 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X