Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Counters for Winning Trades and Losing Trades

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

    Counters for Winning Trades and Losing Trades

    I would like to add counters to a strategy for winning trades and losing trades.

    I would reset the winning counter when a losing trade occurs and reset the losing counter when a winning trade occurs.

    If someone could explain it to me like I'm 5 years old, that would be greatly appreciated.

    #2
    Below is what I have so far but they do not seem to be counting.

    if (SystemPerformance.RealTimeTrades.Count > 0)
    {
    // Check to make sure there is at least one trade in the collection
    Trade lastTrade = SystemPerformance.RealTimeTrades[SystemPerformance.RealTimeTrades.Count - 1];

    // Calculate the PnL for the last completed real-time trade
    double lastProfitCurrency = lastTrade.ProfitCurrency;

    // Store the quantity of the last completed real-time trade
    double lastTradeQty = lastTrade.Quantity;

    if (lastTrade.ProfitCurrency > 0)
    {
    WinningTrades++;
    }

    else if (lastTrade.ProfitCurrency < 0)
    {
    LosingTrades++;
    }​

    Comment


      #3
      This is how I'm resetting them which may also be the problem.

      priorTrades = SystemPerformance.AllTrades.Count;

      if ((WinningTrades >= 1) && SystemPerformance.AllTrades.Count != priorTrades)
      {
      LosingTrades = 0;
      }

      if ((LosingTrades >= 1) && SystemPerformance.AllTrades.Count != priorTrades)
      {
      WinningTrades = 0;
      }​

      Comment


        #4
        "I would reset the winning counter when a losing trade occurs and reset the losing counter when a winning trade occurs."

        So that would be this if I understand you correctly:
        Code:
        if (lastTrade.ProfitCurrency > 0)
        {
              WinningTrades++;
               LosingTrades = 0;
        }
        
        else if (lastTrade.ProfitCurrency < 0)
        {
              LosingTrades++;
              WinningTrades = 0;
        }​​

        Comment


          #5
          Thanks, I appreciate that. I tried it and it worked.

          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
          20 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
          49 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          38 views
          0 likes
          Last Post CarlTrading  
          Working...
          X