Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnBarUpdate - multi-instrument-script

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

    OnBarUpdate - multi-instrument-script

    Hello,

    it seems that "Position.Quantity.ToString();" does not update in OnBarUpdate when using in a script with more than 1 instrument. It shows always "0", when I change the instrument in the chart then its shows the positionquantity. What does one have to add please so that its working with the instrument it is attached in the chart (or specified to any of the used instruments).

    Thank you!
    Tony

    #2
    Hello tonynt,

    This depends on where you are calling the syntax and what BarsInProgress called OnBarUpdate. Generally for multi series scripts you need to use "Positions" plural, instead of Position singular.



    Assuming you are using two difference instruments, you can reference a specific instrument using the Positions[index].

    I look forward to being of further assistance.

    Comment


      #3
      Hello,

      thank you for your reply. It works now "partially". But it does not update (in onbarupdate) my "controlvalues" with
      if (Position.MarketPosition == MarketPosition.Short)
      {if (Positions[0].Quantity>=1)
      {
      avgFillSa=Position.AveragePrice;
      ...

      I´m in a short trade but "avgFillSa" persists 0 and doesnt show the entryprice. Why?

      Thank you!
      Tony
      Last edited by tonynt; 08-16-2019, 08:35 AM. Reason: correction

      Comment


        #4
        Hello,

        after replying with this question above I found out. Its interesting that when doing a communication and asking a question very often the solution appears!
        It also has to be if(Positions[0].MarketPosition...) and avgFillSa=Positions[0].AveragePrice.

        Best regards
        Tony
        Last edited by tonynt; 08-16-2019, 08:40 AM. Reason: correction

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        46 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        126 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        66 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        42 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X