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

Position Size

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

    Position Size

    Hi,

    i want to calculate my position size, depending on the % of my capital I want to risk. So in other works, I want to create a user input/variable where I can specify % risk.

    Depending on the currency pair in Forex, the pip size will differ.

    When an order is sent I want to have the code look at the:

    currency pair selected
    calculate its pip size (USD per pip)
    use the stop loss pip size for that trade and then calculate the position size

    Obviously some exchanges only allow you to enter sizes of 100, 1000, 10000, 100000, so the calculation must round the position size to the nearest 1000.

    This value must then be used as a variable to enter a trade.

    Can someone assist with the necessary code for this, or even better through the strategy builder?

    regards

    Jacques

    #2
    Hello Induna,

    Thank you for your note.

    This would not be possible through the Strategy Builder, as you cannot access Account information with the Builder. You would need to code this manually.

    I do have an available example for a good portion of what you're looking for; however, this example assumes your account is in USD and you would need to modify it if your account is not in USD. I've actually modified the strategy so it allows you to set the percentage of account value to be used already, so you'd need to modify this to get the pip size and add your stop loss with that.

    TickSize may represent pip, half pip or tenth pip. You could perform some math on the currency pair to determine the pip size by multiplying the pip value by the lot size, and then to multiply by the conversion rate. This would be the pip size. Multiplying this by 20 would give the the size of 20 pips.

    Most pairs except Yen based FOREX pairs will have a pip value on 0.0001.

    There is not an immediate "pip size" property that can be used with NinjaScript and the math would have to be programmed into the strategy.

    More information on FOREX calculations can be referenced here - https://ninjatrader.com/support/help...latingPipValue

    If you are interested in services in having the code modified for you, I can have a representative of our EcoSystem reach out with more information on NinjaScript consultants who will be happy to do so.

    Please let us know if you have any additional questions.
    Attached Files
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Kate, this is great thank you. I will go through it and see how I can add it to my script. My account is in USD, so no need for conversions there. But i am sure some questions will arise in due course.

      Have a great day and thanks!

      Comment


        #4
        What would need to be done to convert something like EUR/GBP? At some point this would require the multiplication of the current price of GBP/USD. Does this require the adding of additional bar series to get that current price of GBPUSD?

        Is there an indicator out there that may accomplish this which can be referenced to obtain the pip value for both USD based pairs and non-USD pairs?

        Comment


          #5
          Hello forrestang,

          Thank you for your reply.

          Yes, you would need to add an additional GBP/USD series to convert something like EUR/GBP.

          I am unaware of any specific indicators that do this for you, nor am I able to recommend any specific third party vendors that offer such a calculator. You might try a quick online search, or perhaps one of our forum members here will chime in with something they've created or found.

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

          Comment


            #6
            Originally posted by [URL="https://ninjatrader.com/support/forum/member/89030-ninjatrader_kate"
            NinjaTrader_Kate[/URL]]Yes, you would need to add an additional GBP/USD series to convert something like EUR/GBP.

            I am unaware of any specific indicators that do this for you, nor am I able to recommend any specific third party vendors that offer such a calculator. You might try a quick online search, or perhaps one of our forum members here will chime in with something they've created or found.
            I managed to get something working. No error checking, pretty thrown together for what I need, not sure if there are any other problems w/it.
            Last edited by forrestang; 02-27-2020, 11:10 PM.

            Comment


              #7
              I would suggest this be a built in feature to the Chart Trader interface. For example, set risk $ or %, set limit buy/sell, set stop loss, and NT calculate the lot size (quantity) for you. This could then be incorporated into ATM strategies, so that instead of choosing my Quantity, I could select my Risk $ or %, set limit buy/sell and done (lot size and stop loss / targets are set automatically)

              Comment


                #8
                Hello mase2005,

                Thank you for your reply.

                I've added a vote for you to an existing feature request for this functionality. This request is being tracked under the number SFT-420.

                As with all feature requests, interest is tracked before implementation is considered, so we cannot offer an ETA or promise of fulfillment. If implemented, it will be noted in the Release Notes page of the Help Guide.

                Release Notes — https://ninjatrader.com/support/help...ease_notes.htm

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

                Comment


                  #9
                  Hi Kate,
                  any news on this so far?
                  I'd also really like to have that functionality implemented as soon as possible !

                  Comment


                    #10
                    Hello benjit379,

                    Thank you for your inquiry.

                    There is no update on SFT-420 at this time.

                    Deciding on features for future releases is not a simple black and white decision. There are many factors involved including but not limited to:
                    • Demand which is measured by objective user requests and subjective discretion on the part of our Product Management team.
                    • Feasibility
                    • Developer bandwidth
                    • Current projects in the queue
                    • Economics
                    You'll find a note regarding the feature request in the release notes when/if a feature is implemented.

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

                    Comment


                      #11
                      Hi!
                      Nothing about this feature yet?

                      Comment


                        #12
                        Hello eduardopoletto,

                        This SFT number has not been listed in the release notes for NinjaTrader 8.

                        Please note, as mentioned by NinjaTrader_Kate we are not able to provide a guarantee any feature request will be fulfilled.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          HI!
                          Ok, just asking.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by frankthearm, Today, 09:08 AM
                          3 responses
                          7 views
                          0 likes
                          Last Post NinjaTrader_Clayton  
                          Started by yertle, Today, 08:38 AM
                          5 responses
                          15 views
                          0 likes
                          Last Post NinjaTrader_BrandonH  
                          Started by adeelshahzad, Today, 03:54 AM
                          3 responses
                          16 views
                          0 likes
                          Last Post NinjaTrader_BrandonH  
                          Started by bill2023, Yesterday, 08:51 AM
                          6 responses
                          27 views
                          0 likes
                          Last Post NinjaTrader_Erick  
                          Started by NinjaTrader_ChelseaB, 01-08-2017, 06:59 PM
                          80 responses
                          19,667 views
                          5 likes
                          Last Post NinjaTrader_ChelseaB  
                          Working...
                          X