Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

List all trades in playback connection with strategies not inserted in chart

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

    List all trades in playback connection with strategies not inserted in chart

    I am running several strategies without being inserted in the chart, in playback connection.


    The code is below:

    Code:
    private double GetProfitRange(StrategyBase strategy, DateTime begin, DateTime end) {
       double profit = 0.0;
       this.Print("AllTrades : " + strategy.SystemPerformance.AllTrades.Count); // Always return zero.
       List<Trade> rangeTrades = strategy.SystemPerformance.AllTrades.Where(t =>(t.Exit.Time > begin && t.Exit.Time < end)).ToList<Trade>();
       foreach (Trade trade in rangeTrades) {
          profit += trade.ProfitCurrency;
       }
       return profit;
    }
    Is there another way for me to list all the trades, considering the context (strategies not plotted on the chart and playback connection)?
    Last edited by janiodesouza; 11-19-2021, 03:50 PM.

    #2
    Hello janiodesouza,

    Thank you for your post.

    Am I understanding correctly that the above code is not returning a value for strategy.SystemPerformance.AllTrades.Count and that's the issue? Is this code being run within the strategies themselves or is this something you're running externally to the Strategy?

    Do you have IncludeTradeHistoryInBacktest set to true in the strategies' State.SetDefaults?

    Thanks in advance; I look forward to assisting you further.

    Comment


      #3
      Question 1) Yes, it always returns zero.
      Question 2) This code runs in a strategy that manages other strategies. (Because it manages the daily goal of several strategies).
      Question 3) Yes, it is included in all strategies.

      Comment


        #4
        Hello janiodesouza,

        Thank you for your reply.

        I'd expect AllTrades to not be empty if IncludeTradeHistoryInBacktest is set to true. This needs to be set to true in State.SetDefaults though for Control Center, so you may need to remove and re-add the strategies to the Strategies tab if you changed that later.

        I'm attaching a pair of strategies that demonstrates. If I add and enable SampleMATest on the Strategies tab and then run the PrintStrategyTradesCount strategy, I get an expected value for AllTrades.Count. Do you see the same?

        Thanks in advance; I look forward to assisting you further.
        Attached Files

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        53 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        130 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        70 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        44 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        49 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X