Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Money management

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

    Money management

    Hello. I'm trying to manage the money into the automated trading and I need to know how much money I win/loss in the last trade for adding or substracting. I have put the next routine:

    protectedoverridevoid OnOrderUpdate(IOrder order)
    {

    Trade UltimoTrade;

    UltimoTrade = Performance.AllTrade[Performance.AllTrades.Count - 1];

    if (LongOrder != null && LongOrder.Token == order.Token)
    if (order.OrderState == OrderState.Filled)

    GCCapital = GCCapital + UltimoTrade.ProfitCurrency *
    UltimoTrade.Quantity;
    }


    if (ShortOrder != null && ShortOrder.Token == order.Token)
    {
    if (order.OrderState == OrderState.Filled)
    GCCapital = GCCapital - UltimoTrade.ProfitCurrency *
    UltimoTrade.Quantity;

    }
    My problem is that this routine is not called after close of every trade. After three trades it calculate the second trade, and so on. What are I'm doing bad.

    Thank you very much.

    #2
    You told it to calculate the last trade but 1.

    "Performance.AllTrades.Count - 1" is what you asked it to do.

    Comment


      #3
      Hello,

      Thanks for the forum post.

      Instead of doing this in OnOrderUpdate().

      Why not just access the current trade and last trade before your ready to make a new trade and do your additions there before as a filter before you can place new trades.

      For example use the following sample, however instead of counting consecutive losers. Do your money management math by accessing the PnL from the trade performance.

      http://www.ninjatrader.com/support/f...ad.php?t=19289

      Let me know if I can be of further assistance.
      BrettNinjaTrader Product Management

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by dshalom9, Today, 02:15 PM
      0 responses
      4 views
      0 likes
      Last Post dshalom9  
      Started by Shai Samuel, Today, 12:22 PM
      2 responses
      16 views
      0 likes
      Last Post Shai Samuel  
      Started by sjmuk1, Today, 01:46 PM
      0 responses
      12 views
      0 likes
      Last Post sjmuk1
      by sjmuk1
       
      Started by amart74, 02-06-2023, 11:44 AM
      7 responses
      109 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by tkaboris, Today, 10:46 AM
      7 responses
      37 views
      0 likes
      Last Post tkaboris  
      Working...
      X