Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dumb Question

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

    Dumb Question



    Hello all, this is probably a newb question, so I apologize for that. In addition, I want to thank you for all the support you provide, I see almost every thread that is started has a reply.


    How do I grab the exit size of my last order, and then use that information to increase the size of my next position?


    I know this is elementary ,so I apologize again in advance. I'm a blacksmith by trade - see more here - not a programmer : )
    Last edited by KarlieBoe; 02-17-2021, 06:42 PM.

    #2
    Hello KarlieBoe,

    Thank you for your post.

    Welcome to the NinjaTrader forums! Don't worry, it's not a stupid question at all.

    To check the exit size of the last order, you would need to check the TradeCollection, get the last trade, then get the quantity of that trade. You could then save this to a variable and use that to adjust the position size of your next entry:



    For example:

    Code:
    private int LastTradeQuantity;
    
    protected override void OnBarUpdate()
    {
      // Accesses the last trade in the strategy (oldest trade is at index 0)
      // and assigns the quanity to a variable
      if (SystemPerformance.AllTrades.Count > 1)
      {
          Trade lastTrade = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1];
    
          LastTradeQuantity = lastTrade.Quantity;
    
      }
    
    }
    Please let us know if we may be of further assistance to you.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    52 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    130 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    70 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    43 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    47 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X