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 kinfxhk, 07-14-2026, 09:39 AM
        0 responses
        13 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 07-13-2026, 10:18 AM
        0 responses
        59 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 07-13-2026, 09:50 AM
        0 responses
        41 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 07-13-2026, 07:21 AM
        0 responses
        47 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 07-11-2026, 02:11 AM
        0 responses
        38 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Working...
        X