• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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);
    BertrandNinjaTrader Customer Service

    Comment


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

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by rexmie888, Today, 09:37 PM
      0 responses
      1 view
      0 likes
      Last Post rexmie888  
      Started by jvanelli, Today, 09:23 PM
      0 responses
      6 views
      0 likes
      Last Post jvanelli  
      Started by lavalampmj, Today, 06:07 PM
      1 response
      6 views
      0 likes
      Last Post bltdavid  
      Started by Sameer, Today, 04:40 PM
      1 response
      35 views
      0 likes
      Last Post NinjaTrader_EricB  
      Started by Teebone21, Today, 04:34 PM
      0 responses
      9 views
      0 likes
      Last Post Teebone21  
      Working...
      X