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

Adjusting trade size based on funds availability

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

    Adjusting trade size based on funds availability

    Hello,

    How do I obtain available funds/margin for entering a trade? I would like to the trade quantity based on available, usable funds.

    In looking at the Help documentation, is this correct?

    double buyingPower = Account.GetAccountItem(AccountItem.BuyingPower, Currency.UsDollar).Value;

    ​That seems like a lot of "extra" code to access an attribute on an account. Why doesn't the Account object have straightforward properties?

    Thanks,
    Matt

    #2
    Hello, thanks for writing in. Using the Account object is the correct way to access account values in the strategy. The method to access any account item is Account.Get()


    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hello Support / Chris,

      When I using this code to obtain the buying power in Playback, I'm getting 0.0. ​In the Control Panel, it clearly shows $100,000 for the Playback account.

      double buyingPower = Account.Get(AccountItem.BuyingPower, Currency.UsDollar);

      Is this the correct code to get the buying power for a given trade? That is, with this buyingPower variable, I want to determine the number of contracts I should trade (code not shown).
      If it is the correct code for live trading (I've not tested/confirmed yet), what the correct code for playback?

      Thanks,
      Matt

      Comment


        #4
        Hello Matt,

        Neither the Sim101 nor the Playback accounts provide a Buying power account item.

        Check the Accounts tab of the Control Center and you see the Buying power is 0 for the Playback account.

        However, the CashValue is available, and you can use this.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by dcriador, Yesterday, 10:45 AM
        3 responses
        27 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by SnailHorn, Yesterday, 10:49 PM
        2 responses
        13 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by cmtjoancolmenero, 04-29-2024, 03:40 PM
        26 responses
        85 views
        0 likes
        Last Post cmtjoancolmenero  
        Started by PaulMohn, Yesterday, 06:59 PM
        1 response
        23 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by milfocs, Yesterday, 07:23 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X