Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

order entry error

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

    order entry error

    Hi

    When I compile my strategy, for this line:

    EnterLongStopLimit(accountsize, SMA(50)[0] + 1 * TickSize, SMA(50)[0], "")

    an error message appears that says: the name "accountsize" does not exist in the current context. What's the right thing to enter in place of 'accountsize'?

    #2
    Hi Labonte,

    What are you looking for here?

    Are you looking for your cash balance?

    Are you wanting to calculate the number of contracts that can be made with a given dollar amount? (this is done in the strategy parameters not in the code and would require that you use DefaultQuantity here)
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea - I'd like it to calculate how many shares to buy with a specified account size. Also, I entered "defaultQuantity" in place of accountsize - however this too generated an error

      Comment


        #4
        what should "accountsize" be replaced with, so that it calculates how many shares to buy, using percent of buying power and a nominal dollar value?

        Comment


          #5
          Hello Labonte,

          C# is case sensitive. DefaultQuantity does not equal defaultQuantity.

          http://ninjatrader.com/support/helpG...ltquantity.htm

          Attached is a screenshot of using the by Account size option. This allows you to type in a dollar amount that represents the account size and NinjaTrader will calculate the amount of shares that can be purchased with that amount.

          From the help guide:
          Sets how the order size is determined, options are:
          "by default quantity" - User defined order size
          "by strategy" - Takes the order size specified programmatically within the strategy
          "by account" - Allows you to set a virtual account value that is used to determine maximum order size based on margin settings per instrument set in the instrument manager

          http://ninjatrader.com/support/helpG...t_strategy.htm


          If you are wanting to poll your account and calculate the account size yourself without using this feature, this could be possible but take custom logic to achieve.

          You can loop through accounts with an undocumented account collection:
          foreach (Account acct in Cbi.Globals.Accounts)
          { }
          Attached Files
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          556 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          324 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          545 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X