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.

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

    https://ninjatrader.com/support/help...collection.htm

    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.
    Kate W.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by sidlercom80, Today, 02:40 AM
    0 responses
    7 views
    0 likes
    Last Post sidlercom80  
    Started by b16_aln, Today, 01:52 AM
    0 responses
    9 views
    0 likes
    Last Post b16_aln
    by b16_aln
     
    Started by junkone, Yesterday, 08:55 PM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by adaeiqendqw, 01-16-2021, 02:56 AM
    1 response
    16 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by [email protected], Yesterday, 06:10 PM
    5 responses
    16 views
    0 likes
    Last Post NinjaTrader_ChrisSch  
    Working...
    X