Backtest - same code gets different trade results by changing end date

Created at 22 Sep 2020, 21:13
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
CT

ctid1074959

Joined 19.03.2019

Backtest - same code gets different trade results by changing end date
22 Sep 2020, 21:13


Backtest -

 

I'm getting different trade results by changing end date

for example...

if I run 01/01/20 to 11/9/20 I get an overall equity high of 25k

if I run 01/01/20 to 18/9/20 (a later date) I only get an overall equity high of 17k

both runs using exact same code and setup parameters with tick level data for EURUSD

I'm able to recreate this... I'm using a live account

maybe its a cAlgo bug or how cAlgo backtest software calculates using number of days?

regardless something is very wrong

-DE


@ctid1074959
Replies

PanagiotisCharalampous
23 Sep 2020, 08:24

Hi there,

Why do you expect to see the same results on different dates?

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

ctid1074959
23 Sep 2020, 13:53

RE:

PanagiotisCharalampous said:

Hi there,

Why do you expect to see the same results on different dates?

Best Regards,

Panagiotis 

Join us on Telegram

 

obviously I don't expect the same END resulting profit/loss

as mentioned above, I have a variable called :"absolutehigh" for highest profit point for time period... the "absoluteHIgh" for the shorter time period is higher (25k) vs the longer time period of (17k)... this should NOT be

what I do expect is the same trades for the same time periods 

ie

if I run 01/01/20 to 11/09/20 compared to 01/01/20 to 18/09/20 the trades for both runs between 01/01/20 to 11/09/20 should be the same trades

currently they are NOT.... different trades (during the exact same period) are triggering just by moving the end date of the backtest to a later date

understand?


@ctid1074959

PanagiotisCharalampous
23 Sep 2020, 13:58

Hi ctid1074959,

as mentioned above, I have a variable called :"absolutehigh" for highest profit point for time period... the "absoluteHIgh" for the shorter time period is higher (25k) vs the onger time period of (17k)... this should NOT be

No, you did not provide this information in the original post. To help you further with this, you need to provide us with the complete cBot code and steps to reproduce this behavior e.g. cBot parameters or any other information we need to know.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

ctid1074959
23 Sep 2020, 14:18

RE:

PanagiotisCharalampous said:

Hi ctid1074959,

as mentioned above, I have a variable called :"absolutehigh" for highest profit point for time period... the "absoluteHIgh" for the shorter time period is higher (25k) vs the onger time period of (17k)... this should NOT be

No, you did not provide this information in the original post. To help you further with this, you need to provide us with the complete cBot code and steps to reproduce this behavior e.g. cBot parameters or any other information we need to know.

Best Regards,

Panagiotis 

Join us on Telegram

what email do I send to?


@ctid1074959

PanagiotisCharalampous
23 Sep 2020, 14:19

Hi ctid1074959,

You can post it here. If you don't want to disclose the code, you can send it to community@spotware.com

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

ctid1074959
23 Sep 2020, 18:30

RE:

PanagiotisCharalampous said:

Hi ctid1074959,

You can post it here. If you don't want to disclose the code, you can send it to community@spotware.com

Best Regards,

Panagiotis 

Join us on Telegram

Thank you. I sent the code and info as directed.

I exported the trades to review and compare... it seems the longer time period changes the trade execution somehow showing different prices for the same trades and therefore a difference in comparable profit

-de


@ctid1074959

ctid1074959
23 Sep 2020, 18:34

RE: RE:

ctid1074959 said:

PanagiotisCharalampous said:

Hi ctid1074959,

You can post it here. If you don't want to disclose the code, you can send it to community@spotware.com

Best Regards,

Panagiotis 

Join us on Telegram

Thank you. I sent the code and info as directed.

I exported the trades to review and compare... it seems the longer time period changes the trade execution somehow showing different prices for the same trades and therefore a difference in comparable profit

-de

Hopefully you can figure this out and fix this quickly... otherwise using backtest is NOT accurate and NOT reliable.

Thanks again for taking a look... I'm excited to hear your findings.

--de


@ctid1074959

ctid1074959
23 Sep 2020, 18:42

RE: RE: RE:

ctid1074959 said:

ctid1074959 said:

PanagiotisCharalampous said:

Hi ctid1074959,

You can post it here. If you don't want to disclose the code, you can send it to community@spotware.com

Best Regards,

Panagiotis 

Join us on Telegram

Thank you. I sent the code and info as directed.

I exported the trades to review and compare... it seems the longer time period changes the trade execution somehow showing different prices for the same trades and therefore a difference in comparable profit

-de

Hopefully you can figure this out and fix this quickly... otherwise using backtest is NOT accurate and NOT reliable.

Thanks again for taking a look... I'm excited to hear your findings.

--de

 

I see out of 245 trades 12 were executed differently (i.e. at a different price than it's counterpart) when comparing same trades of two different lengths of backtest; that's almost 5% of trades executed differently... so probably as the number of trades grows the impact increases to profit/loss calculations


@ctid1074959

martins
01 Oct 2024, 15:47 ( Updated at: 01 Oct 2024, 16:45 )

RE: Backtest - same code gets different trade results by changing end date

Hi,
I've jusy spent a few hours trying to debug why a cBot logic change altered the trade pattern, but couldn't use the feature of clicking on the yellow balance line, or a trade in the history, to redraw the upper chart with the price & trades, because (I think) you can only go back a 1000 or 2000 trades from the end (is that right?) - so I needed to shorten the backtest period in order to find the relevant part of the chart that matched the history. 

BUT, because of the 'feature' mentioned in this forum item, the equity after the early trades was completly different (due to, as I now know, it using currency conversion rates from different end dates) so the trades soon became completly different too - in other words I couldn't easily find the relevant parts of the longer before & after charts by shortening the period of backtest. The fact that the program change hadn't actually caused a difference in early trades was additionally confusing - it made me wonder whether the change was in effect or not! 

Is there any way of avoiding this effect - say, by using the beginning date for currency rates (since you'd expect trades to alter with a different start date anyway), or some specified date, or even better when the currency pair actually contains the currency rate needed (eg GBPUSD with an account in GBP) then use the proper dynamic rate?

(I suppose another way would be to make cBot decisions based on some sort of overall pips*volume profit measure, to avoid the arbitary exchange rate, but that seems overkill! [and wouldn't include commission or swap])

(using cTrader Desktop v4.9.2)


@martins