How to debug cBots or Custom Indicators in Visual Studio
Microsoft Visual Studio is a powerful IDE which can be used for debugging your cBots or Custom Indicators. All the following steps describe how to debug cBot in Visual Studio, however you can debug Custom Indicators in the same way.
First of all you need to open your cBot in Visual Studio. After Visual Studio is opened you need to build your cBot in “Debug” mode:
Debug will not be possible if you build your cBot in “Release” mode or by using Build command in cAlgo.
After you build your cBot in “Debug” mode you can set Breakpoints.
To set a breakpoint:
- In a source code window, right-click a line of code where you want to set a breakpoint.
- On the context menu, choose Breakpoint and then Insert Breakpoint.
In the “Attach to process” window you need to find cAlgo process where you are going to run your cBot. Please note that attaching Visual Studio Debugger to cAlgo or cTrader processes can interrupt the process and can affect the Advanced Protection, running cBots or other functionality. Please do not attach the Visual Studio Debugger to cAlgo or cTrader processes running under live accounts.
After you select cAlgo process you need to press “Attach button”
After that you need to start or backtest your cBot in cAlgo. When execution of your cBot will reach the breakpoint Visual Studio will be switched to the break mode:
In the break mode you can mouse over a variable and see its value in the tooltip:
You can observe values of all local variables in the Locals Window:
By using Debug Toolbar you can Step in the break mode:
You can visit Visual Studio Resources to find out more information about Debugging in Visual Studio.