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.



      Let me know if I can be of further assistance.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by judysamnt7, 03-13-2023, 09:11 AM
      4 responses
      59 views
      0 likes
      Last Post DynamicTest  
      Started by ScottWalsh, Today, 06:52 PM
      4 responses
      36 views
      0 likes
      Last Post ScottWalsh  
      Started by olisav57, Today, 07:39 PM
      0 responses
      7 views
      0 likes
      Last Post olisav57  
      Started by trilliantrader, Today, 03:01 PM
      2 responses
      21 views
      0 likes
      Last Post helpwanted  
      Started by cre8able, Today, 07:24 PM
      0 responses
      10 views
      0 likes
      Last Post cre8able  
      Working...
      X