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 Belfortbucks, Today, 09:29 PM
              0 responses
              6 views
              0 likes
              Last Post Belfortbucks  
              Started by zstheorist, Today, 07:52 PM
              0 responses
              7 views
              0 likes
              Last Post zstheorist  
              Started by pmachiraju, 11-01-2023, 04:46 AM
              8 responses
              151 views
              0 likes
              Last Post rehmans
              by rehmans
               
              Started by mattbsea, Today, 05:44 PM
              0 responses
              6 views
              0 likes
              Last Post mattbsea  
              Started by RideMe, 04-07-2024, 04:54 PM
              6 responses
              33 views
              0 likes
              Last Post RideMe
              by RideMe
               
              Working...
              X