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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      152 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      89 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      131 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      127 views
      1 like
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      107 views
      0 likes
      Last Post CarlTrading  
      Working...
      X