Topics

Forum Topics not found

Replies

agalbenus
26 Jul 2023, 16:28 ( Updated at: 26 Jul 2023, 16:38 )

The only viable way to pause a cBot runtime during backtesting (mainly visual mode) is using windows forms.

        public void Pause()
        {
            if (!IsDebugEnabled) return;
            Print("[DEBUG] pausing the cBot runtime.");
            var result = System.Windows.Forms.MessageBox.Show("Do you want to continue?", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

            if (result == DialogResult.OK)
            {
                Print("[DEBUG] resuming the cBot runtime.");
            }
            else
            {
                Stop();
            }
        }

You also need to enable windows forms in the dotnet solution 

<Project Sdk="Microsoft.NET.Sdk">
 <PropertyGroup>
   <TargetFramework>net6.0-windows</TargetFramework>
   <UseWindowsForms>true</UseWindowsForms>
 </PropertyGroup>
 <ItemGroup>
   <PackageReference Include="cTrader.Automate" Version="1.*" />
 </ItemGroup>
</Project>

and use dotnet sdk for compiling the cBot instead of embedded compiler. You can do that in cTrader settings→Automate→Select Compiler

 

 


@agalbenus