BacktestingDataMode usage

Created at 13 Sep 2024, 11:59
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!
YS

ys2310

Joined 03.12.2021

BacktestingDataMode usage
13 Sep 2024, 11:59


Can I check the back testing data mode in my cBot code to handle different scenarios accordingly, such as loading different data files or adjusting your strategy logic like below?

The following code doesn't compile.

using cAlgo.API;
using cAlgo.API.Internals;

namespace cAlgo.Robots
{
   [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
   public class BacktestingDataModeCheckBot : Robot
   {
       protected override void OnStart()
       {
           // Check the current backtesting data mode
           if (BacktestingDataMode == BacktestingDataMode.M1Csv)
           {
               Print("Backtesting using M1 CSV data mode.");
               // Perform specific logic for M1 CSV mode
           }
           else
           {
               Print("Backtesting using a different data mode.");
               // Perform different logic for other data modes
           }
       }

       protected override void OnTick()
       {
           // Your strategy logic here
       }
   }
}
 


@ys2310
Replies

PanagiotisCharalampous
14 Sep 2024, 05:06

Hi there,

This property is not available in cBots. It is only available in plugins.

Best regards,

Panagiotis


@PanagiotisCharalampous