Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to find the last orders EXIT position SIZE?

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

    How to find the last orders EXIT position SIZE?

    First off, I've been using the platform for years to develop many different ideas and I love it. While I haven't been successful, that's not fault of the platform! So thank you.

    I've scoured the forums to try and find an answer to this question and there are many similar ones out there, but I seem to be overlooking the answer to my particular problem...

    The Question: In short, I want to grab the exit size of my last order and on my next order that's placed, increase the size based on the previous exit.

    I know you can just "Enter Short" on a losing Long Trade easily enough using the editor and code, but I don't want to do it within the same bar. I want to be able to wait until another defined entry point and use the previous orders exit size to size my new position.

    I hope that makes sense and thank you for your time!

    #2
    Hello boolwinkle,

    Thank you for your post.

    You could do this by querying the trades collection and getting the quantity of the last trade:

    Code:
    protected override void OnBarUpdate()
    {
      if (SystemPerformance.AllTrades.Count > 0)
      {
          // Check to make sure there is at least one trade in the collection
          Trade lastTrade = SystemPerformance.RealTimeTrad es[SystemPerformance.RealTimeTrades.Count - 1];
    
          // Store the quantity of the last completed real-time trade
          double lastTradeQty = lastTrade.Quantity;
    
         // Print the quantity of the last trade
         Print("The last trade was for " + lastTradeQty + " contracts");
      }
    }


    You can then use the lastTradeQty to calculate the size of your subsequenty entries.

    Please let us know if we may be of further assistance to you.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    62 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    134 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    75 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    50 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X