Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calculate Per-Pip Dollar Value for Non-USD Pairs

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

    Calculate Per-Pip Dollar Value for Non-USD Pairs

    Hello,

    I'm wondering if there is a built in solution for calculating the pip value in USD for forex pairs that do not have USD as the base or quote currency? For example, opening a position on EUR/CAD has a pip value (today) of 0.000074 USD per unit. Writing my own algorithm to do this would require my strategy to query the USD conversion rates for each non-US currency, so it would be ideal to use a built in function if it exists.

    The goal is for the strategy to calculate size based on a USD pip value input parameter only. For example, PipValueUSD = 2.5 USD/PIP and the strategy calculates the size needed to achieve this. Otherwise, the user will need to calculate it on their own.

    Your input is appreciated!

    #2
    Hello jflaggs,

    Thank you for your post.

    Unfortunately, there is no built-in function to convert pip value to USD for Forex pairs that do not have USD as the base/quote currency.

    Your script will need to implement this conversion, or as you've stated, the user will need to calculate this on their own.

    Calculating Pip Value - https://ninjatrader.com/support/help...latingPipValue

    Please let us know if you have any other questions.

    Comment


      #3
      That's unfortunate. Then how can I get the needed conversion rates in Ninjascript programmatically? I'd need a function such as GetRate("EURUSD")[0]. Adding a series ahead of time will not be a good solution because then you get into hard-coding territory.

      Comment


        #4
        Hello,

        The converted rate will populate automatically, as long as there are active instrument pairs that encompass both currencies.

        Please see this forum post that goes into a bit more detail:
        https://forum.ninjatrader.com/forum/...84#post1146984

        And this post on getting the exchange rate:
        https://forum.ninjatrader.com/forum/...65#post1085365

        The links in the post are broken, but I am providing them below:

        https://ninjatrader.com/support/help...nstruments.htm

        https://ninjatrader.com/support/help...riceseries.htm

        Please let me know if you have any other questions.

        Comment


          #5
          The documentation for multi timeframe specifically warns that you cannot add an instrument dynamically. So this means that the only way to have real time currency conversion is to hard code every single currency combination in state Configure so that it can be accessed later. I'm concerned about the performance implications of this during back testing and real time.

          I'd propose that if NT can display my non-US PNL in USD then there should be a corresponding Ninjascript function to do the same thing. For example, PNL for my EUR/JPY trade is displayed in USD in my positions tab and also in the AccountItem object. That is the functionality we should have access to in Ninjascipt as well. Does that seem like a fair request for future development?

          Comment


            #6
            Hello,

            Thank you for your suggestion.

            We have submitted this as a feature request to the Development Team and will follow up with an internal tracking number for your reference as soon as it is created.

            Thanks in advance for your patience.

            Comment


              #7
              Hello,

              This request is being tracked under the number SFT-6165.


              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 on the Release Notes page of the Help Guide.


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

              Comment


                #8
                Can AddDataSeries() be called in a for-loop? If not, can you please explain? I have over 30 series that I need to add to my indicator so hard coding it is not a clean solution. Especially when you consider that any "hosting" indicator or strategy will also have to hard code these same lines.

                Referencing the documentation here: https://ninjatrader.com/support/help...nstruments.htm

                •This method should ONLY be called from the OnStateChange() method during State.Configure
                •Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided. Trying to load bars dynamically may result in an error similar to: Unable to load bars series. Your NinjaScript may be trying to use an additional data series dynamically in an unsupported manner.
                •When instantiating indicators in a Multi-Series script in OnStateChange, the input any hosted indicator is running on should be explicitly stated (since a specific BarsInProgress is not guaranteed)
                Example Code:

                Code:
                      foreach (string symbol in symbols)
                      {
                          AddDataSeries(symbol, Data.BarsPeriodType.Day, 1, Data.MarketDataType.Last);
                      }​​

                Comment


                  #9
                  Hello,

                  No, as mentioned in the documentation for AddDataSeries() you cannot add data series dynamically. Dynamically adding data series is not currently supported.

                  The reason being (like the documentation says) is that it can cause errors / fail in various use cases.

                  "Trying to load bars dynamically may result in an error similar to: Unable to load bars series. Your NinjaScript may be trying to use an additional data series dynamically in an unsupported manner."

                  Instead, you can use a BarsRequest. Please see the forum post linked below for an example script:



                  Please let me know if you have any other questions.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by NullPointStrategies, Yesterday, 05:17 AM
                  0 responses
                  54 views
                  0 likes
                  Last Post NullPointStrategies  
                  Started by argusthome, 03-08-2026, 10:06 AM
                  0 responses
                  130 views
                  0 likes
                  Last Post argusthome  
                  Started by NabilKhattabi, 03-06-2026, 11:18 AM
                  0 responses
                  70 views
                  0 likes
                  Last Post NabilKhattabi  
                  Started by Deep42, 03-06-2026, 12:28 AM
                  0 responses
                  44 views
                  0 likes
                  Last Post Deep42
                  by Deep42
                   
                  Started by TheRealMorford, 03-05-2026, 06:15 PM
                  0 responses
                  49 views
                  0 likes
                  Last Post TheRealMorford  
                  Working...
                  X