Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Performance.AllTrades - Trade collection

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

    Performance.AllTrades - Trade collection

    Hello Forum,
    I'm monitoring all trades done by a strategy to process the data further into a DB...
    Therefore I'm using the 'Trade' object.
    Now, I encountered a funny behaviour in a "scale-in" strategy, where a full
    position is build after several (long) trades.
    By the way, in a normal strategy (without scaling) this all is working like a charme)

    Let's take my current backtest as an example, lets imagine 6 buys, 1 every day, and on the 7th day a full liquidation.
    Please have a look at the attached picture!

    Ok I would expect this code
    PHP Code:
    Trade t = Performance.AllTrades[Performance.AllTrades.Count-1];
    Print(t.Entry.ToString());
    Print(t.Exit.ToString()); 
    
    to print me 6 trades with different entry prices and dates and one exit price at the last day.

    But here is the result for the entry: It prints 6 entries but it takes the last 'buy' day
    and the entry price of that day, which was 9010.
    PHP Code:
    Execution='NT-00005' Instrument='FDAX 03-14' Account='Backtest' Name='Buy' Exchange=Default Price=9010 Quantity=1 Market position=Long Commission=0 Order='NT-00005' Time='16.12.2013 22:00:00'
    Execution='NT-00005' Instrument='FDAX 03-14' Account='Backtest' Name='Buy' Exchange=Default Price=9010 Quantity=1 Market position=Long Commission=0 Order='NT-00005' Time='16.12.2013 22:00:00'
    Execution='NT-00005' Instrument='FDAX 03-14' Account='Backtest' Name='Buy' Exchange=Default Price=9010 Quantity=1 Market position=Long Commission=0 Order='NT-00005' Time='16.12.2013 22:00:00'
    Execution='NT-00005' Instrument='FDAX 03-14' Account='Backtest' Name='Buy' Exchange=Default Price=9010 Quantity=1 Market position=Long Commission=0 Order='NT-00005' Time='16.12.2013 22:00:00'
    Execution='NT-00005' Instrument='FDAX 03-14' Account='Backtest' Name='Buy' Exchange=Default Price=9010 Quantity=1 Market position=Long Commission=0 Order='NT-00005' Time='16.12.2013 22:00:00'
    Execution='NT-00005' Instrument='FDAX 03-14' Account='Backtest' Name='Buy' Exchange=Default Price=9010 Quantity=1 Market position=Long Commission=0 Order='NT-00005' Time='16.12.2013 22:00:00' 
    
    and the exit:
    PHP Code:
    Execution='NT-00006' Instrument='FDAX 03-14' Account='Backtest' Name='Sell' Exchange=Default Price=9168.5 Quantity=6 Market position=Short Commission=0 Order='NT-00006' Time='17.12.2013 22:00:00'
    Execution='NT-00006' Instrument='FDAX 03-14' Account='Backtest' Name='Sell' Exchange=Default Price=9168.5 Quantity=6 Market position=Short Commission=0 Order='NT-00006' Time='17.12.2013 22:00:00'
    Execution='NT-00006' Instrument='FDAX 03-14' Account='Backtest' Name='Sell' Exchange=Default Price=9168.5 Quantity=6 Market position=Short Commission=0 Order='NT-00006' Time='17.12.2013 22:00:00'
    Execution='NT-00006' Instrument='FDAX 03-14' Account='Backtest' Name='Sell' Exchange=Default Price=9168.5 Quantity=6 Market position=Short Commission=0 Order='NT-00006' Time='17.12.2013 22:00:00'
    Execution='NT-00006' Instrument='FDAX 03-14' Account='Backtest' Name='Sell' Exchange=Default Price=9168.5 Quantity=6 Market position=Short Commission=0 Order='NT-00006' Time='17.12.2013 22:00:00'
    Execution='NT-00006' Instrument='FDAX 03-14' Account='Backtest' Name='Sell' Exchange=Default Price=9168.5 Quantity=6 Market position=Short Commission=0 Order='NT-00006' Time='17.12.2013 22:00:00' 
    
    Ok so, what's the problem here and how to overcome it? I used the iExecution
    Object and could see the real entry prices, but not in the Trade object...
    Am I missing someting? Any help welcome.
    All the best
    Attached Files

    #2
    Ok, sure the mistake is on my side and i solved it, so no need to put time into that question.
    The answer is that I have to use a counter to determine the last trade instead of using :
    Performance.AllTrades.Count-1


    So what I'm using now is a trade counter
    PHP Code:
    Trade t = Performance.AllTrades[counter];
    Print(t.Entry.ToString());
    Print(t.Exit.ToString()); 
    counter++; 
    

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    656 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    371 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    109 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    574 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    579 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X