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 Mindset, 04-21-2026, 06:46 AM
        0 responses
        88 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        134 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        68 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        119 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        67 views
        0 likes
        Last Post PaulMohn  
        Working...
        X