Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Limit strategy to a % of an account

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

    Limit strategy to a % of an account

    Say I have a new strategy and I want it to only run against a % of an account ( IB to be exact ). How would I accomplish that please.

    #2
    Hello stevenev,

    You would need to calculate this number either in your strategy code or manually before placing the quantity.

    You can check the account balance of a strategy in real time with:
    GetAccountValue(AccountItem.CashValue)

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

    You would then multiply this by a percentage value, convert to an int, then use this for the quantity when placing an order.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks, Chelsea. That would work great.

      steve

      Comment


        #4
        On 2nd thought, would this work? If the strategy is running against multiple symbols, then it could trigger multiple orders each as large as the % specified.

        I am thinking another way is to have a static (persistent) variable keeping track of what is being bought/sold per strategy. This would work if ninjascript could get hold of order status, i.e. bought or sold.

        Comment


          #5
          I see a reference to "Strategy Position" https://ninjatrader.com/support/help..._account_p.htm

          That would solve my problem if that could be used in ninjascript.

          Comment


            #6
            Hello stevenev,

            It would be possible to use a static variable but this would not be something I could assist with.

            You could write the value to a file and then read the value from other scripts.
            StreamWriter - http://www.ninjatrader.com/support/f...ead.php?t=3475
            StreamReader - http://www.ninjatrader.com/support/f...ead.php?t=3476

            Regarding the strategies position which is separate from the account position, this can be checked with the Position object. (The Position object refers to the strategy position and not the account position)

            Below is a link to the help guide on Position.
            http://ninjatrader.com/support/helpG...7/position.htm

            For example:

            if (Position.MarketPosition == MarketPosition.Long)
            {
            Print(Position.Quantity);
            }
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Thanks, Chelsea

              Position object is what I was looking/hoping for. All good. This should work very well.

              Regards, steve

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              75 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              45 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              26 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              32 views
              0 likes
              Last Post TheRealMorford  
              Started by Mindset, 02-28-2026, 06:16 AM
              0 responses
              62 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Working...
              X