OptimizationProcess
interface cAlgo.API Since 5.9
DesktopCLICloud
Represents an optimization process with methods and properties to monitor its status and results.
Environment behaviour
CLI — not supported. Available to plugins only, and plugins cannot run in the CLI.
Cloud — not supported. Available to plugins only, and plugins cannot run in the cloud.
Definition
public interface OptimizationProcess
Namespace: cAlgo.API · Group: Optimization
Examples
if (AlgoRegistry.Get("Sample Trend cBot", AlgoKind.Robot) is not RobotType robotType)
return;
var criteria = new[] { new OptimizationCriterion(OptimizationCriterionType.NetProfit, OptimizationCriterionDirection.Maximize) };
var settings = new OptimizationSettings(new DateTime(2025, 1, 1), new DateTime(2025, 2, 1), 10000, criteria);
var process = Optimization.Start(robotType, "EURUSD", TimeFrame.Hour, settings, new OptimizationIntegerParameter("SlowPeriods", 5, 50, 5));
process.ProgressChanged += args => Print("Progress: {0:F1}%", args.Progress);
process.Completed += args => Print("Completed with {0} passes, error: {1}", process.Passes.Count, process.OptimizationError);
from System import DateTime
algoType = api.AlgoRegistry.Get("Sample Trend cBot", AlgoKind.Robot)
if algoType is None:
return
criteria = [OptimizationCriterion(OptimizationCriterionType.NetProfit, OptimizationCriterionDirection.Maximize)]
settings = OptimizationSettings(DateTime(2025, 1, 1), DateTime(2025, 2, 1), 10000, criteria)
process = api.Optimization.Start(RobotType(algoType), "EURUSD", TimeFrame.Hour, settings, OptimizationIntegerParameter("SlowPeriods", 5, 50, 5))
process.ProgressChanged += lambda args: api.Print(f"Progress: {args.Progress:.1f}%")
process.Completed += lambda args: api.Print(f"Completed with {args.Process.Passes.Count} passes, error: {args.Process.OptimizationError}")
Methods
| Name | Description |
|---|---|
TerminateDesktopCLICloudvoid | Terminates the optimization process. |
Properties
| Name | Description |
|---|---|
BestPassDesktopCLICloudOptimizationPass | Gets the best pass by the configured criteria or custom fitness, or null if no pass has completed. |
IsCompletedDesktopCLICloudbool | Gets a value indicating whether the optimization process is completed. |
JsonReportDesktopCLICloudstring | Gets the optimization result as JSON (the .optres content): configuration plus every pass with its statistics. Returns null if the optimization is not finished or an error occurred. The format matches the desktop optimization "Save results", so the JSON can be opened or imported by the desktop optimization UI. |
OptimizationErrorDesktopCLICloudOptimizationError | Gets the error information if the optimization process failed. |
PassesDesktopCLICloudIReadOnlyList<OptimizationPass> | Gets the passes completed so far, ordered by pass id. While running this grows as passes finish; on completion it holds every pass. |
Events
| Name | Description |
|---|---|
CompletedDesktopCLICloudAction<OptimizationCompletedEventArgs> | Occurs when the optimization process is completed. |
PassCompletedDesktopCLICloudAction<OptimizationPassCompletedEventArgs> | Occurs when an individual optimization pass completes. |
ProgressChangedDesktopCLICloudAction<OptimizationProgressChangedEventArgs> | Occurs when the optimization progress changes. |