• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Knortzsch, Today, 12:36 AM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Marco  
            Started by Wick Wrangler, Today, 12:42 AM
            0 responses
            8 views
            0 likes
            Last Post Wick Wrangler  
            Started by saltminer, Yesterday, 11:06 PM
            0 responses
            5 views
            0 likes
            Last Post saltminer  
            Started by saltminer, Yesterday, 10:14 PM
            0 responses
            6 views
            0 likes
            Last Post saltminer  
            Started by Mykro, Yesterday, 10:03 PM
            0 responses
            6 views
            0 likes
            Last Post Mykro
            by Mykro
             
            Working...
            X