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 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