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 argusthome, 03-08-2026, 10:06 AM
            0 responses
            86 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            48 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            29 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            32 views
            0 likes
            Last Post TheRealMorford  
            Started by Mindset, 02-28-2026, 06:16 AM
            0 responses
            67 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Working...
            X