Back testing across multiple instruments

Created at 12 Aug 2022, 11:21
AF Affluent_Trading's avatar

Affluent_Trading

Joined 11.08.2022

Back testing across multiple instruments
12 Aug 2022, 11:21


Hi,

I am not even sure if this is possible, but I was wondering if I could back test my bot over multiple instruments at the same time. So for example run it over the last 2 years across AUDCAD, EURJPY and USTEC?

Regards,

Jay


@Affluent_Trading
Replies

Affluent_Trading
12 Aug 2022, 12:06

RE:

PanagiotisCharalampous said:

Hi Jay,

Yes you can.

https://help.ctrader.com/ctrader-automate/backtesting-and-optimizing-cbots/#multi-symbol-backtestoptimize

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Thank you very much, you are my savior today!

Do you have any code examples of this please?


@Affluent_Trading

PanagiotisCharalampous
12 Aug 2022, 12:09

Hi Jay,

Here is one.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous

Affluent_Trading
12 Aug 2022, 12:18

RE:

PanagiotisCharalampous said:

Hi Jay,

Here is one.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Thank you. I can see how that code will trade on multiple instruments at once but my bot runs on each bar. It then analyses the bar data against a set of indicators and if I think there is a trade it will place the trade. I am not sure how I can get the latest bars for  AUDCAD, EURJPY and USTEC (for example), analyse each one and then determine if there is a trade?


@Affluent_Trading

PanagiotisCharalampous
12 Aug 2022, 12:21

Hi Jay,

You can use GetBars() to get the bars for any symbol you want.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous

Affluent_Trading
12 Aug 2022, 12:27

RE:

PanagiotisCharalampous said:

Hi Jay,

You can use GetBars() to get the bars for any symbol you want.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Legendary...thank you very much!


@Affluent_Trading

Affluent_Trading
12 Aug 2022, 12:28 ( Updated at: 12 Aug 2022, 12:31 )

RE:

PanagiotisCharalampous said:

Hi Jay,

You can use GetBars() to get the bars for any symbol you want.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Sorry one final question...to then back test the bot, do I need to still set up an instance against a single instrument but then the code underneath it will go away and get all the data it needs?


@Affluent_Trading

PanagiotisCharalampous
12 Aug 2022, 12:30

Hi Jay,

Correct :)

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous

Affluent_Trading
12 Aug 2022, 12:34

RE:

PanagiotisCharalampous said:

Hi Jay,

Correct :)

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Thank you very much for your help! I am thinking that because it is c# I can code it so that instead of a for each I can run every instrument I go after in a Parallel For each, as long as I set a sensible Max Degree Of Parallelism so that I do not cause the machine it is running on to crash


@Affluent_Trading