Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 bmartz, 03-12-2024, 06:12 AM
      4 responses
      31 views
      0 likes
      Last Post bmartz
      by bmartz
       
      Started by Aviram Y, Today, 05:29 AM
      4 responses
      11 views
      0 likes
      Last Post Aviram Y  
      Started by algospoke, 04-17-2024, 06:40 PM
      3 responses
      28 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by gentlebenthebear, Today, 01:30 AM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by cls71, Today, 04:45 AM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X