Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Optimization Fitnesses

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

    Optimization Fitnesses

    From within the above, it is possible to find out how many of the trades were exited via limit orders vs market ?

    #2
    Hello spottysallrite,

    Thank you for your note.

    You may get this information from a specific trade object using an index value for the TradeCollection being accessed. For example, building on the following example from the help guide that accesses the first and last trade in the strategy, we can also print out the order type for the exit of those trades:

    Code:
      // Accesses the first/last trade in the strategy (oldest trade is at index 0)
      // and prints out the order type for the exit order
      if (SystemPerformance.AllTrades.Count > 1)
      {
          Trade lastTrade = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1];
          Trade firstTrade = SystemPerformance.AllTrades[0];
    
          Print("The last trade exit order type was " + lastTrade.Exit.Order.OrderType);
          Print("The first trade exit order type was " + firstTrade.Exit.Order.OrderType);
      }​
    The following links are relevant:
    When considering Optimization Fitness scripts, you could calculate the number of market exits for example using the following logic in OnCalculatePerformanceValue():
    Code:
            protected override void OnCalculatePerformanceValue(StrategyBase strategy)
            {
                int marketExits = 0;
                if (strategy.SystemPerformance.AllTrades.Count > 1)
                {
                    for (int x = 0; x < strategy.SystemPerformance.AllTrades.Count; x++)
                    {
                        if (strategy.SystemPerformance.AllTrades[x].Exit.Order.OrderType == OrderType.Market)
                            marketExits++;
                    }
                    Value = marketExits;
                }
            }​
    You could do something similar for limit orders or even make a ratio of limit order exits vs. market order exits depending on your needs.

    Please let us know if we may be of further assistance.

    Comment


      #3
      Nice ! Thx much !

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      43 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      124 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      65 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      42 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      46 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X