Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can't get history of trades for my own analysis

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

    Can't get history of trades for my own analysis

    Hi!

    I try to use Performance.AllTrades in this way (some code from OnBarUpdate):

    Code:
                if(Time[0] >= FirstRealtimeDate && bProcessed == false)
                {
                bProcessed = true;
                Print("all " + Performance.AllTrades.Count + "; real " + Performance.RealtimeTrades.Count + "; exec " + Performance.Executions.Count);
                if (Performance.AllTrades.Count > 0)
                {
                    foreach(Trade lastTrade in Performance.AllTrades)
                    {
                        // Calculate the PnL for the last completed real-time trade
                        double lastProfit = lastTrade.ProfitCurrency * lastTrade.Quantity;
                
                        // Pring the PnL to the Output window
                        Print("Pnl" + lastProfit);
                    }
                }
    where FirstRealtimeDateset to DateTime.Now on Initialize.

    Code works properly in time, but I always get this:
    all 0; real 0; exec 0.
    I have about 100 trades in history on my Sim101 account.......

    I set in Initialize():
    Enabled = true;
    SyncAccountPosition = true;
    TraceOrders = true;

    What I should to do to fix?
    Last edited by fut_practic; 02-11-2015, 08:36 PM.

    #2
    Hey, get some ideas for?

    Rainbow indicator shows my previous trades, but my script won't do this......

    Comment


      #3
      fut_practic, so this would be for manual trades you done in the Sim101 account? The performance collection you're working with would only allow accessing the strategy instance own trades executed (historical in backtest or realtime, whatever collection you access).

      Comment


        #4
        Ok, what does SyncAccountPosition = true mean?

        Comment


          #5
          Hi fut_practic,

          Regarding the Rainbow indicator, I've got good news and I've bad news for you:

          1) Good news is: Showing historical trades by an indicator can be done and I do it by extracting ChartExecution objects from the chart, which carry the execution data (reflection must be used). These are converted to trades and displayed. In case you want to use it, you're a lucky guy, as I'll post the source code for this feature in the NinjaScript file sharing forum soon (won't promise any exact dates).

          2) Bad news is: The executions, which are accessible through this method are more or less just those, that are currently displayed on the chart, so it can't be done without a chart. I collect them, so I don't have do the recalculations all the time, but you won't get all the historical data unless you scroll the chart back to history ... Which can be bad, but doesn't have to be an obstacle depending on what you're trying to achieve.

          Lucas
          -------------
          Get Rainbow free at http://rainbow-in.com

          Comment


            #6
            Originally posted by fut_practic View Post
            Ok, what does SyncAccountPosition = true mean?
            fut_practic, that means the automatic sync market order if needed to sync the account position to match your strategy position is enabled for the script instance.

            More details on this approach and the setup scenarios could be found here in our helpguide - https://www.ninjatrader.com/support/..._positions.htm

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            633 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            364 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            105 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            567 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            568 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X