Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem using trade collection

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

    Problem using trade collection

    Hi!

    I'm sorry I have to bug you guys again with one of my small problems.
    This time I'm trying to calculate the Minimum Payoff Ratio of my strategy with this code:


    Code:
    // Minimum Payoff Ratio
    private string MinPayoff = "Not enough trades to calculate Minimum Payoff Ratio";
    private double MinPayoff2 = 1337; // Value is just to see when it prints this.
    
    			if((Performance.AllTrades.WinningTrades.TradesCount == 0) || (Performance.AllTrades.LosingTrades.TradesCount == 0))
    				MinPayoff = "Not enough trades to calculate Minimum Payoff Ratio";
    			else
    			{
    				MinPayoff = "Current Minimum Payoff Ratio is: ";
    				MinPayoff2 = (Performance.AllTrades.LosingTrades.TradesCount / Performance.AllTrades.WinningTrades.TradesCount);
    			}
    
    Print(MinPayoff + MinPayoff2); // Not working
    I have tried making it print just the Performance.AllTrades.LosingTrades.TradesCount (and winning one). Both of those will print out the correct value, however it won't print anything but 0 if I try to use thise code. The result will look like this: Current Minimum Payoff Ratio is: 0

    Anyone have an idea on how I can make it work?

    #2
    Since you're dividing two int's here, I think you need to add more precision to see the floating type results for your ratio - for example, please try this change :

    MinPayoff2 = (double)(Performance.AllTrades.LosingTrades.Trades Count / (double)Performance.AllTrades.WinningTrades.Trades Count);

    Comment


      #3
      That worked like a charm! Thank you very much

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      633 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      364 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      105 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      567 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      568 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X