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

Price of contract

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

    Price of contract

    Hi,

    I've been trying to develop an automatic position size within my code and the way I intend to program this is by taking the available amount in cash of my account and dividing by the contract price to see how many contracts I am able to enter with.
    For instance, let's say I have $5000 in my account and each contract costs $700, hence the number of contracts would be 5000/700 = 7 contracts.
    I know how to get the cash value of the account by using Account.Get(AccountItem.CashValue, Currency.UsDollar), but then how can I get the price of each contract for a particular instrument and use this value as a divisor for the cash?

    Thanks a lot,
    Eddie

    #2
    Are you talking about the Intraday Margin requirements imposed on each contract by your broker?

    Who's your broker?
    Last edited by bltdavid; 04-18-2021, 10:16 AM.

    Comment


      #3
      Yes, my broker is GFF/Ironbeam

      Comment


        #4
        You're wading into the deep dark world of margins, and it can get a bit tricky.

        The Initial Margin is set by the exchange (this is the amount you need to hold the
        security "overnight", which is typically just the 1-hour break in-between sessions).

        Intraday Margin is a broker thing and is subject to change.

        Good introduction here.

        Study Account information here and here.
        If this code is for a Strategy, study this, too.

        I presume if your broker changes the Intraday Margin for your account (which
        can happen in times of high volatility), the idea is that OnAccountItemUpdate
        would tell you such a change has occurred -- but I'm not sure if that's true, or
        how reliable it would be for your broker, so NT Support will need to confirm.

        Good luck!

        PS: It might be faster & wiser to just create an input parameter and define
        the value as a property of your Strategy. Then check with your broker on
        the current Intraday Margin for the instrument you wish to trade ... and just
        enter the value into the property grid when setting up your strategy.


        Comment


          #5
          Originally posted by bltdavid View Post
          The Initial Margin is set by the exchange (this is the amount you need to hold the
          security "overnight", which is typically just the 1-hour break in-between sessions).
          Just an fyi --
          Saying "overnight" is archaic -- today's terminology is "past the close".

          Comment


            #6
            Originally posted by bltdavid View Post

            PS: It might be faster & wiser to just create an input parameter and define
            the value as a property of your Strategy. Then check with your broker on
            the current Intraday Margin for the instrument you wish to trade ... and just
            enter the value into the property grid when setting up your strategy.

            Thanks a lot bltdavid
            Actually, I've already done that. I placed the position size into a property and change it manually every time.
            The ideal condition though, would be the program updating this automatically (since it's an automated strategy, I should not have to input anything, right!?!), but now, I am not so sure this would be safe enough to leave it running on its own. If this is possible through some NT object it would be the ultimate for me, but even so, I would monitor its behavior for a while until I make sure it works.

            Thank you so much for all the links, I will make sure to visit them all. Meanwhile, I think someone from Tech Support may reply and add to this post, I will be waiting.

            Comment


              #7
              You're welcome.

              Another question for Support becomes obvious after studying
              the organization of the Account object.

              To Support:
              OP wants IntradayMargin on a per instrument basis, so that he can
              perform his position sizing calculations. But it looks like that item value
              available in Account (also called IntradayMargin) does not represent
              a per instrument value, but some kind of aggregate value for the entire
              account, is that correct? I mean, how does that value relate to the per
              instrument value the OP seeks?
              Last edited by bltdavid; 04-18-2021, 05:16 PM. Reason: fix typo

              Comment


                #8
                Hello Eddie and bltdavid,

                There is nothing supported to get the equivalent of what would be in the Risk templates (which can be applied to Sim accounts) for individual instruments.

                I am happy to submit a feature request on this and will provide a tracking ID once I have received this.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Sounds good to me
                  Thanks a lot Chelsea.

                  Comment


                    #10
                    Hello,

                    This request for Intra-day margin per instrument is being tracked with ID# SFT-5244.

                    Please note, we receive many requests and cannot reasonably implement all requested features or changes. Interest is tracked internally and if enough interest is tracked, it would be weighed against how feasible it would be to make those changes to consider implementing, so we cannot offer an ETA or promise of fulfillment.

                    When new features are implemented, they will be listed in the Release Notes page of the Help Guide. The ID number may be different than the internal feature request tracking ID, but the description of the feature will let you know if that feature has been implemented.

                    Release Notes - https://ninjatrader.com/support/help...ease_notes.htm
                    Chelsea B.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by arvidvanstaey, Today, 02:19 PM
                    4 responses
                    11 views
                    0 likes
                    Last Post arvidvanstaey  
                    Started by samish18, 04-17-2024, 08:57 AM
                    16 responses
                    61 views
                    0 likes
                    Last Post samish18  
                    Started by jordanq2, Today, 03:10 PM
                    2 responses
                    9 views
                    0 likes
                    Last Post jordanq2  
                    Started by traderqz, Today, 12:06 AM
                    10 responses
                    18 views
                    0 likes
                    Last Post traderqz  
                    Started by algospoke, 04-17-2024, 06:40 PM
                    5 responses
                    48 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Working...
                    X