Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

wrong Position quantity

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

    wrong Position quantity

    I am filling an array with my position information according to BarsInProgress during onBarUpdate.

    When I print this out though, it puts my last fill information instead of my position quantity into the array Instr[10, i].

    Can you see why? Here is the code snipit:

    /// WRITE POSTION INFO TO INSTR ARRAY
    for (int i = 0; i < mySymbol.Count; i++)
    {
    if (BarsInProgress == i && Close[0] != 0)
    {
    if (Position.MarketPosition == MarketPosition.Flat) Instr[10, i] = 0;
    if (Position.MarketPosition == MarketPosition.Long) Instr[10, i] = Position.Quantity;
    if (Position.MarketPosition == MarketPosition.Short) Instr[10, i] = Position.Quantity * -1;

    Instr[11, i] = Position.AvgPrice;

    Print("BIP: " + BarsInProgress + mySymbol[i] + " Qty: " + Instr[10, i] + " Avg$:" + Instr[11, i]);
    }
    }
    Last edited by vjsworld; 08-14-2013, 10:50 AM.

    #2
    I know what's going on. When I restart the strategy it does not pickup the existing trades from its last run. I know how to query those with your 'unsupported':
    foreach (Account acct in Cbi.Globals.Accounts)

    I'll do a work around.

    Comment


      #3
      Hello,

      Try using Positions[i] instead



      This will allow you to specify the correct instrument

      Let me know if I can further assist.
      LanceNinjaTrader Customer Service

      Comment


        #4
        Nope, still picks up zeros until a new trade happens. Then only populates the new trade info ignoring the 'old existing' trades. Does not tell my actual MP, just the new fill info as though that's my only MP.

        Gotta do the workaround.

        Comment


          #5
          Ok thanks for clarifying. I didn't realize you were trying to pick up orders when restarting the script.
          LanceNinjaTrader Customer Service

          Comment


            #6
            Not orders, previous positions

            previous position qty + current fill qty = actual position

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by CaptainJack, 04-24-2026, 11:07 PM
            0 responses
            18 views
            0 likes
            Last Post CaptainJack  
            Started by Mindset, 04-21-2026, 06:46 AM
            0 responses
            120 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            174 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            92 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by cmoran13, 04-16-2026, 01:02 PM
            0 responses
            134 views
            0 likes
            Last Post cmoran13  
            Working...
            X