Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to get Position.Quantity of another instrument using a multi-instrument strategy

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

    How to get Position.Quantity of another instrument using a multi-instrument strategy

    Hi NT8 support,

    Do do I get the Position.Quantity of the other instuments in a multi-instrument strategy.

    For instance, if I added the EURUSD to my add'l data series, and I placed trades on the second instrument [1] EURUSD within a strategy, how can I know the Position.Quantity of units currency on that second instrument. Thank you.




    #2
    Hello Austiner87,

    You can use the Positions object. You can see how that works in the following page, secondary instruments always start as index [2] on Positions.

    Comment


      #3
      Hello Jesse,

      thank you, I was able to get this to work. I have a closely related question about using BarsSinceEntry on another instrument in a multi-instrument strategy.

      please see the snap below - I thought that by tagging the signal name on the Bars Since Entry as the same signal name as the entry on the multi-instrument that would work, but it is not. Can you please help me so that my BarsSinceEntry will work on Instrument[1]. What is happening when I turn the strategy on in market replay is that it only enters on the first entry (set 1), but not the second (set 2).

      Thank you!
      Attached Files

      Comment


        #4
        Hello Austiner87,

        Have you tried using a Print to see what the value is when running that? You would need to print before the set 2 condition and output the BarsSinceEntryExecution to see if it is -1 (not found) or a value like 0.

        The method BarsSinceEntry will return the amount of bars in relation to the series used, in some use cases that value may not change or will be slow to increment. For example if this code was being used on a 1 tick series and the primary was an 30 minute bars. That would result in 0 BarsAgo for a lot of ticks before a new primary bar is generated.

        Comment


          #5
          Hi Jesse, I will try the print, but all my instruments use the 1 min bars to prevent a desynch of bars for many issues, including this one.

          I think what is happening is that the bars since entry is expecting an entry on the primary instrument to test against but I want it to reference the seconday instrument[1].

          i believe you indicated the barssincentry function can't do this. Do I have that right?

          Comment


            #6
            Hello Austiner87,

            The print will be the best way forward from this point, without knowing what is happening you would just be making guesses at the problem. Finding out what the value is at that time will help to understand the problem. If -1 is reported then it didn't find that entry. If a 0 is reported that would be less than your BarsSinceEntry variable. You may also want to print the BarsSinceEntry in case that is being set in your logic to confirm that value is the right value.

            i believe you indicated the barssincentry function can't do this. Do I have that right?
            Using the BarsSinceEntryExecution function between two different timeframes of the same instrument can yield problems based on the note in the help guide for that method. In that use case you may see that the value does not advance as expected depending on the two timeframes used. The primary timeframe would be what the BarsAgo is reported for, using a smaller secondary you would see the BarsAgo not increase for many secondary bars.
            Note: When working with a multi-series strategy the BarsSinceEntryExecution() will return you the elapsed bars as determined by the first Bars object for the instrument specified by the barsInProgressIndex.
            When using two different instruments on a similar timeframe you will likely have similar bars however the BarsSinceEntryExecution reported bars is the number of bars for the associated series of the order. If you checked if it had been 5 bars since then entry that assumes you meant 5 bars from the instrument which the order was submitted to. That would only be important to keep in mind if you called this method from a BarsInProgress other than the instrument that submitted the order. The reported BarsAgo would relate to the instrument for the order and not the instrument which called OnBarUpdate at that time. 5 BarsAgo on instrument A may not equate to the same place in time that 5 BarsAgo on instrument B would be.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Today, 05:17 AM
            0 responses
            52 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