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 CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      67 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      41 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      202 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      366 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      283 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X