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 cmtjoancolmenero, Yesterday, 03:58 PM
              11 responses
              39 views
              0 likes
              Last Post cmtjoancolmenero  
              Started by FrazMann, Today, 11:21 AM
              0 responses
              5 views
              0 likes
              Last Post FrazMann  
              Started by geddyisodin, Yesterday, 05:20 AM
              8 responses
              52 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by DayTradingDEMON, Today, 09:28 AM
              4 responses
              26 views
              0 likes
              Last Post DayTradingDEMON  
              Started by George21, Today, 10:07 AM
              1 response
              22 views
              0 likes
              Last Post NinjaTrader_ChristopherJ  
              Working...
              X