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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      93 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      138 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      123 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      73 views
      0 likes
      Last Post PaulMohn  
      Working...
      X