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

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 judysamnt7, 03-13-2023, 09:11 AM
          4 responses
          59 views
          0 likes
          Last Post DynamicTest  
          Started by ScottWalsh, Today, 06:52 PM
          4 responses
          36 views
          0 likes
          Last Post ScottWalsh  
          Started by olisav57, Today, 07:39 PM
          0 responses
          7 views
          0 likes
          Last Post olisav57  
          Started by trilliantrader, Today, 03:01 PM
          2 responses
          22 views
          0 likes
          Last Post helpwanted  
          Started by cre8able, Today, 07:24 PM
          0 responses
          10 views
          0 likes
          Last Post cre8able  
          Working...
          X