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

Entering Position Based on Percentage of Account

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

    #16
    Hello CoopersFX,

    You could use Math.Floor to round down to the nearest integer.

    I have attached a sample strategy which will calculate 2 percent of your account size, divide that by the currency price, then divide by 1000 and round down to give you how many micro lots to purchase.

    If you were applying this to something which doesn't have the quote currency in USD, for example JPYUSD, extra consideration would need to be made to line 80 within the code.

    The strategy was written in NT8 thus will not work in NT7, however demonstrates the logic for how you would calculate what you're looking for.

    Please let us know if you need further assistance.
    Attached Files
    Alan P.NinjaTrader Customer Service

    Comment


      #17
      Hello!
      That was helpful, but I don´t understand why I still get the "Not Enough Excess Margin" when I am trading with so small amounts.
      How do I check for that, by Position? Do I need to stop the strategy and cancel all orders?
      My Playback account is on $5.000.

      Comment


        #18
        Hello,

        If you had working orders that could cause this issue.

        I would suggest setting your playback account to 100k and retesting.

        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment


          #19
          Greetings,

          I'm looking to do the same thing. I have NT8 strategies that will trade EURUSD.

          "If you were applying this to something which doesn't have the quote currency in USD, for example JPYUSD, extra consideration would need to be made to line 80 within the code." --- Can you please tell me exactly what I'd need to do to make this work? I have no coding experience, so a For Dummies version would be great.

          With that in mind, can you please recommend a highly competent coder I might hire to do this if I decide I'm in over my head?

          Comment


            #20
            Hello Ranger Brad,

            Thank you for your post.

            I talked to Alan regarding what he meant by extra consideration. He stated the strategy takes account size *2 percent to get the betsize, then to determine how much AUD/USD to buy it divides betsize by the AUD/USD rate. If the currency pair was quoted USD/JPY rather than JPY/USD, you would want to divide (1/(JPY/USD)). So you'd be okay since your pair is quoted EURUSD.

            CME quotes currencies FX/USD, but often the yen is quoted USD/JPY, which is just the inverse.

            As far as getting recommendations for NInjaScript Consultants, please write into our main support email at platformsupport[at]ninjatrader[dot]com and we'd be happy to provide you with some options.

            Please let us know if we may be of further assistance to you.
            Kate W.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by gravdigaz6, Today, 11:40 PM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by MarianApalaghiei, Today, 10:49 PM
            3 responses
            10 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by XXtrader, Today, 11:30 PM
            0 responses
            4 views
            0 likes
            Last Post XXtrader  
            Started by love2code2trade, Yesterday, 01:45 PM
            4 responses
            28 views
            0 likes
            Last Post love2code2trade  
            Started by funk10101, Today, 09:43 PM
            0 responses
            9 views
            0 likes
            Last Post funk10101  
            Working...
            X