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 CaptainJack, 05-29-2026, 05:09 AM
        0 responses
        163 views
        0 likes
        Last Post CaptainJack  
        Started by CaptainJack, 05-29-2026, 12:02 AM
        0 responses
        82 views
        0 likes
        Last Post CaptainJack  
        Started by charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        125 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        206 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        185 views
        0 likes
        Last Post CarlTrading  
        Working...
        X