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 andrewtrades, Today, 04:57 PM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by chbruno, Today, 04:10 PM
          0 responses
          5 views
          0 likes
          Last Post chbruno
          by chbruno
           
          Started by josh18955, 03-25-2023, 11:16 AM
          6 responses
          436 views
          0 likes
          Last Post Delerium  
          Started by FAQtrader, Today, 03:35 PM
          0 responses
          7 views
          0 likes
          Last Post FAQtrader  
          Started by rocketman7, Today, 09:41 AM
          5 responses
          19 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X