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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    43 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    21 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    30 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    50 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    40 views
    0 likes
    Last Post CarlTrading  
    Working...
    X